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


PHP group_update_listings函数代码示例

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


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

示例1: group_set_user_default

/**
* Set users default group
*
* @access private
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
{
    global $phpbb_container, $db, $phpbb_dispatcher;
    if (empty($user_id_ary)) {
        return;
    }
    $attribute_ary = array('group_colour' => 'string', 'group_rank' => 'int', 'group_avatar' => 'string', 'group_avatar_type' => 'string', 'group_avatar_width' => 'int', 'group_avatar_height' => 'int');
    $sql_ary = array('group_id' => $group_id);
    // Were group attributes passed to the function? If not we need to obtain them
    if ($group_attributes === false) {
        $sql = 'SELECT ' . implode(', ', array_keys($attribute_ary)) . '
			FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_id = {$group_id}";
        $result = $db->sql_query($sql);
        $group_attributes = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
    }
    foreach ($attribute_ary as $attribute => $type) {
        if (isset($group_attributes[$attribute])) {
            // If we are about to set an avatar or rank, we will not overwrite with empty, unless we are not actually changing the default group
            if ((strpos($attribute, 'group_avatar') === 0 || strpos($attribute, 'group_rank') === 0) && !$group_attributes[$attribute]) {
                continue;
            }
            settype($group_attributes[$attribute], $type);
            $sql_ary[str_replace('group_', 'user_', $attribute)] = $group_attributes[$attribute];
        }
    }
    $updated_sql_ary = $sql_ary;
    // Before we update the user attributes, we will update the rank for users that don't have a custom rank
    if (isset($sql_ary['user_rank'])) {
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET ' . $db->sql_build_array('UPDATE', array('user_rank' => $sql_ary['user_rank'])) . '
			WHERE user_rank = 0
				AND ' . $db->sql_in_set('user_id', $user_id_ary);
        $db->sql_query($sql);
        unset($sql_ary['user_rank']);
    }
    // Before we update the user attributes, we will update the avatar for users that don't have a custom avatar
    $avatar_options = array('user_avatar', 'user_avatar_type', 'user_avatar_height', 'user_avatar_width');
    if (isset($sql_ary['user_avatar'])) {
        $avatar_sql_ary = array();
        foreach ($avatar_options as $avatar_option) {
            if (isset($sql_ary[$avatar_option])) {
                $avatar_sql_ary[$avatar_option] = $sql_ary[$avatar_option];
            }
        }
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET ' . $db->sql_build_array('UPDATE', $avatar_sql_ary) . "\n\t\t\tWHERE user_avatar = ''\n\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
        $db->sql_query($sql);
    }
    // Remove the avatar options, as we already updated them
    foreach ($avatar_options as $avatar_option) {
        unset($sql_ary[$avatar_option]);
    }
    if (!empty($sql_ary)) {
        $sql = 'UPDATE ' . USERS_TABLE . '
			SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
			WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
        $db->sql_query($sql);
    }
    if (isset($sql_ary['user_colour'])) {
        // Update any cached colour information for these users
        $sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\tSET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary);
        $db->sql_query($sql);
        $sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\tSET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_poster', $user_id_ary);
        $db->sql_query($sql);
        $sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\tSET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary);
        $db->sql_query($sql);
        global $config;
        if (in_array($config['newest_user_id'], $user_id_ary)) {
            set_config('newest_user_colour', $sql_ary['user_colour'], true);
        }
    }
    // Make all values available for the event
    $sql_ary = $updated_sql_ary;
    /**
     * Event when the default group is set for an array of users
     *
     * @event core.user_set_default_group
     * @var	int		group_id			ID of the group
     * @var	array	user_id_ary			IDs of the users
     * @var	array	group_attributes	Group attributes which were changed
     * @var	array	update_listing		Update the list of moderators and foes
     * @var	array	sql_ary				User attributes which were changed
     * @since 3.1.0-a1
     */
    $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary');
    extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars)));
    if ($update_listing) {
        group_update_listings($group_id);
    }
    // Because some tables/caches use usercolour-specific data we need to purge this here.
    $phpbb_container->get('cache.driver')->destroy('sql', MODERATOR_CACHE_TABLE);
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:98,代码来源:functions_user.php

示例2: group_set_user_default

