You are here

function sbp_nodes_sbp_query_modify in Search by Page 7

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

Implements Search by Page hook_sbp_query_modify().

Adds an access permission check to the search query.

File

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

Code

function sbp_nodes_sbp_query_modify($environment, $query) {
  $cond = db_and();
  if (!user_access('access content')) {

    // This user cannot access content, so don't bother with the query
    // mods, they should not see anything from this module.
    $cond
      ->where('0=1');
    return $cond;
  }

  // Join to the node table and mark it as a node access query.
  $query
    ->leftJoin('node', 'sbpn_n', 'sbpn_n.nid = sp.modid');
  $query
    ->addTag('node_access');

  // Make sure also only to allow published content.
  $cond = db_and();
  $cond
    ->condition('sbpn_n.status', 1);
  return $cond;
}