You are here

function node_limit_access in Node Limit 8

Same name and namespace in other branches
  1. 7 node_limit.module \node_limit_access()

Custom access callback for node/add/TYPE pages.

Parameters

string $type: Content type to check.

object $account: User account to check (default to current user).

2 calls to node_limit_access()
node_limit_node_prepare in old/node_limit.module
Implements hook_node_prepare().
_node_limit_add_access in old/node_limit.module
Rewriten access callback for node/add page.
1 string reference to 'node_limit_access'
node_limit_menu_alter in old/node_limit.module
Implements hook_menu_alter().

File

old/node_limit.module, line 142

Code

function node_limit_access($type, $account = NULL) {
  global $user;
  if (empty($account)) {
    $account = $user;
  }
  $access =& drupal_static(__FUNCTION__, array());
  if (!array_key_exists($account->uid, $access)) {
    $access[$account->uid] = array();
  }
  if (!array_key_exists($type, $access[$account->uid])) {
    $node = new stdClass();
    $node->uid = $account->uid;
    $node->type = $type;
    $oldCallback = variable_get('node_limit_' . $type . '_access_callback');
    $oldArguments = variable_get('node_limit_' . $type . '_access_arguments', array());
    $oldAccess = function_exists($oldCallback) ? call_user_func_array($oldCallback, $oldArguments) : TRUE;
    $access[$account->uid][$type] = !_node_limit_violates_limit($node) && $oldAccess;
  }
  return $access[$account->uid][$type];
}