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


PHP group_set_user_default函数代码示例

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


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

示例1: group_user_attributes

/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $phpbb_root_path, $phpEx, $config;
    // We need both username and user_id info
    $result = user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary) || $result !== false) {
        return 'NO_USERS';
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 1\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query_limit($sql, 1);
            $not_empty = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($not_empty) {
                return 'NO_VALID_USERS';
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = $email_users = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
                $email_users[] = $row;
            }
            $db->sql_freeresult($result);
            if (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            // Send approved email to users...
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger();
            foreach ($email_users as $row) {
                $messenger->template('group_approved', $row['user_lang']);
                $messenger->to($row['user_email'], $row['username']);
                $messenger->im($row['user_jabber'], $row['username']);
                $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username']), 'GROUP_NAME' => htmlspecialchars_decode($group_name), 'U_GROUP' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=membership"));
                $messenger->send($row['user_notify_type']);
            }
            $messenger->save_queue();
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            $sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
            $result = $db->sql_query($sql);
            $groups = array();
            while ($row = $db->sql_fetchrow($result)) {
                if (!isset($groups[$row['group_id']])) {
                    $groups[$row['group_id']] = array();
                }
                $groups[$row['group_id']][] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            foreach ($groups as $gid => $uids) {
                remove_default_rank($gid, $uids);
                remove_default_avatar($gid, $uids);
            }
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    // Clear permissions cache of relevant users
    $auth->acl_clear_prefetch($user_id_ary);
    add_log('admin', $log, $group_name, implode(', ', $username_ary));
    group_update_listings($group_id);
    return false;
}
开发者ID:Phatboy82,项目名称:phpbbgarage,代码行数:88,代码来源:functions_user.php

示例2: group_user_attributes

/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $phpbb_root_path, $phpEx, $config, $phpbb_container;
    // We need both username and user_id info
    $result = user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary) || $result !== false) {
        return 'NO_USERS';
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 1\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query_limit($sql, 1);
            $not_empty = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($not_empty) {
                return 'NO_VALID_USERS';
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
            $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 (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $phpbb_notifications = $phpbb_container->get('notification_manager');
            $phpbb_notifications->add_notifications('notification.type.group_request_approved', array('user_ids' => $user_id_ary, 'group_id' => $group_id, 'group_name' => $group_name));
            $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id);
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            // We only set default group for approved members of the group
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = $username_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            $result = user_get_id_name($user_id_ary, $username_ary);
            if (!sizeof($user_id_ary) || $result !== false) {
                return 'NO_USERS';
            }
            $sql = 'SELECT user_id, group_id
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
            $result = $db->sql_query($sql);
            $groups = array();
            while ($row = $db->sql_fetchrow($result)) {
                if (!isset($groups[$row['group_id']])) {
                    $groups[$row['group_id']] = array();
                }
                $groups[$row['group_id']][] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            foreach ($groups as $gid => $uids) {
                remove_default_rank($gid, $uids);
                remove_default_avatar($gid, $uids);
            }
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    // Clear permissions cache of relevant users
    $auth->acl_clear_prefetch($user_id_ary);
    add_log('admin', $log, $group_name, implode(', ', $username_ary));
    group_update_listings($group_id);
    return false;
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:94,代码来源:functions_user.php

示例3: group_user_attributes

/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $phpbb_root_path, $phpEx, $config;
    // We need both username and user_id info
    user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary)) {
        return false;
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_id IN (" . implode(', ', $user_id_ary) . ')';
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ug.user_id IN (' . implode(', ', $user_id_ary) . ')';
            $result = $db->sql_query($sql);
            $user_id_ary = $email_users = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
                $email_users[] = $row;
            }
            $db->sql_freeresult($result);
            if (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_id IN (" . implode(', ', $user_id_ary) . ')';
            $db->sql_query($sql);
            // Send approved email to users...
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger();
            $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
            foreach ($email_users as $row) {
                $messenger->template('group_approved', $row['user_lang']);
                $messenger->replyto($config['board_email']);
                $messenger->to($row['user_email'], $row['username']);
                $messenger->im($row['user_jabber'], $row['username']);
                $messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($row['username']), 'GROUP_NAME' => html_entity_decode($group_name), 'U_GROUP' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=membership"));
                $messenger->send($row['user_notify_type']);
                $messenger->reset();
            }
            $messenger->save_queue();
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    // Clear permissions cache of relevant users
    $auth->acl_clear_prefetch($user_id_ary);
    add_log('admin', $log, $group_name, implode(', ', $username_ary));
    return true;
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:68,代码来源:functions_user.php

示例4: group_user_attributes

/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $user, $phpbb_container, $phpbb_log, $phpbb_dispatcher;
    // We need both username and user_id info
    $result = user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary) || $result !== false) {
        return 'NO_USERS';
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 1\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query_limit($sql, 1);
            $not_empty = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($not_empty) {
                return 'NO_VALID_USERS';
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.username_clean, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ' . $db->sql_in_set('ug.user_id', $user_id_ary);
            $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 (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $db->sql_query($sql);
            /* @var $phpbb_notifications \phpbb\notification\manager */
            $phpbb_notifications = $phpbb_container->get('notification_manager');
            $phpbb_notifications->add_notifications('notification.type.group_request_approved', array('user_ids' => $user_id_ary, 'group_id' => $group_id, 'group_name' => $group_name));
            $phpbb_notifications->delete_notifications('notification.type.group_request', $user_id_ary, $group_id);
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            // We only set default group for approved members of the group
            $sql = 'SELECT user_id
				FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
            $result = $db->sql_query($sql);
            $user_id_ary = $username_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            $result = user_get_id_name($user_id_ary, $username_ary);
            if (!sizeof($user_id_ary) || $result !== false) {
                return 'NO_USERS';
            }
            $sql = 'SELECT user_id, group_id
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
            $result = $db->sql_query($sql);
            $groups = array();
            while ($row = $db->sql_fetchrow($result)) {
                if (!isset($groups[$row['group_id']])) {
                    $groups[$row['group_id']] = array();
                }
                $groups[$row['group_id']][] = $row['user_id'];
            }
            $db->sql_freeresult($result);
            foreach ($groups as $gid => $uids) {
                remove_default_rank($gid, $uids);
                remove_default_avatar($gid, $uids);
            }
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    /**
     * Event to perform additional actions on setting user group attributes
     *
     * @event core.user_set_group_attributes
     * @var	int		group_id			ID of the group
     * @var	string	group_name			Name of the group
     * @var	array	user_id_ary			IDs of the users to set group attributes
     * @var	array	username_ary		Names of the users to set group attributes
     * @var	array	group_attributes	Group attributes which were changed
     * @var	string	action				Action to perform over the group members
     * @since 3.1.10-RC1
//.........这里部分代码省略.........
开发者ID:phpbb,项目名称:phpbb,代码行数:101,代码来源:functions_user.php

示例5: phpbb_convert_authentication

/**
* Convert authentication
* user, group and forum table has to be filled in order to work
*/
function phpbb_convert_authentication($mode)
{
	global $db, $src_db, $same_db, $convert, $phpbb_root_path, $phpEx;

	if ($mode == 'start')
	{
		$db->sql_query($convert->truncate_statement . ACL_USERS_TABLE);
		$db->sql_query($convert->truncate_statement . ACL_GROUPS_TABLE);

		// Grab users with admin permissions
		$sql = "SELECT uid, permissions
			FROM {$convert->src_table_prefix}adminoptions
			WHERE uid >= 1";
		$result = $src_db->sql_query($sql);
		$admins = $founders = array();

		while ($row = $src_db->sql_fetchrow($result))
		{
			$user_id = (int) phpbb_user_id($row['uid']);
			$permissions = unserialize($row['permissions']);
			$admins[] = $user_id;

			if ($permissions['user']['admin_permissions'])
			{
				$founders[] = $user_id;
			} 
		}
		$src_db->sql_freeresult($result);

		// We'll set the users that can manage admin permissions as founders.
		$sql = 'UPDATE ' . USERS_TABLE . '
			SET user_type = ' . USER_FOUNDER . "
			WHERE " . $db->sql_in_set('user_id', $founders);
		$db->sql_query($sql);

		$bot_group_id = get_group_id('bots');

		user_group_auth('guests', 'SELECT user_id, {GUESTS} FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS, false);
		user_group_auth('registered', 'SELECT user_id, {REGISTERED} FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS . " AND group_id <> $bot_group_id", false);

		$auth_sql = 'SELECT user_id, {ADMINISTRATORS} FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $admins);
		user_group_auth('administrators', $auth_sql, false);

		$auth_sql = 'SELECT user_id, {GLOBAL_MODERATORS} FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $admins);
		user_group_auth('global_moderators', $auth_sql, false);

		if (!function_exists('group_set_user_default'))
		{
			include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
		}

		// Set the admin group as their default group.
		group_set_user_default(get_group_id('administrators'), $admins);
	}
	else if ($mode == 'first')
	{
		// Assign permission roles and other default permissions

		// guests having u_download and u_search ability
		$db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) SELECT ' . get_group_id('guests') . ', 0, auth_option_id, 0, 1 FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option IN ('u_', 'u_download', 'u_search')");

		// administrators/global mods having full user features
		mass_auth('group_role', 0, 'administrators', 'USER_FULL');
		mass_auth('group_role', 0, 'global_moderators', 'USER_FULL');

		// By default all converted administrators are given full access
		mass_auth('group_role', 0, 'administrators', 'ADMIN_FULL');

		// All registered users are assigned the standard user role
		mass_auth('group_role', 0, 'registered', 'USER_STANDARD');
		mass_auth('group_role', 0, 'registered_coppa', 'USER_STANDARD');

		// Instead of administrators being global moderators we give the MOD_FULL role to global mods (admins already assigned to this group)
		mass_auth('group_role', 0, 'global_moderators', 'MOD_FULL');
	}
}
开发者ID:phimax,项目名称:zoroak,代码行数:80,代码来源:functions_mybb16.php


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