diff options
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 457e286840..69990a9524 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2468,27 +2468,32 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna return true; } - /** * A small version of validate_username to check for a group name's existence. To be called directly. */ -function group_validate_groupname($group_id, $groupname) +function group_validate_groupname($group_id, $group_name) { global $config, $db; - $groupname = utf8_clean_string($groupname); + $group_name = utf8_clean_string($group_name); if (!empty($group_id)) { $sql = 'SELECT group_name - FROM ' . GROUPS_TABLE . ' - WHERE group_id = ' . (int)$group_id; + FROM ' . GROUPS_TABLE . ' + WHERE group_id = ' . (int) $group_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - - $allowed_groupname = utf8_clean_string($row['group_name']); - if ($allowed_groupname == $groupname) + + if (!$row) + { + return false; + } + + $allowed_groupname = utf8_clean_string($row['group_name']); + + if ($allowed_groupname == $group_name) { return false; } @@ -2496,7 +2501,7 @@ function group_validate_groupname($group_id, $groupname) $sql = 'SELECT group_name FROM ' . GROUPS_TABLE . " - WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($groupname)) . "'"; + WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($group_name)) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -2505,11 +2510,10 @@ function group_validate_groupname($group_id, $groupname) { return 'GROUP_NAME_TAKEN'; } + return false; } - - /** * Set users default group * |