function oa_clone_clone_access_alter in Open Atrium Clone 7.2
Implements hook_clone_access().
File
- ./
oa_clone.module, line 222
Code
function oa_clone_clone_access_alter(&$access, $node) {
global $user;
if ($user->uid == 0) {
$access = FALSE;
return;
}
// We only affect the access of group content types, but we completely take
// over the access for those nodes.
if (og_is_group_content_type('node', $node->type) && clone_is_permitted($node->type)) {
// Bypass the access check and simply allow the user to clone this node.
if (!empty($node->oa_clone_bypass_access_check)) {
$access = TRUE;
return;
}
// Make sure that this user has permission to view this node and create
// content of the same type.
if (!node_access('view', $node) || !node_access('create', $node->type)) {
$access = FALSE;
return;
}
$own_node = $user->uid && $node->uid == $user->uid;
// Next, we check the global Drupal permissions.
if (user_access('clone node in any group') || $own_node && user_access('clone own nodes in any group')) {
$access = TRUE;
return;
}
// Finally, we check the group permissions.
$gid = oa_core_get_group_from_node($node->nid);
$access = og_user_access('node', $gid, 'clone node') || $own_node && og_user_access('node', $gid, 'clone own nodes');
}
}