/**
* Set users default group
*
* @access private
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
{
    global $db;
    if (empty($user_id_ary)) {
        return;
    }
    $attribute_ary = array('group_colour' => 'string', 'group_rank' => 'int', 'group_avatar' => 'string', 'group_avatar_type' => 'int', 'group_avatar_width' => 'int', 'group_avatar_height' => 'int');
    $sql_ary = array('group_id' => $group_id);
    // Were group attributes passed to the function? If not we need to obtain them
    if ($group_attributes === false) {
        $sql = 'SELECT ' . implode(', ', array_keys($attribute_ary)) . '
			FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_id = {$group_id}";
        $result = $db->sql_query($sql);
        $group_attributes = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
    }
    foreach ($attribute_ary as $attribute => $type) {
        if (isset($group_attributes[$attribute])) {
            // If we are about to set an avatar or rank, we will not overwrite with empty, unless we are not actually changing the default group
            if ((strpos($attribute, 'group_avatar') === 0 || strpos($attribute, 'group_rank') === 0) && !$group_attributes[$attribute]) {
                continue;
            }
            settype($group_attributes[$attribute], $type);
            $sql_ary[str_replace('group_', 'user_', $attribute)] = $group_attributes[$attribute];
        }
    }
    // Before we update the user attributes, we will make a list of those having now the group avatar assigned
    if (isset($sql_ary['user_avatar'])) {
        // Ok, get the original avatar data from users having an uploaded one (we need to remove these from the filesystem)
        $sql = 'SELECT user_id, group_id, user_avatar
			FROM ' . USERS_TABLE . '
			WHERE ' . $db->sql_in_set('user_id', $user_id_ary) . '
				AND user_avatar_type = ' . AVATAR_UPLOAD;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            avatar_delete('user', $row);
        }
        $db->sql_freeresult($result);
    } else {
        unset($sql_ary['user_avatar_type']);
        unset($sql_ary['user_avatar_height']);
        unset($sql_ary['user_avatar_width']);
    }
    $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
		WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
    $db->sql_query($sql);
    if (isset($sql_ary['user_colour'])) {
        // Update any cached colour information for these users
        $sql = 'UPDATE ' . FORUMS_TABLE . " SET forum_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('forum_last_poster_id', $user_id_ary);
        $db->sql_query($sql);
        $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_first_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_poster', $user_id_ary);
        $db->sql_query($sql);
        $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_poster_colour = '" . $db->sql_escape($sql_ary['user_colour']) . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_last_poster_id', $user_id_ary);
        $db->sql_query($sql);
        global $config;
        if (in_array($config['newest_user_id'], $user_id_ary)) {
            set_config('newest_user_colour', $sql_ary['user_colour'], true);
        }
    }
    if ($update_listing) {
        group_update_listings($group_id);
    }
}
开发者ID:Phatboy82,项目名称:phpbbgarage,代码行数:68,代码来源:functions_user.php

示例3: run_tool

    /**
     * Run Tool
     *
     * Does the actual stuff we want the tool to do after submission
     */
    function run_tool(&$error)
    {
        global $config, $user, $db, $cache;
        $user->add_lang('ucp');
        if (!check_form_key('merge_users')) {
            $error[] = 'FORM_INVALID';
            return;
        }
        $source_name = utf8_normalize_nfc(request_var('source_name', '', true));
        $source_id = utf8_normalize_nfc(request_var('source_id', 0));
        $target_name = utf8_normalize_nfc(request_var('target_name', '', true));
        $target_id = utf8_normalize_nfc(request_var('target_id', 0));
        $delete = request_var('delete', false);
        // Check that one source field and one target field is filled in.
        if (!$source_name && empty($source_id) || !$target_name && empty($target_id)) {
            if (!$source_name && !$source_id) {
                $error[] = 'NO_SOURCE_USER';
            }
            if (!$target_name && !$target_id) {
                $error[] = 'NO_TARGET_USER';
            }
            return;
        }
        // Check if both source fields or both target fields are filled in.
        if ($source_name && $source_id || $target_name && $target_id) {
            if ($source_name && $source_id) {
                $error[] = 'BOTH_SOURCE_USER';
            }
            if ($target_name && $target_id) {
                $error[] = 'BOTH_TARGET_USER';
            }
            return;
        }
        $sql = 'SELECT user_id, user_type
			FROM ' . USERS_TABLE . '
			WHERE ' . ($source_name ? 'username_clean = \'' . $db->sql_escape(utf8_clean_string($source_name)) . '\'' : 'user_id = ' . (int) $source_id);
        $result = $db->sql_query($sql);
        $source = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        $sql = 'SELECT user_id, user_type
			FROM ' . USERS_TABLE . '
			WHERE ' . ($target_name ? 'username_clean = \'' . $db->sql_escape(utf8_clean_string($target_name)) . '\'' : 'user_id = ' . (int) $target_id);
        $result = $db->sql_query($sql);
        $target = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$source || !$target) {
            if (!$source) {
                $error[] = 'NO_SOURCE_USER';
            }
            if (!$target) {
                $error[] = 'NO_TARGET_USER';
            }
            return;
        }
        if ($source['user_id'] == $target['user_id']) {
            $error[] = 'MERGE_USERS_SAME_USERS';
            return;
        }
        if ($source['user_type'] != $target['user_type']) {
            if ($source['user_type'] == USER_FOUNDER || $target['user_type'] == USER_FOUNDER) {
                // Cannot merge a founder with a non founder or vice versa
                $error[] = 'MERGE_USERS_BOTH_FOUNDERS';
                return;
            } else {
                if ($source['user_type'] == USER_IGNORE || $target['user_type'] == USER_IGNORE) {
                    // Cannot merge a bot with a non bot or vice versa
                    $error[] = 'MERGE_USERS_BOTH_IGNORE';
                    return;
                }
            }
        }
        $source = (int) $source['user_id'];
        $target = (int) $target['user_id'];
        // Needed for the merge
        include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
        $result = $this->merge($source, $target);
        if (is_string($result)) {
            $error[] = $result;
            return;
        }
        $db->sql_transaction('begin');
        foreach ($result as $sql) {
            $db->sql_query($sql);
        }
        $db->sql_transaction('commit');
        // Delete source user
        if ($delete) {
            user_delete('remove', $source, $post_username = false);
        }
        $sql = 'SELECT DISTINCT group_id
			FROM ' . USER_GROUP_TABLE . "\n\t\t\tWHERE user_id IN ({$source}, {$target})";
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            group_update_listings((int) $row['group_id']);
        }
//.........这里部分代码省略.........
开发者ID:melvingb,项目名称:phpbb3.1-STK,代码行数:101,代码来源:merge_users.php


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