mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
this was not supposed to be committed yet - it is completely untested
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9392 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
9f023e4711
commit
47fdd374bd
1 changed files with 31 additions and 51 deletions
|
@ -696,7 +696,6 @@ class auth_admin extends auth
|
||||||
|
|
||||||
$cur_options = array();
|
$cur_options = array();
|
||||||
|
|
||||||
// Determine current options
|
|
||||||
$sql = 'SELECT auth_option, is_global, is_local
|
$sql = 'SELECT auth_option, is_global, is_local
|
||||||
FROM ' . ACL_OPTIONS_TABLE . '
|
FROM ' . ACL_OPTIONS_TABLE . '
|
||||||
ORDER BY auth_option_id';
|
ORDER BY auth_option_id';
|
||||||
|
@ -704,7 +703,15 @@ class auth_admin extends auth
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local');
|
if ($row['is_global'])
|
||||||
|
{
|
||||||
|
$cur_options['global'][] = $row['auth_option'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row['is_local'])
|
||||||
|
{
|
||||||
|
$cur_options['local'][] = $row['auth_option'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
@ -719,11 +726,14 @@ class auth_admin extends auth
|
||||||
|
|
||||||
foreach ($option_ary as $option_value)
|
foreach ($option_ary as $option_value)
|
||||||
{
|
{
|
||||||
$new_options[$type][] = $option_value;
|
if (!in_array($option_value, $cur_options[$type]))
|
||||||
|
{
|
||||||
|
$new_options[$type][] = $option_value;
|
||||||
|
}
|
||||||
|
|
||||||
$flag = substr($option_value, 0, strpos($option_value, '_') + 1);
|
$flag = substr($option_value, 0, strpos($option_value, '_') + 1);
|
||||||
|
|
||||||
if (!in_array($flag, $new_options[$type]))
|
if (!in_array($flag, $cur_options[$type]) && !in_array($flag, $new_options[$type]))
|
||||||
{
|
{
|
||||||
$new_options[$type][] = $flag;
|
$new_options[$type][] = $flag;
|
||||||
}
|
}
|
||||||
|
@ -734,53 +744,23 @@ class auth_admin extends auth
|
||||||
$options = array();
|
$options = array();
|
||||||
$options['local'] = array_diff($new_options['local'], $new_options['global']);
|
$options['local'] = array_diff($new_options['local'], $new_options['global']);
|
||||||
$options['global'] = array_diff($new_options['global'], $new_options['local']);
|
$options['global'] = array_diff($new_options['global'], $new_options['local']);
|
||||||
$options['both'] = array_intersect($new_options['local'], $new_options['global']);
|
$options['local_global'] = array_intersect($new_options['local'], $new_options['global']);
|
||||||
|
|
||||||
// Now check which options to add/update
|
$sql_ary = array();
|
||||||
$add_options = $update_options = array();
|
|
||||||
|
|
||||||
// First local ones...
|
|
||||||
foreach ($options as $type => $option_ary)
|
foreach ($options as $type => $option_ary)
|
||||||
{
|
{
|
||||||
foreach ($option_ary as $option)
|
foreach ($option_ary as $option)
|
||||||
{
|
{
|
||||||
if (!isset($cur_options[$option]))
|
$sql_ary[] = array(
|
||||||
{
|
'auth_option' => (string) $option,
|
||||||
$add_options[] = array(
|
'is_global' => ($type == 'global' || $type == 'local_global') ? 1 : 0,
|
||||||
'auth_option' => (string) $option,
|
'is_local' => ($type == 'local' || $type == 'local_global') ? 1 : 0
|
||||||
'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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($add_options))
|
$db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary);
|
||||||
{
|
|
||||||
$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 ' . $db->sql_in_set('auth_option', $update_options);
|
|
||||||
$db->sql_query($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache->destroy('_acl_options');
|
$cache->destroy('_acl_options');
|
||||||
$this->acl_clear_prefetch();
|
$this->acl_clear_prefetch();
|
||||||
|
|
Loading…
Add table
Reference in a new issue