当前位置: 首页>>代码示例>>PHP>>正文


PHP group_validate_groupname函数代码示例

本文整理汇总了PHP中group_validate_groupname函数的典型用法代码示例。如果您正苦于以下问题:PHP group_validate_groupname函数的具体用法?PHP group_validate_groupname怎么用?PHP group_validate_groupname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了group_validate_groupname函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: group_create

/**
* Add or edit a group. If we're editing a group we only update user
* parameters such as rank, etc. if they are changed
*/
function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false)
{
    global $phpbb_root_path, $config, $db, $user, $file_upload, $phpbb_container;
    $error = array();
    // Attributes which also affect the users table
    $user_attribute_ary = array('group_colour', 'group_rank', 'group_avatar', 'group_avatar_type', 'group_avatar_width', 'group_avatar_height');
    // Check data. Limit group name length.
    if (!utf8_strlen($name) || utf8_strlen($name) > 60) {
        $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'];
    }
    $group_teampage = !empty($group_attributes['group_teampage']);
    unset($group_attributes['group_teampage']);
    if (!sizeof($error)) {
        $current_legend = \phpbb\groupposition\legend::GROUP_DISABLED;
        $current_teampage = \phpbb\groupposition\teampage::GROUP_DISABLED;
        $legend = $phpbb_container->get('groupposition.legend');
        $teampage = $phpbb_container->get('groupposition.teampage');
        if ($group_id) {
            try {
                $current_legend = $legend->get_group_value($group_id);
                $current_teampage = $teampage->get_group_value($group_id);
            } catch (\phpbb\groupposition\exception $exception) {
                trigger_error($user->lang($exception->getMessage()));
            }
        }
        if (!empty($group_attributes['group_legend'])) {
            if ($group_id && $current_legend == \phpbb\groupposition\legend::GROUP_DISABLED || !$group_id) {
                // Old group currently not in the legend or new group, add at the end.
                $group_attributes['group_legend'] = 1 + $legend->get_group_count();
            } else {
                // Group stayes in the legend
                $group_attributes['group_legend'] = $current_legend;
            }
        } else {
            if ($group_id && $current_legend != \phpbb\groupposition\legend::GROUP_DISABLED) {
                // Group is removed from the legend
                try {
                    $legend->delete_group($group_id, true);
                } catch (\phpbb\groupposition\exception $exception) {
                    trigger_error($user->lang($exception->getMessage()));
                }
                $group_attributes['group_legend'] = \phpbb\groupposition\legend::GROUP_DISABLED;
            } else {
                $group_attributes['group_legend'] = \phpbb\groupposition\legend::GROUP_DISABLED;
            }
        }
        // Unset the objects, we don't need them anymore.
        unset($legend);
        $user_ary = array();
        $sql_ary = array('group_name' => (string) $name, 'group_desc' => (string) $desc, 'group_desc_uid' => '', 'group_desc_bitfield' => '', 'group_type' => (int) $type);
        // Parse description
        if ($desc) {
            generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies);
        }
        if (sizeof($group_attributes)) {
            // Merge them with $sql_ary to properly update the group
            $sql_ary = array_merge($sql_ary, $group_attributes);
        }
        // Setting the log message before we set the group id (if group gets added)
        $log = $group_id ? 'LOG_GROUP_UPDATED' : 'LOG_GROUP_CREATED';
        $query = '';
        if ($group_id) {
            $sql = 'SELECT user_id
				FROM ' . USERS_TABLE . '
				WHERE group_id = ' . $group_id;
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $user_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            if (isset($sql_ary['group_avatar'])) {
                remove_default_avatar($group_id, $user_ary);
            }
            if (isset($sql_ary['group_rank'])) {
                remove_default_rank($group_id, $user_ary);
            }
            $sql = 'UPDATE ' . GROUPS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\tWHERE group_id = {$group_id}";
            $db->sql_query($sql);
            // Since we may update the name too, we need to do this on other tables too...
            $sql = 'UPDATE ' . MODERATOR_CACHE_TABLE . "\n\t\t\t\tSET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "'\n\t\t\t\tWHERE group_id = {$group_id}";
            $db->sql_query($sql);
            // One special case is the group skip auth setting. If this was changed we need to purge permissions for this group
            if (isset($group_attributes['group_skip_auth'])) {
                // Get users within this group...
                $sql = 'SELECT user_id
					FROM ' . USER_GROUP_TABLE . '
					WHERE group_id = ' . $group_id . '
						AND user_pending = 0';
//.........这里部分代码省略.........
开发者ID:Tarendai,项目名称:spring-website,代码行数:101,代码来源:functions_user.php

示例2: group_create

/**
* Add or edit a group. If we're editing a group we only update user
* parameters such as rank, etc. if they are changed
*/
function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false)
{
    global $phpbb_root_path, $config, $db, $user, $file_upload;
    $error = array();
    $attribute_ary = array('group_colour' => 'string', 'group_rank' => 'int', 'group_avatar' => 'string', 'group_avatar_type' => 'int', 'group_avatar_width' => 'int', 'group_avatar_height' => 'int', 'group_receive_pm' => 'int', 'group_legend' => 'int', 'group_message_limit' => 'int', 'group_max_recipients' => 'int', 'group_founder_manage' => 'int');
    // Those are group-only attributes
    $group_only_ary = array('group_receive_pm', 'group_legend', 'group_message_limit', 'group_max_recipients', 'group_founder_manage');
    // Check data. Limit group name length.
    if (!utf8_strlen($name) || utf8_strlen($name) > 60) {
        $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'];
    }
    if (!sizeof($error)) {
        $user_ary = array();
        $sql_ary = array('group_name' => (string) $name, 'group_desc' => (string) $desc, 'group_desc_uid' => '', 'group_desc_bitfield' => '', 'group_type' => (int) $type);
        // Parse description
        if ($desc) {
            generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies);
        }
        if (sizeof($group_attributes)) {
            foreach ($attribute_ary as $attribute => $_type) {
                if (isset($group_attributes[$attribute])) {
                    settype($group_attributes[$attribute], $_type);
                    $sql_ary[$attribute] = $group_attributes[$attribute];
                }
            }
        }
        // Setting the log message before we set the group id (if group gets added)
        $log = $group_id ? 'LOG_GROUP_UPDATED' : 'LOG_GROUP_CREATED';
        $query = '';
        if ($group_id) {
            $sql = 'SELECT user_id
				FROM ' . USERS_TABLE . '
				WHERE group_id = ' . $group_id;
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $user_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            if (isset($sql_ary['group_avatar']) && !$sql_ary['group_avatar']) {
                remove_default_avatar($group_id, $user_ary);
            }
            if (isset($sql_ary['group_rank']) && !$sql_ary['group_rank']) {
                remove_default_rank($group_id, $user_ary);
            }
            $sql = 'UPDATE ' . GROUPS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\tWHERE group_id = {$group_id}";
            $db->sql_query($sql);
            // Since we may update the name too, we need to do this on other tables too...
            $sql = 'UPDATE ' . MODERATOR_CACHE_TABLE . "\n\t\t\t\tSET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "'\n\t\t\t\tWHERE group_id = {$group_id}";
            $db->sql_query($sql);
        } else {
            $sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
            $db->sql_query($sql);
        }
        if (!$group_id) {
            $group_id = $db->sql_nextid();
            if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == AVATAR_UPLOAD) {
                group_correct_avatar($group_id, $sql_ary['group_avatar']);
            }
        }
        // Set user attributes
        $sql_ary = array();
        if (sizeof($group_attributes)) {
            foreach ($attribute_ary as $attribute => $_type) {
                if (isset($group_attributes[$attribute]) && !in_array($attribute, $group_only_ary)) {
                    // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set...
                    if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) {
                        continue;
                    }
                    $sql_ary[$attribute] = $group_attributes[$attribute];
                }
            }
        }
        if (sizeof($sql_ary) && sizeof($user_ary)) {
            group_set_user_default($group_id, $user_ary, $sql_ary);
        }
        $name = $type == GROUP_SPECIAL ? $user->lang['G_' . $name] : $name;
        add_log('admin', $log, $name);
        group_update_listings($group_id);
    }
    return sizeof($error) ? $error : false;
}
开发者ID:Phatboy82,项目名称:phpbbgarage,代码行数:93,代码来源:functions_user.php

