From 4cbf6bc703bdadf716197b68a89b3438247ff022 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Mar 2009 16:34:26 +0000 Subject: 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 --- phpBB/modules/acp/auth.php | 64 ++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 22 deletions(-) (limited to 'phpBB/modules/acp/auth.php') 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(); -- cgit v1.2.1