auth comments, cache(?)

git-svn-id: file:///svn/phpbb/trunk@2936 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2002-10-06 11:57:45 +00:00
parent 803cc378dd
commit 7a8b0a6f27

View file

@ -503,12 +503,57 @@ class auth
$and_sql = ( !$forum_id ) ? $and_sql : "( a.forum_id = $forum_id ) OR ( a.forum_id <> $forum_id AND ( ao.auth_value LIKE 'forum_list' OR ao.auth_value LIKE 'mod_%' ) )";
$and_sql .= " OR ao.auth_value LIKE 'admin_%'";
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_value
FROM " . ACL_PREFETCH_TABLE . " a, " . ACL_OPTIONS_TABLE . " ao
WHERE a.user_id = " . $userdata['user_id'] . "
AND ao.auth_option_id = a.auth_option_id
AND ( $and_sql )";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
{
do
{
// Why do we explode this? Because there are places we want to see
// whether any forum option is set rather than a specifc one
// by breaking apart the type from what it applies to we can easily determine
// this ... is there a better soln?
list($auth_main, $auth_type) = explode('_', $row['auth_value']);
$this->acl[$row['forum_id']][$auth_main][$auth_type] = $row['auth_allow_deny'];
}
while ( $row = $db->sql_fetchrow($result) );
}
else
{
$this->cache_acl($userdata);
}
}
return;
}
// Look up an option
function get_acl($forum_id, $auth_main, $auth_type = false)
{
return ( $auth_main && $auth_type ) ? ( ( $this->founder || max($this->acl[0]['admin']) ) ? true : $this->acl[$forum_id][$auth_main][$auth_type] ) : max($this->acl[$forum_id][$auth_main]);
}
// Is this needed?
function get_acl_admin($auth_type = false)
{
return ( $this->founder ) ? true : $this->get_acl(0, 'admin', $auth_type);
}
// Cache data
function cache_acl(&$userdata)
{
global $db;
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_value
FROM " . ACL_GROUPS_TABLE . " a, " . ACL_OPTIONS_TABLE . " ao, " . USER_GROUP_TABLE . " ug
WHERE ug.user_id = " . $userdata['user_id'] . "
AND a.group_id = ug.group_id
AND ao.auth_option_id = a.auth_option_id
AND ( $and_sql )";
AND ao.auth_option_id = a.auth_option_id";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
@ -534,8 +579,7 @@ class auth
$sql = "SELECT a.forum_id, a.auth_allow_deny, ao.auth_value
FROM " . ACL_USERS_TABLE . " a, " . ACL_OPTIONS_TABLE . " ao
WHERE a.user_id = " . $userdata['user_id'] . "
AND ao.auth_option_id = a.auth_option_id
AND ( $and_sql )";
AND ao.auth_option_id = a.auth_option_id";
$result = $db->sql_query($sql);
if ( $row = $db->sql_fetchrow($result) )
@ -578,29 +622,17 @@ class auth
break;
}
}
//
// Store max result for type ... used later ... saves time
//
$this->acl[$forum_id][$type][0] = max($this->acl[$forum_id][$type]);
}
}
}
}
return;
}
function get_acl($forum_id, $auth_main, $auth_type = false)
{
return ( $auth_main && $auth_type ) ? ( ( $this->founder || $this->acl[0]['admin'][0] ) ? true : $this->acl[$forum_id][$auth_main][$auth_type] ) : $this->acl[$forum_id][$auth_main][0];
}
function get_acl_admin($auth_type = false)
{
return ( $this->founder ) ? true : $this->get_acl(0, 'admin', $auth_type);
// Insert pre-calculated results ...
}
// Could these go into an admin only extends since this is only used for the admin
// panel (and perhaps the MCP in future)? Would need to instantiate that class rather
// than (or in addition to) auth if we do (which is done in common ...)
function set_acl_user(&$forum_id, &$user_id, &$auth, $dependencies = false)
{
global $db;