You are here

function node_limit_limits in Node Limit 6

Same name and namespace in other branches
  1. 8 old/node_limit.module \node_limit_limits()
  2. 7 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 159
Module to restrict the number of nodes a user or role may create.

Code

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

  //get all the limits:
  $res = db_query("SELECT lid FROM {node_limit} ORDER BY weight ASC");
  $applicable_limits = array();
  while ($l = db_fetch_array($res)) {

    // This particular limit id.
    $lid = $l['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_DOESNT_APPLY) {
        $applies = FALSE;
      }
    }
    if ($applies == TRUE) {
      $applicable_limits[] = $lid;
    }
  }
  return $applicable_limits;
}