function domain_node_grants in Domain Access 7.2
Same name and namespace in other branches
- 5 domain.module \domain_node_grants()
- 6.2 domain.module \domain_node_grants()
- 7.3 domain.module \domain_node_grants()
Implements hook_node_grants.
Informs the node access system what permissions the user has. By design all users are in the realm defined by the currently active domain_id.
In Drupal 7, you may modify these grants in your own module, through the function hook_node_grants_alter().
@link http://api.drupal.org/api/function/hook_node_grants_alter/7
See also
domain_strict_node_grants_alter()
File
- ./
domain.module, line 1649 - Core module functions for the Domain Access suite.
Code
function domain_node_grants($account, $op) {
$_domain = domain_get_domain();
$grants = array();
// By design, all users can see content sent to all affiliates,
// but the $_domain['site_grant'] can be set to FALSE.
if ($op == 'view') {
if (!empty($_domain['site_grant'])) {
$grants['domain_site'][] = 0;
}
// Grant based on active domain.
$grants['domain_id'][] = $_domain['domain_id'];
// In special cases, we grant the ability to view all nodes. That is,
// we simply get out of the way of other node_access rules.
// We do this with the universal 'domain_all' grant.
if (domain_grant_all()) {
$grants = array(
'domain_all' => array(
0,
),
);
}
}
else {
// The $account may not have domain information loaded, so get it.
$domains = domain_get_user_domains($account);
$perm = 'delete domain content';
if ($op == 'update') {
$perm = 'edit domain content';
}
if (user_access($perm, $account)) {
if (!empty($domains)) {
foreach ($domains as $id) {
if (abs($id) > 0) {
if ($id > 0) {
$grants['domain_id'][] = $id;
}
else {
$grants['domain_id'][] = 0;
}
}
}
}
}
}
return $grants;
}