You are here

function apachesolr_nodeaccess_apachesolr_update_index in Apache Solr Search 6

Same name and namespace in other branches
  1. 5.2 contrib/apachesolr_nodeaccess/apachesolr_nodeaccess.module \apachesolr_nodeaccess_apachesolr_update_index()
  2. 5 contrib/apachesolr_nodeaccess/apachesolr_nodeaccess.module \apachesolr_nodeaccess_apachesolr_update_index()
  3. 6.2 contrib/apachesolr_nodeaccess/apachesolr_nodeaccess.module \apachesolr_nodeaccess_apachesolr_update_index()

Implementation of apachesolr_update_index

1 call to apachesolr_nodeaccess_apachesolr_update_index()
DrupalApacheSolrNodeAccess::testIndexing in contrib/apachesolr_nodeaccess/tests/apachesolr_nodeaccess.test

File

contrib/apachesolr_nodeaccess/apachesolr_nodeaccess.module, line 6

Code

function apachesolr_nodeaccess_apachesolr_update_index(&$document, $node, $namespace) {
  static $account;
  if (!isset($account)) {

    // Load the anonymous user.
    $account = drupal_anonymous_user();
  }
  if (!node_access('view', $node, $account)) {

    // Get node access grants.
    $result = db_query('SELECT * FROM {node_access} WHERE (nid = 0 OR nid = %d) AND grant_view = 1', $node->nid);
    while ($grant = db_fetch_object($result)) {
      $key = 'nodeaccess_' . apachesolr_site_hash() . '_' . $grant->realm;
      $document
        ->setMultiValue($key, $grant->gid);
    }
  }
  else {

    // Add the generic view grant if we are not using
    // node access or the node is viewable by anonymous users.
    $document
      ->setMultiValue('nodeaccess_all', 0);
  }
}