function forum_access_access in Forum Access 7
Same name and namespace in other branches
- 8 includes/forum_access.common.inc \forum_access_access()
- 5 forum_access.module \forum_access_access()
- 6 forum_access.module \forum_access_access()
Implements access checking.
$op -- view, update, delete or create $tid -- the tid of the forum $account -- the account to test for; if NULL use current user $administer_nodes_sees_everything -- pass FALSE to ignore the 'administer nodes' permission
Return: FALSE - access not granted 1 - access granted 2 - access granted for forum moderator
8 calls to forum_access_access()
- forum_access_node_access in ./
forum_access.module - Implements hook_node_access().
- _forum_access_comment_access_callback in ./
forum_access.module - _forum_access_comment_edit_callback in ./
forum_access.module - _forum_access_comment_view_alter in ./
forum_access.node.inc - Really implements hook_comment_view_alter().
- _forum_access_forum_form in ./
forum_access.admin.inc - Rewrite the forum administration page with our new access rules.
File
- ./
forum_access.module, line 673 - forum_access.module
Code
function forum_access_access($op, $tid, $account = NULL, $administer_nodes_sees_everything = TRUE) {
$cache =& drupal_static(__FUNCTION__, array());
if (!$account) {
global $user;
$account = $user;
}
if (user_access('bypass node access', $account)) {
//TODO revise (including comment above)
// $administer_nodes_sees_everything && user_access('administer nodes', $account) && array_search($type, array('view', 'update', 'delete')) !== FALSE) {
return 1;
}
if ($op == 'delete' && user_access('delete any forum content', $account)) {
return 1;
}
if ($op == 'update' && user_access('edit any forum content', $account)) {
return 1;
}
if (!isset($cache[$account->uid][$tid][$op])) {
$query = db_select('forum_access', 'fa')
->fields('fa', array(
'tid',
))
->condition("fa.grant_{$op}", 1, '>=')
->condition('fa.rid', array_keys($account->roles), 'IN');
if ($tid != 0) {
$query = $query
->condition('fa.tid', $tid, '=');
}
$result = $query
->execute()
->fetchField();
if ($result) {
$cache[$account->uid][$tid][$op] = 1;
}
else {
// check our moderators too
$result = forum_access_is_moderator($account, $tid);
$cache[$account->uid][$tid][$op] = $result ? 2 : FALSE;
}
}
return $cache[$account->uid][$tid][$op];
}