From a841fe70a8234bf158165105339e32aa5ceb75a2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 17 Jan 2007 18:41:49 +0000 Subject: ok, handled some bugs... the most important being validate_username (the variable passed to validate_data([...]array('username', [...])) and updating group listings while doing relevant group actions. Oh, and PM icons are working now. :o git-svn-id: file:///svn/phpbb/trunk@6894 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 25ac6f24eb..3e60580293 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -817,9 +817,11 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas } // Fetch currently set bans of the specified type and exclude state. Prevent duplicate bans. + $sql_where = ($type == 'ban_userid') ? 'ban_userid <> 0' : "$type <> ''"; + $sql = "SELECT $type FROM " . BANLIST_TABLE . " - WHERE $type <> '' + WHERE $sql_where AND ban_exclude = $ban_exclude"; $result = $db->sql_query($sql); @@ -1148,15 +1150,19 @@ function validate_match($string, $optional = false, $match) * Also checks if it includes the " character, which we don't allow in usernames. * Used for registering, changing names, and posting anonymously with a username * +* @param string $username The username to check +* @param string $allowed_username An allowed username, default being $user->data['username'] +* * @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) */ -function validate_username($username) +function validate_username($username, $allowed_username = false) { global $config, $db, $user, $cache; $clean_username = utf8_clean_string($username); + $allowed_username = ($allowed_username === false) ? $user->data['username_clean'] : utf8_clean_string($allowed_username); - if (utf8_clean_string($user->data['username']) == $clean_username) + if ($allowed_username == $clean_username) { return false; } @@ -1190,7 +1196,6 @@ function validate_username($username) return 'USERNAME_TAKEN'; } - $bad_usernames = $cache->obtain_disallowed_usernames(); foreach ($bad_usernames as $bad_username) @@ -1725,6 +1730,8 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow $name = ($type == GROUP_SPECIAL) ? $user->lang['G_' . $name] : $name; add_log('admin', $log, $name); + + group_update_listings($group_id); } return (sizeof($error)) ? $error : false; @@ -2013,6 +2020,8 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false, add_log('admin', $log, $group_name, implode(', ', $username_ary)); + group_update_listings($group_id); + // Return false - no error return false; } @@ -2115,13 +2124,17 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna add_log('admin', $log, $group_name, implode(', ', $username_ary)); + group_update_listings($group_id); + return true; } /** * Set users default group +* +* @private */ -function group_set_user_default($group_id, $user_id_ary, $group_attributes = false) +function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false) { global $db; @@ -2212,6 +2225,11 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal set_config('newest_user_colour', $sql_ary['user_colour'], true); } } + + if ($update_listing) + { + group_update_listings($group_id); + } } /** -- cgit v1.2.1