function og_access_node_access_records in Organic groups 5.3
Same name and namespace in other branches
- 5.8 og_access.module \og_access_node_access_records()
- 5 og_access.module \og_access_node_access_records()
- 5.7 og_access.module \og_access_node_access_records()
- 6.2 modules/og_access/og_access.module \og_access_node_access_records()
- 6 modules/og_access/og_access.module \og_access_node_access_records()
- 7.2 og_access/og_access.module \og_access_node_access_records()
- 7 og_access/og_access.module \og_access_node_access_records()
Implementation of hook_node_access_records.
File
- ./
og_access.module, line 200
Code
function og_access_node_access_records($node) {
// don't write records if the node type is omitted or node is a group
if (og_is_omitted_type($node->type)) {
return;
}
if (og_is_group_type($node->type)) {
// This grant allows group admins to manage their group.
$grants[] = array(
'realm' => 'og_admin',
'gid' => $node->nid,
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
);
// If the group is not marked private, let everyone view the group homepage.
if (!$node->og_private) {
$grants[] = array(
'realm' => 'og_public',
'gid' => 0,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
);
}
else {
$grants[] = array(
'realm' => 'og_subscriber',
'gid' => $node->nid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
);
}
}
elseif (is_array($node->og_groups)) {
// Applies to non group nodes.
if ($node->og_public) {
$grants[] = array(
'realm' => 'og_public',
'gid' => 0,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
);
}
foreach ($node->og_groups as $gid) {
// Group administrators get all operations.
$grants[] = array(
'realm' => 'og_admin',
'gid' => $gid,
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
);
// Normal subscribers just get update operation if node type is a wiki type.
$is_wiki = og_is_wiki_type($node->type);
$grants[] = array(
'realm' => 'og_subscriber',
'gid' => $gid,
'grant_view' => 1,
'grant_update' => $is_wiki,
'grant_delete' => 0,
);
}
}
return $grants;
}