You are here

function _node_limit_violates_limit in Node Limit 7

Same name and namespace in other branches
  1. 8 old/node_limit.module \_node_limit_violates_limit()
  2. 6 node_limit.module \_node_limit_violates_limit()

Helper function to check limit violations for this node. Always returns FALSE for user 1.

Parameters

$node: The node to check.

3 calls to _node_limit_violates_limit()
node_limit_access in ./node_limit.module
Custom access callback for node/add/TYPE pages.
node_limit_node_prepare in ./node_limit.module
Implements hook_node_prepare().
node_limit_node_validate in ./node_limit.module
Implements hook_node_validate().

File

./node_limit.module, line 247

Code

function _node_limit_violates_limit(&$node, $context = '') {
  if ($node->uid == 1 || user_access(NODE_LIMIT_PERM_OVERRIDE)) {
    return FALSE;
  }
  $limits = node_limit_limits($node);
  foreach ($limits as $idx => $lid) {
    $limit = node_limit_load($lid);
    if ($limit['nlimit'] == NODE_LIMIT_NO_LIMIT) {
      continue;
    }
    $select = _node_limit_sql($limit['lid']);
    $count = $select
      ->execute()
      ->fetchField();
    if ($count >= $limit['nlimit'] && empty($context)) {
      return TRUE;
    }
  }
  return FALSE;
}