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


PHP auth::acl_group_raw_data方法代码示例

本文整理汇总了PHP中phpbb\auth\auth::acl_group_raw_data方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::acl_group_raw_data方法的具体用法?PHP auth::acl_group_raw_data怎么用?PHP auth::acl_group_raw_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpbb\auth\auth的用法示例。


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

示例1: phpbb_cache_moderators

/**
* Cache moderators. Called whenever permissions are changed
* via admin_permissions. Changes of usernames and group names
* must be carried through for the moderators table.
*
* @param \phpbb\db\driver\driver_interface $db Database connection
* @param \phpbb\cache\driver\driver_interface Cache driver
* @param \phpbb\auth\auth $auth Authentication object
* @return null
*/
function phpbb_cache_moderators($db, $cache, $auth)
{
    // Remove cached sql results
    $cache->destroy('sql', MODERATOR_CACHE_TABLE);
    // Clear table
    switch ($db->get_sql_layer()) {
        case 'sqlite':
        case 'sqlite3':
            $db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE);
            break;
        default:
            $db->sql_query('TRUNCATE TABLE ' . MODERATOR_CACHE_TABLE);
            break;
    }
    // We add moderators who have forum moderator permissions without an explicit ACL_NEVER setting
    $sql_ary = array();
    // Grab all users having moderative options...
    $hold_ary = $auth->acl_user_raw_data(false, 'm_%', false);
    // Add users?
    if (sizeof($hold_ary)) {
        // At least one moderative option warrants a display
        $ug_id_ary = array_keys($hold_ary);
        // Remove users who have group memberships with DENY moderator permissions
        $sql_ary_deny = array('SELECT' => 'a.forum_id, ug.user_id, g.group_id', 'FROM' => array(ACL_OPTIONS_TABLE => 'o', USER_GROUP_TABLE => 'ug', GROUPS_TABLE => 'g', ACL_GROUPS_TABLE => 'a'), 'LEFT_JOIN' => array(array('FROM' => array(ACL_ROLES_DATA_TABLE => 'r'), 'ON' => 'a.auth_role_id = r.role_id')), 'WHERE' => '(o.auth_option_id = a.auth_option_id OR o.auth_option_id = r.auth_option_id)
				AND ((a.auth_setting = ' . ACL_NEVER . ' AND r.auth_setting IS NULL)
					OR r.auth_setting = ' . ACL_NEVER . ')
				AND a.group_id = ug.group_id
				AND g.group_id = ug.group_id
				AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1)
				AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . "\n\t\t\t\tAND ug.user_pending = 0\n\t\t\t\tAND o.auth_option " . $db->sql_like_expression('m_' . $db->get_any_char()));
        $sql = $db->sql_build_query('SELECT', $sql_ary_deny);
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            if (isset($hold_ary[$row['user_id']][$row['forum_id']])) {
                unset($hold_ary[$row['user_id']][$row['forum_id']]);
            }
        }
        $db->sql_freeresult($result);
        if (sizeof($hold_ary)) {
            // Get usernames...
            $sql = 'SELECT user_id, username
				FROM ' . USERS_TABLE . '
				WHERE ' . $db->sql_in_set('user_id', array_keys($hold_ary));
            $result = $db->sql_query($sql);
            $usernames_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $usernames_ary[$row['user_id']] = $row['username'];
            }
            $db->sql_freeresult($result);
            foreach ($hold_ary as $user_id => $forum_id_ary) {
                // Do not continue if user does not exist
                if (!isset($usernames_ary[$user_id])) {
                    continue;
                }
                foreach ($forum_id_ary as $forum_id => $auth_ary) {
                    $sql_ary[] = array('forum_id' => (int) $forum_id, 'user_id' => (int) $user_id, 'username' => (string) $usernames_ary[$user_id], 'group_id' => 0, 'group_name' => '');
                }
            }
        }
    }
    // Now to the groups...
    $hold_ary = $auth->acl_group_raw_data(false, 'm_%', false);
    if (sizeof($hold_ary)) {
        $ug_id_ary = array_keys($hold_ary);
        // Make sure not hidden or special groups are involved...
        $sql = 'SELECT group_name, group_id, group_type
			FROM ' . GROUPS_TABLE . '
			WHERE ' . $db->sql_in_set('group_id', $ug_id_ary);
        $result = $db->sql_query($sql);
        $groupnames_ary = array();
        while ($row = $db->sql_fetchrow($result)) {
            if ($row['group_type'] == GROUP_HIDDEN || $row['group_type'] == GROUP_SPECIAL) {
                unset($hold_ary[$row['group_id']]);
            }
            $groupnames_ary[$row['group_id']] = $row['group_name'];
        }
        $db->sql_freeresult($result);
        foreach ($hold_ary as $group_id => $forum_id_ary) {
            // If there is no group, we do not assign it...
            if (!isset($groupnames_ary[$group_id])) {
                continue;
            }
            foreach ($forum_id_ary as $forum_id => $auth_ary) {
                $flag = false;
                foreach ($auth_ary as $auth_option => $setting) {
                    // Make sure at least one ACL_YES option is set...
                    if ($setting == ACL_YES) {
                        $flag = true;
                        break;
                    }
//.........这里部分代码省略.........
开发者ID:bruninoit,项目名称:phpbb,代码行数:101,代码来源:functions_admin.php


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