Ignore:
Timestamp:
Mar 31, 2010, 6:32:40 PM (14 years ago)
Author:
george
Message:
  • Upraveno: Aktualizace fóra.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/includes/acp/auth.php

    r400 r702  
    33*
    44* @package phpBB3
    5 * @version $Id: auth.php 8479 2008-03-29 00:22:48Z naderman $
     5* @version $Id$
    66* @copyright (c) 2005 phpBB Group
    77* @license http://opensource.org/licenses/gpl-license.php GNU Public License
     
    5959                }
    6060        }
    61        
     61
    6262        /**
    6363        * Get permission mask
     
    141141                                }
    142142
    143                                
     143
    144144                                $hold_ary[$userdata['user_id']] = array();
    145145                                foreach ($forum_ids as $f_id)
     
    346346                // Build js roles array (role data assignments)
    347347                $s_role_js_array = '';
    348                
     348
    349349                if (sizeof($roles))
    350350                {
     
    697697                $cur_options = array();
    698698
     699                // Determine current options
    699700                $sql = 'SELECT auth_option, is_global, is_local
    700701                        FROM ' . ACL_OPTIONS_TABLE . '
     
    704705                while ($row = $db->sql_fetchrow($result))
    705706                {
    706                         if ($row['is_global'])
    707                         {
    708                                 $cur_options['global'][] = $row['auth_option'];
    709                         }
    710 
    711                         if ($row['is_local'])
    712                         {
    713                                 $cur_options['local'][] = $row['auth_option'];
    714                         }
     707                        $cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local');
    715708                }
    716709                $db->sql_freeresult($result);
     
    727720                        foreach ($option_ary as $option_value)
    728721                        {
    729                                 if (!in_array($option_value, $cur_options[$type]))
    730                                 {
    731                                         $new_options[$type][] = $option_value;
    732                                 }
     722                                $new_options[$type][] = $option_value;
    733723
    734724                                $flag = substr($option_value, 0, strpos($option_value, '_') + 1);
    735725
    736                                 if (!in_array($flag, $cur_options[$type]) && !in_array($flag, $new_options[$type]))
     726                                if (!in_array($flag, $new_options[$type]))
    737727                                {
    738728                                        $new_options[$type][] = $flag;
     
    745735                $options['local'] = array_diff($new_options['local'], $new_options['global']);
    746736                $options['global'] = array_diff($new_options['global'], $new_options['local']);
    747                 $options['local_global'] = array_intersect($new_options['local'], $new_options['global']);
    748 
    749                 $sql_ary = array();
    750 
     737                $options['both'] = array_intersect($new_options['local'], $new_options['global']);
     738
     739                // Now check which options to add/update
     740                $add_options = $update_options = array();
     741
     742                // First local ones...
    751743                foreach ($options as $type => $option_ary)
    752744                {
    753745                        foreach ($option_ary as $option)
    754746                        {
    755                                 $sql_ary[] = array(
    756                                         'auth_option'   => (string) $option,
    757                                         'is_global'             => ($type == 'global' || $type == 'local_global') ? 1 : 0,
    758                                         'is_local'              => ($type == 'local' || $type == 'local_global') ? 1 : 0
    759                                 );
    760                         }
    761                 }
    762 
    763                 $db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary);
     747                                if (!isset($cur_options[$option]))
     748                                {
     749                                        $add_options[] = array(
     750                                                'auth_option'   => (string) $option,
     751                                                'is_global'             => ($type == 'global' || $type == 'both') ? 1 : 0,
     752                                                'is_local'              => ($type == 'local' || $type == 'both') ? 1 : 0
     753                                        );
     754
     755                                        continue;
     756                                }
     757
     758                                // Else, update existing entry if it is changed...
     759                                if ($type === $cur_options[$option])
     760                                {
     761                                        continue;
     762                                }
     763
     764                                // New type is always both:
     765                                // If is now both, we set both.
     766                                // If it was global the new one is local and we need to set it to both
     767                                // If it was local the new one is global and we need to set it to both
     768                                $update_options[] = $option;
     769                        }
     770                }
     771
     772                if (!empty($add_options))
     773                {
     774                        $db->sql_multi_insert(ACL_OPTIONS_TABLE, $add_options);
     775                }
     776
     777                if (!empty($update_options))
     778                {
     779                        $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . '
     780                                SET is_global = 1, is_local = 1
     781                                WHERE ' . $db->sql_in_set('auth_option', $update_options);
     782                        $db->sql_query($sql);
     783                }
    764784
    765785                $cache->destroy('_acl_options');
     
    803823                $flag = key($auth);
    804824                $flag = substr($flag, 0, strpos($flag, '_') + 1);
    805                
     825
    806826                // This ID (the any-flag) is set if one or more permissions are true...
    807827                $any_option_id = (int) $this->acl_options['id'][$flag];
     
    917937                $flag = key($auth);
    918938                $flag = substr($flag, 0, strpos($flag, '_') + 1);
    919                
     939
    920940                // Remove any-flag from auth ary
    921941                if (isset($auth[$flag]))
     
    10681088                        $where_sql[] = $db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary));
    10691089                }
    1070                
     1090
    10711091                $sql = "DELETE FROM $table
    10721092                        WHERE " . implode(' AND ', $where_sql);
     
    10911111                                'S_NEVER'       => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false,
    10921112                                'S_NO'          => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false,
    1093                                                        
     1113
    10941114                                'CAT_NAME'      => $user->lang['permission_cat'][$cat])
    10951115                        );
     
    11801200                                        );
    11811201                                }
    1182                        
     1202
    11831203                                $cat = $user->lang['acl_' . $permission]['cat'];
    1184                        
     1204
    11851205                                // Build our categories array
    11861206                                if (!isset($categories[$cat]))
Note: See TracChangeset for help on using the changeset viewer.