phpBB

Code Changes

File: includes/acp/auth.php

  Unmodified   Added   Modified   Removed
Line 22Line 22
*/
class auth_admin extends auth
{

*/
class auth_admin extends auth
{

	var $option_ids = array();


 
	/**
* Init auth settings
*/

	/**
* Init auth settings
*/

Line 33Line 31

if (($this->acl_options = $cache->get('_acl_options')) === false)
{


if (($this->acl_options = $cache->get('_acl_options')) === false)
{

			$sql = 'SELECT auth_option, is_global, is_local

			$sql = 'SELECT auth_option_id, auth_option, is_global, is_local

				FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id';
$result = $db->sql_query($sql);

				FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id';
$result = $db->sql_query($sql);

Line 51Line 49
				{
$this->acl_options['local'][$row['auth_option']] = $local++;
}

				{
$this->acl_options['local'][$row['auth_option']] = $local++;
}

 

$this->acl_options['id'][$row['auth_option']] = (int) $row['auth_option_id'];
$this->acl_options['option'][(int) $row['auth_option_id']] = $row['auth_option'];

			}
$db->sql_freeresult($result);

$cache->put('_acl_options', $this->acl_options);

			}
$db->sql_freeresult($result);

$cache->put('_acl_options', $this->acl_options);

		}

if (!sizeof($this->option_ids))
{
$sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE;
$result = $db->sql_query($sql);

$this->option_ids = array();
while ($row = $db->sql_fetchrow($result))
{
$this->option_ids[$row['auth_option']] = $row['auth_option_id'];
}
$db->sql_freeresult($result);

 
		}
}


		}
}


Line 126Line 113

while ($row = $db->sql_fetchrow($result))
{


while ($row = $db->sql_fetchrow($result))
{

				$forum_ids[] = $row['forum_id'];

				$forum_ids[] = (int) $row['forum_id'];

			}
$db->sql_freeresult($result);
}

			}
$db->sql_freeresult($result);
}

Line 709Line 696

$cur_options = array();



$cur_options = array();


 
		// Determine current options

		$sql = 'SELECT auth_option, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id';

		$sql = 'SELECT auth_option, is_global, is_local
FROM ' . ACL_OPTIONS_TABLE . '
ORDER BY auth_option_id';

Line 716Line 704

while ($row = $db->sql_fetchrow($result))
{


while ($row = $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');









		}
$db->sql_freeresult($result);


		}
$db->sql_freeresult($result);


Line 738Line 718
			$option_ary = array_unique($option_ary);

foreach ($option_ary as $option_value)

			$option_ary = array_unique($option_ary);

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);



$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;
}

				{
$new_options[$type][] = $flag;
}

Line 757Line 734
		$options = array();
$options['local'] = array_diff($new_options['local'], $new_options['global']);
$options['global'] = array_diff($new_options['global'], $new_options['local']);

		$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)
{

		foreach ($options as $type => $option_ary)
{
foreach ($option_ary as $option)
{

				$sql_ary[] = array(



				if (!isset($cur_options[$option]))
{
$add_options[] = array(

					'auth_option'	=> (string) $option,

					'auth_option'	=> (string) $option,

					'is_global'		=> ($type == 'global' || $type == 'local_global') ? 1 : 0,
'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;

		}


		}


		$db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary);




















				// 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, $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');
$this->acl_clear_prefetch();


$cache->destroy('_acl_options');
$this->acl_clear_prefetch();

 

// Because we just changed the options and also purged the options cache, we instantly update/regenerate it for later calls to succeed.
$this->acl_options = array();
$this->auth_admin();


return true;
}


return true;
}

Line 813Line 824
		$flag = substr($flag, 0, strpos($flag, '_') + 1);

// This ID (the any-flag) is set if one or more permissions are true...

		$flag = substr($flag, 0, strpos($flag, '_') + 1);

// This ID (the any-flag) is set if one or more permissions are true...

		$any_option_id = (int) $this->option_ids[$flag];

		$any_option_id = (int) $this->acl_options['id'][$flag];


// Remove any-flag from auth ary
if (isset($auth[$flag]))


// Remove any-flag from auth ary
if (isset($auth[$flag]))

Line 825Line 836
		$auth_option_ids = array((int)$any_option_id);
foreach ($auth as $auth_option => $auth_setting)
{

		$auth_option_ids = array((int)$any_option_id);
foreach ($auth as $auth_option => $auth_setting)
{

			$auth_option_ids[] = (int) $this->option_ids[$auth_option];

			$auth_option_ids[] = (int) $this->acl_options['id'][$auth_option];

		}

$sql = "DELETE FROM $table

		}

$sql = "DELETE FROM $table

Line 888Line 899
			{
foreach ($auth as $auth_option => $setting)
{

			{
foreach ($auth as $auth_option => $setting)
{

					$auth_option_id = (int) $this->option_ids[$auth_option];

					$auth_option_id = (int) $this->acl_options['id'][$auth_option];


if ($setting != ACL_NO)
{


if ($setting != ACL_NO)
{

Line 944Line 955
		$sql_ary = array();
foreach ($auth as $auth_option => $setting)
{

		$sql_ary = array();
foreach ($auth as $auth_option => $setting)
{

			$auth_option_id = (int) $this->option_ids[$auth_option];

			$auth_option_id = (int) $this->acl_options['id'][$auth_option];


if ($setting != ACL_NO)
{


if ($setting != ACL_NO)
{

Line 961Line 972
		{
$sql_ary[] = array(
'role_id' => (int) $role_id,

		{
$sql_ary[] = array(
'role_id' => (int) $role_id,

				'auth_option_id'	=> (int) $this->option_ids[$flag],

				'auth_option_id'	=> (int) $this->acl_options['id'][$flag],

				'auth_setting'		=> ACL_NEVER
);
}

				'auth_setting'		=> ACL_NEVER
);
}

Line 1238Line 1249
			return false;
}


			return false;
}


		$hold_ary = $this->acl_raw_data($from_user_id, false, false);

if (isset($hold_ary[$from_user_id]))
{
$hold_ary = $hold_ary[$from_user_id];
}

		$hold_ary = $this->acl_raw_data_single_user($from_user_id);






		
// Key 0 in $hold_ary are global options, all others are forum_ids


		
// Key 0 in $hold_ary are global options, all others are forum_ids


Line 1252Line 1258
		{
if (strpos($opt, 'a_') === 0)
{

		{
if (strpos($opt, 'a_') === 0)
{

				$hold_ary[0][$opt] = ACL_NEVER;

				$hold_ary[0][$this->acl_options['id'][$opt]] = ACL_NEVER;

			}
}

// Force a_switchperm to be allowed

			}
}

// Force a_switchperm to be allowed

		$hold_ary[0]['a_switchperm'] = ACL_YES;

		$hold_ary[0][$this->acl_options['id']['a_switchperm']] = ACL_YES;


$user_permissions = $this->build_bitstring($hold_ary);



$user_permissions = $this->build_bitstring($hold_ary);