You are here

function finder_node_finder_find in Finder 7

Same name and namespace in other branches
  1. 6 modules/finder_node/finder_node.module \finder_node_finder_find()

Implements hook_finder_find().

See also

hook_finder_find()

File

modules/finder_node/finder_node.module, line 148
The finder node module.

Code

function finder_node_finder_find($finder, $finder_element_id, $keywords, $mode, $match, $pager) {
  $prequery = array();
  foreach ($keywords as $feid => $keyword_array) {
    $element =& finder_element($finder, $feid);
    $types[$feid] =& $element->settings['choices']['node_types'];
    $published[$feid] =& $element->settings['choices']['published'];

    // restrict by types
    unset($types[$feid]['']);
    if (!empty($types[$feid])) {
      if ($feid == $finder_element_id) {
        $prequery['conditions'][] = (object) array(
          'field' => 'node.type',
          'value' => array_keys($types[$feid]),
          'match' => 'IN',
        );
      }
      else {
        $prequery['conditions']['restrictions'][$feid][] = (object) array(
          'field' => 'node.type',
          'value' => array_keys($types[$feid]),
          'match' => 'IN',
        );
      }
    }
  }

  // restrict to published nodes if required
  if (in_array(1, $published)) {
    $prequery['conditions'][] = array(
      'node.status',
      1,
    );
  }
  $join_ons = array(
    'node_revision' => array(
      'node_revision' => 'node_revision.vid = node.vid',
    ),
    'node_type' => array(
      'node_type' => 'node_type.type = node.type',
    ),
    'users' => array(
      'users' => 'users.uid = node.uid',
    ),
  );
  $base_table = 'node';
  $base_field = 'nid';
  $result = finder_find_query($prequery, $finder, $finder_element_id, $keywords, $mode, $match, $pager, $join_ons, $base_table, $base_field);
  return $result;
}