示例3: group_create

/**
* Add or edit a group. If we're editing a group we only update user
* parameters such as rank, etc. if they are changed
*/
function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow_desc_bbcode = false, $allow_desc_urls = false, $allow_desc_smilies = false)
{
    global $phpbb_root_path, $config, $db, $user, $file_upload;
    $error = array();
    // Attributes which also affect the users table
    $user_attribute_ary = array('group_colour', 'group_rank', 'group_avatar', 'group_avatar_type', 'group_avatar_width', 'group_avatar_height');
    // Check data. Limit group name length.
    if (!utf8_strlen($name) || utf8_strlen($name) > 60) {
        $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'];
    }
    if (!sizeof($error)) {
        $user_ary = array();
        $sql_ary = array('group_name' => (string) $name, 'group_desc' => (string) $desc, 'group_desc_uid' => '', 'group_desc_bitfield' => '', 'group_type' => (int) $type);
        // Parse description
        if ($desc) {
            generate_text_for_storage($sql_ary['group_desc'], $sql_ary['group_desc_uid'], $sql_ary['group_desc_bitfield'], $sql_ary['group_desc_options'], $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies);
        }
        if (sizeof($group_attributes)) {
            // Merge them with $sql_ary to properly update the group
            $sql_ary = array_merge($sql_ary, $group_attributes);
        }
        // Setting the log message before we set the group id (if group gets added)
        $log = $group_id ? 'LOG_GROUP_UPDATED' : 'LOG_GROUP_CREATED';
        $query = '';
        if ($group_id) {
            $sql = 'SELECT user_id
				FROM ' . USERS_TABLE . '
				WHERE group_id = ' . $group_id;
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $user_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            if (isset($sql_ary['group_avatar']) && !$sql_ary['group_avatar']) {
                remove_default_avatar($group_id, $user_ary);
            }
            if (isset($sql_ary['group_rank']) && !$sql_ary['group_rank']) {
                remove_default_rank($group_id, $user_ary);
            }
            $sql = 'UPDATE ' . GROUPS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\tWHERE group_id = {$group_id}";
            $db->sql_query($sql);
            // Since we may update the name too, we need to do this on other tables too...
            $sql = 'UPDATE ' . MODERATOR_CACHE_TABLE . "\n\t\t\t\tSET group_name = '" . $db->sql_escape($sql_ary['group_name']) . "'\n\t\t\t\tWHERE group_id = {$group_id}";
            $db->sql_query($sql);
            // One special case is the group skip auth setting. If this was changed we need to purge permissions for this group
            if (isset($group_attributes['group_skip_auth'])) {
                // Get users within this group...
                $sql = 'SELECT user_id
					FROM ' . USER_GROUP_TABLE . '
					WHERE group_id = ' . $group_id . '
						AND user_pending = 0';
                $result = $db->sql_query($sql);
                $user_id_ary = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $user_id_ary[] = $row['user_id'];
                }
                $db->sql_freeresult($result);
                if (!empty($user_id_ary)) {
                    global $auth;
                    // Clear permissions cache of relevant users
                    $auth->acl_clear_prefetch($user_id_ary);
                }
            }
        } else {
            $sql = 'INSERT INTO ' . GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
            $db->sql_query($sql);
        }
        if (!$group_id) {
            $group_id = $db->sql_nextid();
            if (isset($sql_ary['group_avatar_type']) && $sql_ary['group_avatar_type'] == AVATAR_UPLOAD) {
                group_correct_avatar($group_id, $sql_ary['group_avatar']);
            }
        }
        // Set user attributes
        $sql_ary = array();
        if (sizeof($group_attributes)) {
            // Go through the user attributes array, check if a group attribute matches it and then set it. ;)
            foreach ($user_attribute_ary as $attribute) {
                if (!isset($group_attributes[$attribute])) {
                    continue;
                }
                // If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set...
                if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute]) {
                    continue;
                }
                $sql_ary[$attribute] = $group_attributes[$attribute];
            }
        }
//.........这里部分代码省略.........
开发者ID:eyumay,项目名称:ju.ejhs,代码行数:101,代码来源:functions_user.php


注:本文中的group_validate_groupname函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。