diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-03-22 16:34:26 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-03-22 16:34:26 +0000 |
commit | 4cbf6bc703bdadf716197b68a89b3438247ff022 (patch) | |
tree | 952f7fe84b9428d10e4d49d535c5108e06d4640a /phpBB/modules/acp/auth.php | |
parent | fac9c024ff370eb4c34f7a7ffa9048732e5c74c7 (diff) | |
download | forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.gz forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.bz2 forums-4cbf6bc703bdadf716197b68a89b3438247ff022.tar.xz forums-4cbf6bc703bdadf716197b68a89b3438247ff022.zip |
Merge most changes from 3.0.x branch since the 25th december.
(Captcha changes for refreshing captcha image not included)
git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/modules/acp/auth.php')
-rw-r--r-- | phpBB/modules/acp/auth.php | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/phpBB/modules/acp/auth.php b/phpBB/modules/acp/auth.php index 396b66c76f..b1dae06cea 100644 --- a/phpBB/modules/acp/auth.php +++ b/phpBB/modules/acp/auth.php @@ -679,6 +679,7 @@ class auth_admin extends auth { $cur_options = array(); + // Determine current options $sql = 'SELECT auth_option, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . ' ORDER BY auth_option_id'; @@ -686,15 +687,7 @@ class auth_admin extends auth while ($row = phpbb::$db->sql_fetchrow($result)) { - if ($row['is_global']) - { - $cur_options['global'][] = $row['auth_option']; - } - - if ($row['is_local']) - { - $cur_options['local'][] = $row['auth_option']; - } + $cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local'); } phpbb::$db->sql_freeresult($result); @@ -709,14 +702,11 @@ class auth_admin extends auth foreach ($option_ary as $option_value) { - if (!in_array($option_value, $cur_options[$type])) - { - $new_options[$type][] = $option_value; - } + $new_options[$type][] = $option_value; $flag = substr($option_value, 0, strpos($option_value, '_') + 1); - if (!in_array($flag, $cur_options[$type]) && !in_array($flag, $new_options[$type])) + if (!in_array($flag, $new_options[$type])) { $new_options[$type][] = $flag; } @@ -727,23 +717,53 @@ class auth_admin extends auth $options = array(); $options['local'] = array_diff($new_options['local'], $new_options['global']); $options['global'] = array_diff($new_options['global'], $new_options['local']); - $options['local_global'] = array_intersect($new_options['local'], $new_options['global']); + $options['both'] = array_intersect($new_options['local'], $new_options['global']); - $sql_ary = array(); + // Now check which options to add/update + $add_options = $update_options = array(); + // First local ones... foreach ($options as $type => $option_ary) { foreach ($option_ary as $option) { - $sql_ary[] = array( - 'auth_option' => (string) $option, - 'is_global' => ($type == 'global' || $type == 'local_global') ? 1 : 0, - 'is_local' => ($type == 'local' || $type == 'local_global') ? 1 : 0 - ); + if (!isset($cur_options[$option])) + { + $add_options[] = array( + 'auth_option' => (string) $option, + 'is_global' => ($type == 'global' || $type == 'both') ? 1 : 0, + 'is_local' => ($type == 'local' || $type == 'both') ? 1 : 0 + ); + + continue; + } + + // Else, update existing entry if it is changed... + if ($type === $cur_options[$option]) + { + continue; + } + + // New type is always both: + // If is now both, we set both. + // If it was global the new one is local and we need to set it to both + // If it was local the new one is global and we need to set it to both + $update_options[] = $option; } } - phpbb::$db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary); + if (!empty($add_options)) + { + phpbb::$db->sql_multi_insert(ACL_OPTIONS_TABLE, $add_options); + } + + if (!empty($update_options)) + { + $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' + SET is_global = 1, is_local = 1 + WHERE ' . phpbb::$db->sql_in_set('auth_option', $update_options); + phpbb::$db->sql_query($sql); + } phpbb::$acm->destroy('acl_options'); $this->acl_clear_prefetch(); |