You are here

function hook_node_limit_applies_in_context in Node Limit 8

Same name and namespace in other branches
  1. 7 node_limit.api.php \hook_node_limit_applies_in_context()

Check node limit context.

Called when trying to know which submodule is concerned by a given node limit. Each of them have to answer with an integer as follow : NODE_LIMIT_LIMIT_NEUTRAL if the node limit do nos use this submodule ; NODE_LIMIT_LIMIT_DOESNT_APPLY if this submodule is not concerned ; NODE_LIMIT_LIMIT_DOES_APPLY if this submodule is concerned.

Parameters

int $lid: The node limit id.

object $node: The node to check.

object $user: The user to check.

Return value

array An array with a single key-value pair. The key must be the name of the submodule, and the value is an integer between 0 and 2 inclusive.

5 functions implement hook_node_limit_applies_in_context()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

node_limit_interval_node_limit_applies_in_context in old/node_limit_interval/node_limit_interval.module
Implements hook_node_limit_applies_in_context().
node_limit_role_node_limit_applies_in_context in old/node_limit_role/node_limit_role.module
Implements hook_node_limit_applies_in_context().
node_limit_type_node_limit_applies_in_context in old/node_limit_type/node_limit_type.module
Implements hook_node_limit_applies_in_context().
node_limit_userofrole_node_limit_applies_in_context in old/node_limit_userofrole/node_limit_userofrole.module
Implements hook_node_limit_applies_in_context().
node_limit_user_node_limit_applies_in_context in old/node_limit_user/node_limit_user.module
Implements hook_node_limit_applies_in_context().
1 invocation of hook_node_limit_applies_in_context()
node_limit_limits in old/node_limit.module
Returns all the limits that can be applied to a specific node.

File

old/node_limit.api.php, line 28
Node_limit api reference.

Code

function hook_node_limit_applies_in_context($lid, $node, $user) {

  // Load limit data.
  $limit = submodule_node_limit_load($lid);
  $applies = NODE_LIMIT_LIMIT_DOES_APPLY;
  if (empty($limit)) {
    $applies = NODE_LIMIT_LIMIT_NEUTRAL;
  }
  elseif ($limit['submodule']['uid'] != $user->uid) {
    $applies = NODE_LIMIT_LIMIT_DOESNT_APPLY;
  }
  return array(
    'submodule' => $applies,
  );
}