本文整理汇总了PHP中UrlManager::deleteUserFromAllUrls方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlManager::deleteUserFromAllUrls方法的具体用法?PHP UrlManager::deleteUserFromAllUrls怎么用?PHP UrlManager::deleteUserFromAllUrls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlManager
的用法示例。
在下文中一共展示了UrlManager::deleteUserFromAllUrls方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_user
/**
* Delete a user from the platform, and all its belongings. This is a
* very dangerous function that should only be accessible by
* super-admins. Other roles should only be able to disable a user,
* which removes access to the platform but doesn't delete anything.
* @param int The ID of th user to be deleted
* @return boolean true if user is successfully deleted, false otherwise
* @assert (null) === false
* @assert ('abc') === false
*/
public static function delete_user($user_id)
{
if ($user_id != strval(intval($user_id))) {
return false;
}
if ($user_id === false) {
return false;
}
if (!self::can_delete_user($user_id)) {
return false;
}
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$usergroup_rel_user = Database::get_main_table(TABLE_USERGROUP_REL_USER);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_session = Database::get_main_table(TABLE_MAIN_SESSION);
$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
$table_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$table_group = Database::get_course_table(TABLE_GROUP_USER);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
// Unsubscribe the user from all groups in all his courses
$sql = "SELECT c.id FROM {$table_course} c, {$table_course_user} cu\n WHERE\n cu.user_id = '" . $user_id . "' AND\n relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND\n c.id = cu.c_id";
$res = Database::query($sql);
while ($course = Database::fetch_object($res)) {
$sql = "DELETE FROM {$table_group}\n WHERE c_id = {$course->id} AND user_id = {$user_id}";
Database::query($sql);
}
// Unsubscribe user from usergroup_rel_user
$sql = "DELETE FROM {$usergroup_rel_user} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Unsubscribe user from all courses
$sql = "DELETE FROM {$table_course_user} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Unsubscribe user from all courses in sessions
$sql = "DELETE FROM {$table_session_course_user} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// If the user was added as a id_coach then set the current admin as coach see BT#
$currentUserId = api_get_user_id();
$sql = "UPDATE {$table_session} SET id_coach = {$currentUserId}\n WHERE id_coach = '" . $user_id . "'";
Database::query($sql);
$sql = "UPDATE {$table_session} SET id_coach = {$currentUserId}\n WHERE session_admin_id = '" . $user_id . "'";
Database::query($sql);
// Unsubscribe user from all sessions
$sql = "DELETE FROM {$table_session_user}\n WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Delete user picture
/* TODO: Logic about api_get_setting('split_users_upload_directory') == 'true'
a user has 4 different sized photos to be deleted. */
$user_info = api_get_user_info($user_id);
if (strlen($user_info['picture_uri']) > 0) {
$path = self::getUserPathById($user_id, 'system');
$img_path = $path . $user_info['picture_uri'];
if (file_exists($img_path)) {
unlink($img_path);
}
}
// Delete the personal course categories
$course_cat_table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "DELETE FROM {$course_cat_table} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Delete user from the admin table
$sql = "DELETE FROM {$table_admin} WHERE user_id = '" . $user_id . "'";
Database::query($sql);
// Delete the personal agenda-items from this user
$agenda_table = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$sql = "DELETE FROM {$agenda_table} WHERE user = '" . $user_id . "'";
Database::query($sql);
$gradebook_results_table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'DELETE FROM ' . $gradebook_results_table . ' WHERE user_id = ' . $user_id;
Database::query($sql);
$extraFieldValue = new ExtraFieldValue('user');
$extraFieldValue->deleteValuesByItem($user_id);
UrlManager::deleteUserFromAllUrls($user_id);
if (api_get_setting('social.allow_social_tool') == 'true') {
$userGroup = new UserGroup();
//Delete user from portal groups
$group_list = $userGroup->get_groups_by_user($user_id);
if (!empty($group_list)) {
foreach ($group_list as $group_id => $data) {
$userGroup->delete_user_rel_group($user_id, $group_id);
}
}
// Delete user from friend lists
SocialManager::remove_user_rel_user($user_id, true);
}
// Removing survey invitation
SurveyManager::delete_all_survey_invitations_by_user($user_id);
// Delete students works
$sql = "DELETE FROM {$table_work} WHERE user_id = {$user_id} AND c_id <> 0";
//.........这里部分代码省略.........