anode_access_test.module in Apache Solr Search 6.3
Dummy module implementing node access related hooks to test API interaction with the Node module. This module restricts view permission to those with a special 'node test view' permission.
File
apachesolr_access/tests/anode_access_test.moduleView source
<?php
/**
* @file
* Dummy module implementing node access related hooks to test API interaction
* with the Node module. This module restricts view permission to those with
* a special 'node test view' permission.
*/
/**
* Implements hook_node_grants().
*/
function anode_access_test_node_grants($account, $op) {
$grants = array();
// First grant a grant to the author for own content.
$grants['node_access_test_author'] = array(
$account->uid,
);
if ($op == 'view' && user_access('node test view', $account)) {
$grants['node_access_test'] = array(
8888,
8889,
);
}
if ($op == 'view' && $account->uid == variable_get('node_test_node_access_all_uid', 0)) {
$grants['node_access_all'] = array(
0,
);
}
return $grants;
}
/**
* Implements hook_node_access_records().
*/
function anode_access_test_node_access_records($node) {
$grants = array();
// For NodeAccessBaseTableTestCase, only set records for private nodes.
if (!variable_get('node_access_test_private', NULL) || $node->private) {
$grants[] = array(
'realm' => 'node_access_test',
'gid' => 8888,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
$grants[] = array(
'realm' => 'node_access_test',
'gid' => 8889,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// For the author realm, the GID is equivalent to a UID, which
// means there are many many groups of just 1 user.
$grants[] = array(
'realm' => 'node_access_test_author',
'gid' => $node->uid,
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 0,
);
}
return $grants;
}
/**
* Implements hook_perm().
*
* Sets up permissions for this module.
*/
function anode_access_test_perm() {
return array(
'node test view',
);
}
Functions
Name![]() |
Description |
---|---|
anode_access_test_node_access_records | Implements hook_node_access_records(). |
anode_access_test_node_grants | Implements hook_node_grants(). |
anode_access_test_perm | Implements hook_perm(). |