You are here

function _prev_next_node_types_sql in Previous/Next API 7.2

Same name and namespace in other branches
  1. 6 prev_next.module \_prev_next_node_types_sql()
  2. 7 prev_next.module \_prev_next_node_types_sql()

Helper function to return a SQL clause for types to be indexed

Parameters

string $node_type: The indexing criteria for the type of node to query for.

Return value

string

3 calls to _prev_next_node_types_sql()
prev_next_admin in ./prev_next.admin.inc
Menu callback argument. Creates the prev_next administration form.
prev_next_cron in ./prev_next.module
Implements hook_cron().
_prev_next_add in ./prev_next.module
Create or update the prev_next records.

File

./prev_next.module, line 447
The previous next module indexes the previous and next nodes based upon user-selectable criteria and stores this index in the database for faster retrieval later.

Code

function _prev_next_node_types_sql($node_type = '') {
  $same_type = variable_get(PREV_NEXT_NODE_TYPE . $node_type . '_same_type', 0);
  if (!$same_type) {
    $types = _prev_next_node_types();
    $quoted_types = array();
    foreach (_prev_next_node_types() as $type) {
      $quoted_types[] = "'" . $type . "'";
    }
    $cond = '';
    if (count($types)) {
      $cond = ' AND type IN (' . implode(',', $quoted_types) . ')';
    }
  }
  else {
    $cond = " AND type = '" . $node_type . "'";
  }
  return $cond;
}