if ($user->data['user_id'] != $user_id) { $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\tSET user_level = '" . $new_level . "'\n\t\t\t\tWHERE user_id = " . $user_id; $result = $db->sql_query($sql); $auth_reset = reset_auth_for_admins($user_id); } $class_notifications->delete_not_auth_notifications(); $db->clear_cache(); cache_tree(true); $message = $lang['Auth_updated'] . '<br /><br />' . sprintf($l_auth_return, '<a href="' . append_sid($l_auth_url . PHP_EXT . '?mode=' . $mode) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid('index.' . PHP_EXT . '?pane=right') . '">', '</a>'); message_die(GENERAL_MESSAGE, $message); } else { // We are changing a user level from admin / jadmin to normal user if ($mode == 'user' && $user_level_new == 'user' && ($user_level == ADMIN || $user_level == JUNIOR_ADMIN)) { // Make admin a user (if already admin) ... ignore if you're trying to change yourself from an admin to user! if ($user->data['user_id'] != $user_id) { $auth_reset = reset_all_auth($user_id); // Update users level, reset to USER $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\tSET user_level = " . USER . "\n\t\t\t\t\tWHERE user_id = " . $user_id; $result = $db->sql_query($sql); } $class_notifications->delete_not_auth_notifications(); $message = $lang['Auth_updated'] . '<br /><br />' . sprintf($l_auth_return, '<a href="' . append_sid($l_auth_url . PHP_EXT . '?mode=' . $mode) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_admin_index'], '<a href="' . append_sid('index.' . PHP_EXT . '?pane=right') . '">', '</a>'); } else { // We are not changing user level, so we may process user permissions... $change_mod_list = isset($_POST['moderator']) ? $_POST['moderator'] : false; if (empty($adv)) { // OLD SQL /* $sql = "SELECT f.* FROM " . FORUMS_TABLE . " f, " . FORUMS_TABLE . " c WHERE f.parent_id = c.forum_id
/** * Remove all auth for not mod forums and set all other auths to 0 because the user is now admin. * This function will not reset the 'auth_mod' field because you may want to show the user as admin in forums list * * @param => user_id * @return => boolean */ function reset_auth_for_admins($user_id) { $auth_delete = delete_all_auth($user_id, true); $auth_reset = reset_all_auth($user_id); return true; }