You are here

function _node_limit_sql in Node Limit 6

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

Generates the sql statement to find the nodes that apply to a particular limit. Modules that implement hook_node_limit_sql() should sprintf their arguments into the returned array. This will be changed in Drupal 7, which will be able to accept an array of arguments to db_query().

Parameters

$lid: Identifier of limit rule.

1 call to _node_limit_sql()
_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 142
Module to restrict the number of nodes a user or role may create.

Code

function _node_limit_sql($lid) {
  $sql = "SELECT COUNT(n.nid) AS number FROM {node} AS n";
  $components = module_invoke_all('node_limit_sql', $lid);
  $limit = node_limit_load($lid);
  $joins = isset($components['join']) ? implode(' ', $components['join']) : '';
  $wheres = isset($components['where']) ? 'WHERE ' . implode(' AND ', $components['where']) : '';
  return $sql . ' ' . $joins . ' ' . $wheres;
}