Exemple #1
0
 /**
  * Apply all permissions
  */
 function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id)
 {
     global $user, $auth;
     // 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 = isset($_POST['setting']) ? $_POST['setting'] : array();
     $auth_roles = isset($_POST['role']) ? $_POST['role'] : array();
     $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_') {
         cache_moderators();
     }
     // Remove users who are now moderators or admins from everyones foes list
     if ($permission_type == 'm_' || $permission_type == 'a_') {
         update_foes($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));
     }
 }
/**
* Re-cache moderators and foes if group has a_ or m_ permissions
*/
function group_update_listings($group_id)
{
    global $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('cache_moderators')) {
            global $phpbb_root_path, $phpEx;
            include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
        }
        cache_moderators();
    }
    if ($mod_permissions || $admin_permissions) {
        if (!function_exists('update_foes')) {
            global $phpbb_root_path, $phpEx;
            include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
        }
        update_foes(array($group_id));
    }
}
     if (sizeof($auth_setting)) {
         // Loop through all user/group ids
         foreach ($ug_data as $id) {
             $auth_admin->acl_set($ug_type, $forum_id[$auth_submode], $id, $auth_setting);
         }
     }
 }
 // Do we need to recache the moderator lists? We do if the mode
 // was mod or auth_settings['mod'] is a non-zero size array
 if ($mode == 'mod' || isset($auth_settings['mod']) && sizeof($auth_settings['mod'])) {
     cache_moderators();
 }
 // Remove users who are now moderators or admins from everyones foes
 // list
 if ($mode == 'mod' || isset($auth_settings['mod']) && sizeof($auth_settings['mod']) || $mode == 'admin' || isset($auth_settings['admin']) && sizeof($auth_settings['admin'])) {
     update_foes();
 }
 // Logging ... first grab user or groupnames ...
 $sql = $ug_type == 'group' ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE group_id' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE user_id';
 $sql .= ' IN (' . implode(', ', array_map('intval', $ug_data)) . ')';
 $result = $_CLASS['core_db']->query($sql);
 $l_ug_list = '';
 while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
     $l_ug_list .= ($l_ug_list != '' ? ', ' : '') . ($row['group_type'] == GROUP_SYSTEM ? '<span class="blue">' . $_CLASS['core_user']->lang['G_' . $row['name']] . '</span>' : $row['name']);
 }
 $_CLASS['core_db']->free_result($result);
 $auth_submode = array_keys($auth_settings);
 foreach ($auth_submode as $sub_mode) {
     if (!in_array(0, $forum_id[$sub_mode])) {
         // Grab the forum details if non-zero forum_id
         $sql = 'SELECT forum_name