Exemplo n.º 1
0
 /**
  * Apply all permissions
  */
 function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
 {
     global $db, $cache, $user, $auth;
     global $request;
     // User or group to be set?
     $ug_type = sizeof($user_id) ? 'user' : 'group';
     // Check the permission setting again
     if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) {
         trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
     }
     $auth_settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \src\request\request_interface::POST);
     $auth_roles = $request->variable('role', array(0 => array(0 => 0)), false, \src\request\request_interface::POST);
     $ug_ids = $forum_ids = array();
     // We need to go through the auth settings
     foreach ($auth_settings as $ug_id => $forum_auth_row) {
         $ug_id = (int) $ug_id;
         $ug_ids[] = $ug_id;
         foreach ($forum_auth_row as $forum_id => $auth_options) {
             $forum_id = (int) $forum_id;
             $forum_ids[] = $forum_id;
             // Check role...
             $assigned_role = isset($auth_roles[$ug_id][$forum_id]) ? (int) $auth_roles[$ug_id][$forum_id] : 0;
             // If the auth settings differ from the assigned role, then do not set a role...
             if ($assigned_role) {
                 if (!$this->check_assigned_role($assigned_role, $auth_options)) {
                     $assigned_role = 0;
                 }
             }
             // Update the permission set...
             $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_options, $assigned_role, false);
         }
     }
     $auth_admin->acl_clear_prefetch();
     // Do we need to recache the moderator lists?
     if ($permission_type == 'm_') {
         src_cache_moderators($db, $cache, $auth);
     }
     // Remove users who are now moderators or admins from everyones foes list
     if ($permission_type == 'm_' || $permission_type == 'a_') {
         src_update_foes($db, $auth, $group_id, $user_id);
     }
     $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids);
     if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') {
         trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids)));
     } else {
         trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action));
     }
 }
Exemplo n.º 2
0
/**
* Re-cache moderators and foes if group has a_ or m_ permissions
*/
function group_update_listings($group_id)
{
    global $db, $cache, $auth;
    $hold_ary = $auth->acl_group_raw_data($group_id, array('a_', 'm_'));
    if (!sizeof($hold_ary)) {
        return;
    }
    $mod_permissions = $admin_permissions = false;
    foreach ($hold_ary as $g_id => $forum_ary) {
        foreach ($forum_ary as $forum_id => $auth_ary) {
            foreach ($auth_ary as $auth_option => $setting) {
                if ($mod_permissions && $admin_permissions) {
                    break 3;
                }
                if ($setting != ACL_YES) {
                    continue;
                }
                if ($auth_option == 'm_') {
                    $mod_permissions = true;
                }
                if ($auth_option == 'a_') {
                    $admin_permissions = true;
                }
            }
        }
    }
    if ($mod_permissions) {
        if (!function_exists('src_cache_moderators')) {
            global $src_root_path, $phpEx;
            include $src_root_path . 'includes/functions_admin.' . $phpEx;
        }
        src_cache_moderators($db, $cache, $auth);
    }
    if ($mod_permissions || $admin_permissions) {
        if (!function_exists('src_update_foes')) {
            global $src_root_path, $phpEx;
            include $src_root_path . 'includes/functions_admin.' . $phpEx;
        }
        src_update_foes($db, $auth, array($group_id));
    }
}
Exemplo n.º 3
0
/**
* Removes moderators and administrators from foe lists.
*
* @deprecated 3.1
* @param array|bool $group_id If an array, remove all members of this group from foe lists, or false to ignore
* @param array|bool $user_id If an array, remove this user from foe lists, or false to ignore
* @return null
*/
function update_foes($group_id = false, $user_id = false)
{
    global $db, $auth;
    return src_update_foes($db, $auth, $group_id, $user_id);
}