function apachesolr_access_apachesolr_index_document_build_node in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr_access/apachesolr_access.module \apachesolr_access_apachesolr_index_document_build_node()
- 7 apachesolr_access/apachesolr_access.module \apachesolr_access_apachesolr_index_document_build_node()
Implements hook_apachesolr_index_document_build_node()
1 call to apachesolr_access_apachesolr_index_document_build_node()
- DrupalApacheSolrNodeAccess::testIndexing in apachesolr_access/
tests/ apachesolr_access.test
File
- apachesolr_access/
apachesolr_access.module, line 6
Code
function apachesolr_access_apachesolr_index_document_build_node($document, $node, $env_id) {
static $account;
if (!isset($account)) {
// Load the anonymous user.
$account = drupal_anonymous_user();
}
if (!node_access('view', $node, $account)) {
// Get node access grants.
$query = "SELECT * FROM {node_access} WHERE (nid = 0 OR nid = %d AND grant_view = 1)";
$result = db_query($query, array(
$node->nid,
));
while ($grant = db_fetch_object($result)) {
$grant_realm = apachesolr_access_clean_realm_name($grant->realm);
$key = 'access_node_' . 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.
// We assume we'll never have an entity with the name '__all'.
$document
->setMultiValue('access__all', 0);
}
}