Line 524 | Line 524 |
---|
ORDER BY role_id ASC'; $result = $db->sql_query($sql);
|
ORDER BY role_id ASC'; $result = $db->sql_query($sql);
|
$this->role_cache = array();
| $role_cache = array();
|
while ($row = $db->sql_fetchrow($result)) {
|
while ($row = $db->sql_fetchrow($result)) {
|
$this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
| $role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
|
} $db->sql_freeresult($result);
|
} $db->sql_freeresult($result);
|
foreach ($this->role_cache as $role_id => $role_options)
| foreach ($role_cache as $role_id => $role_options)
|
{
|
{
|
$this->role_cache[$role_id] = serialize($role_options);
| $role_cache[$role_id] = serialize($role_options);
|
}
|
}
|
$cache->put('_role_cache', $this->role_cache);
| $cache->put('_role_cache', $role_cache);
|
// Now empty user permissions $where_sql = '';
| // Now empty user permissions $where_sql = '';
|
Line 776 | Line 776 |
---|
$sql_group = ($group_id !== false) ? ((!is_array($group_id)) ? 'group_id = ' . (int) $group_id : $db->sql_in_set('group_id', array_map('intval', $group_id))) : ''; $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
|
$sql_group = ($group_id !== false) ? ((!is_array($group_id)) ? 'group_id = ' . (int) $group_id : $db->sql_in_set('group_id', array_map('intval', $group_id))) : ''; $sql_forum = ($forum_id !== false) ? ((!is_array($forum_id)) ? 'AND a.forum_id = ' . (int) $forum_id : 'AND ' . $db->sql_in_set('a.forum_id', array_map('intval', $forum_id))) : '';
|
| $sql_is_local = $forum_id !== false ? 'AND ao.is_local <> 0' : '';
|
$sql_opts = ''; $hold_ary = $sql_ary = array();
| $sql_opts = ''; $hold_ary = $sql_ary = array();
|
Line 787 | Line 788 |
---|
// Grab group settings - non-role specific... $sql_ary[] = 'SELECT a.group_id, a.forum_id, a.auth_setting, a.auth_option_id, ao.auth_option
|
// Grab group settings - non-role specific... $sql_ary[] = 'SELECT a.group_id, a.forum_id, a.auth_setting, a.auth_option_id, ao.auth_option
|
FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . ' ao
| FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " ao
|
WHERE a.auth_role_id = 0
|
WHERE a.auth_role_id = 0
|
AND a.auth_option_id = ao.auth_option_id ' .
| AND a.auth_option_id = ao.auth_option_id $sql_is_local " .
|
(($sql_group) ? 'AND a.' . $sql_group : '') . " $sql_forum $sql_opts
| (($sql_group) ? 'AND a.' . $sql_group : '') . " $sql_forum $sql_opts
|
Line 797 | Line 799 |
---|
// Now grab group settings - role specific... $sql_ary[] = 'SELECT a.group_id, a.forum_id, r.auth_setting, r.auth_option_id, ao.auth_option
|
// Now grab group settings - role specific... $sql_ary[] = 'SELECT a.group_id, a.forum_id, r.auth_setting, r.auth_option_id, ao.auth_option
|
FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . ' ao
| FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_ROLES_DATA_TABLE . ' r, ' . ACL_OPTIONS_TABLE . " ao
|
WHERE a.auth_role_id = r.role_id
|
WHERE a.auth_role_id = r.role_id
|
AND r.auth_option_id = ao.auth_option_id ' .
| $sql_is_local AND r.auth_option_id = ao.auth_option_id " .
|
(($sql_group) ? 'AND a.' . $sql_group : '') . " $sql_forum $sql_opts
| (($sql_group) ? 'AND a.' . $sql_group : '') . " $sql_forum $sql_opts
|
Line 828 | Line 831 |
---|
global $db, $cache;
// Check if the role-cache is there
|
global $db, $cache;
// Check if the role-cache is there
|
if (($this->role_cache = $cache->get('_role_cache')) === false)
| if (($role_cache = $cache->get('_role_cache')) === false)
|
{
|
{
|
$this->role_cache = array();
| $role_cache = array();
|
// We pre-fetch roles $sql = 'SELECT *
| // We pre-fetch roles $sql = 'SELECT *
|
Line 840 | Line 843 |
---|
while ($row = $db->sql_fetchrow($result)) {
|
while ($row = $db->sql_fetchrow($result)) {
|
$this->role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
| $role_cache[$row['role_id']][$row['auth_option_id']] = (int) $row['auth_setting'];
|
} $db->sql_freeresult($result);
|
} $db->sql_freeresult($result);
|
foreach ($this->role_cache as $role_id => $role_options)
| foreach ($role_cache as $role_id => $role_options)
|
{
|
{
|
$this->role_cache[$role_id] = serialize($role_options);
| $role_cache[$role_id] = serialize($role_options);
|
}
|
}
|
$cache->put('_role_cache', $this->role_cache);
| $cache->put('_role_cache', $role_cache);
|
}
$hold_ary = array();
| }
$hold_ary = array();
|
Line 865 | Line 868 |
---|
// If a role is assigned, assign all options included within this role. Else, only set this one option. if ($row['auth_role_id']) {
|
// If a role is assigned, assign all options included within this role. Else, only set this one option. if ($row['auth_role_id']) {
|
$hold_ary[$row['forum_id']] = (empty($hold_ary[$row['forum_id']])) ? unserialize($this->role_cache[$row['auth_role_id']]) : $hold_ary[$row['forum_id']] + unserialize($this->role_cache[$row['auth_role_id']]);
| $hold_ary[$row['forum_id']] = (empty($hold_ary[$row['forum_id']])) ? unserialize($role_cache[$row['auth_role_id']]) : $hold_ary[$row['forum_id']] + unserialize($role_cache[$row['auth_role_id']]);
|
} else {
| } else {
|
Line 890 | Line 893 |
---|
{ $this->_set_group_hold_ary($hold_ary[$row['forum_id']], $row['auth_option_id'], $row['auth_setting']); }
|
{ $this->_set_group_hold_ary($hold_ary[$row['forum_id']], $row['auth_option_id'], $row['auth_setting']); }
|
else if (!empty($this->role_cache[$row['auth_role_id']]))
| else if (!empty($role_cache[$row['auth_role_id']]))
|
{
|
{
|
foreach (unserialize($this->role_cache[$row['auth_role_id']]) as $option_id => $setting)
| foreach (unserialize($role_cache[$row['auth_role_id']]) as $option_id => $setting)
|
{ $this->_set_group_hold_ary($hold_ary[$row['forum_id']], $option_id, $setting); }
| { $this->_set_group_hold_ary($hold_ary[$row['forum_id']], $option_id, $setting); }
|