You are here

function quotes_block_join_sql in Quotes 6

Same name and namespace in other branches
  1. 5 quotes.module \quotes_block_join_sql()
  2. 7 quotes.module \quotes_block_join_sql()

Returns the SQL join text necessary for the provided filter criteria.

Parameters

$filters: The array specifying filter criteria using the keys nid_filter, aid_filter, rid_filter, uid_filter, and tid_filter.

$aliases: The array specifying the aliases to be used for the tables that may be joined based on the provided filter criteria. Keys are the table names node, users_roles, users, and term_node.

Return value

A string containing the SQL join text necessary for the provided criteria.

1 call to quotes_block_join_sql()
quotes_get_quote in ./quotes.module
Returns the node ID for either a random quote or the most recent quote based on the provided filter criteria.

File

./quotes.module, line 1347
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_block_join_sql($filters = array()) {
  $aliases = array(
    'node' => 'n',
    'users_roles' => 'r',
    'users' => 'u',
    'term_node' => 'tn',
  );
  $join = '';
  if ($filters['rid_filter'] && $filters['rid_filter'] != 'none') {
    $a = $aliases['users_roles'];
    $join .= " LEFT JOIN {users_roles} {$a} USING(uid) ";
  }
  if ($filters['tid_filter'] && $filters['tid_filter'] != 'none') {
    $atn = $aliases['term_node'];
    $an = $aliases['node'];
    $join .= " INNER JOIN {term_node} {$atn} ON {$atn}.nid = {$an}.nid ";
  }
  return $join;
}