You are here

function node_limit_limits in Node Limit 7

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

Returns all the limits that can be applied to a specific node.

Parameters

$node: The node object that may be limited.

1 call to node_limit_limits()
_node_limit_violates_limit in ./node_limit.module
Helper function to check limit violations for this node. Always returns FALSE for user 1.

File

./node_limit.module, line 291

Code

function node_limit_limits(&$node) {
  $user = user_load($node->uid);

  //get all the limits:
  $query = db_select('node_limit', 'nl')
    ->fields('nl')
    ->orderBy('weight', 'ASC')
    ->execute();
  $applicable_limits = array();
  foreach ($query as $row) {

    // This particular limit id.
    $lid = $row->lid;
    $applies = TRUE;
    $submodule_applies = module_invoke_all('node_limit_applies_in_context', $lid, $node, $user);
    foreach ($submodule_applies as $module => $module_applies) {

      // A submodule returns DOESNT_APPLY if it requires a specific user or role, etc,
      // and the context given does not satisfy that.
      if ($module_applies == NODE_LIMIT_LIMIT_DOESNT_APPLY) {
        $applies = FALSE;
      }
    }
    if ($applies == TRUE) {
      $applicable_limits[] = $lid;
    }
  }
  return $applicable_limits;
}