function _forum_access_access_any_forum in Forum Access 6
Helper function to determine the access to the 'forum' menu item.
Returns TRUE if the user has at least one role that can access at least one forum.
1 call to _forum_access_access_any_forum()
- _forum_access_forum_access_callback in ./
forum_access.module - Access callback for the 'forum' menu path.
File
- ./
forum_access.module, line 619 - forum_access.module
Code
function _forum_access_access_any_forum($account = NULL) {
global $user;
static $return = array();
if (!isset($account)) {
$account = $user;
}
if (!isset($return[$account->uid])) {
if ($account->uid == 1) {
return $return[$account->uid] = TRUE;
}
if (!user_access('access content', $account)) {
return $return[$account->uid] = FALSE;
}
$rids = variable_get('forum_access_rids', NULL);
if (!isset($rids)) {
$rids = array();
$result = db_query("SELECT fa.rid FROM {forum_access} fa WHERE fa.grant_view > 0 GROUP BY fa.rid");
while ($role = db_fetch_object($result)) {
$rids[] = $role->rid;
}
variable_set('forum_access_rids', $rids);
}
foreach ($rids as $rid) {
if (isset($account->roles[$rid])) {
return $return[$account->uid] = TRUE;
}
}
$return[$account->uid] = FALSE;
}
return $return[$account->uid];
}