You are here

function sbp_nodes_sbp_query_modify in Search by Page 6

Same name and namespace in other branches
  1. 7 sbp_nodes.module \sbp_nodes_sbp_query_modify()

Implementation of Search by Page hook_sbp_query_modify().

Adds an access permission check to the search query.

File

./sbp_nodes.module, line 87
Module file for Search by Page Nodes, a sub-module for Search by Page.

Code

function sbp_nodes_sbp_query_modify($environment) {

  // Get node access permissions from db_rewrite_sql()
  $stuff = search_by_page_unique_rewrite('sbpn_');

  // Form join/where clauses, only allowing published nodes, plus
  // node access stuff
  $join = '';
  if ($stuff[0]) {
    $join .= 'LEFT JOIN ({node} sbpn_n ' . $stuff[0] . ')';
  }
  else {

    // PostgreSQL doesn't support simple joins with ().
    $join .= 'LEFT JOIN {node} sbpn_n';
  }
  $join .= ' ON sbpn_n.nid = sp.modid';
  $where = 'sbpn_n.status = 1';
  if ($stuff[1]) {
    $where .= ' AND ' . $stuff[1];
  }
  return array(
    'join' => $join,
    'where' => $where,
    'arguments' => array(),
  );
}