diff options
author | Henry Sudhof <kellanved@phpbb.com> | 2007-05-02 14:09:44 +0000 |
---|---|---|
committer | Henry Sudhof <kellanved@phpbb.com> | 2007-05-02 14:09:44 +0000 |
commit | 475c73f4a82fe25fa11fd07ae0197ddcfc9efc60 (patch) | |
tree | 24b29038135910146341868c8bea4375e51e69fb /phpBB/includes/functions_user.php | |
parent | cb645227f7ca21e4ad39082030650e2bc5933936 (diff) | |
download | forums-475c73f4a82fe25fa11fd07ae0197ddcfc9efc60.tar forums-475c73f4a82fe25fa11fd07ae0197ddcfc9efc60.tar.gz forums-475c73f4a82fe25fa11fd07ae0197ddcfc9efc60.tar.bz2 forums-475c73f4a82fe25fa11fd07ae0197ddcfc9efc60.tar.xz forums-475c73f4a82fe25fa11fd07ae0197ddcfc9efc60.zip |
#10377
Translators, take note. This inroduces a new language variable in acp/groups.php
git-svn-id: file:///svn/phpbb/trunk@7449 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 29d6618f11..8a3fa47b9c 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1931,7 +1931,13 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow { $error[] = (!utf8_strlen($name)) ? $user->lang['GROUP_ERR_USERNAME'] : $user->lang['GROUP_ERR_USER_LONG']; } - + + $err = group_validate_groupname($group_id, $name); + if (!empty($err)) + { + $error[] = $user->lang[$err]; + } + if (!in_array($type, array(GROUP_OPEN, GROUP_CLOSED, GROUP_HIDDEN, GROUP_SPECIAL, GROUP_FREE))) { $error[] = $user->lang['GROUP_ERR_TYPE']; @@ -2462,6 +2468,47 @@ 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) +{ + global $config, $db; + + $groupname = utf8_clean_string($groupname); + + if (!empty($group_id)) + { + $sql = 'SELECT group_name + 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) + { + return false; + } + } + + $sql = 'SELECT group_name + FROM ' . GROUPS_TABLE . " + WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($groupname)) . "'"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + return 'GROUP_NAME_TAKEN'; + } +} + + + /** * Set users default group * |