function pmperson_node_access_records in Drupal PM (Project Management) 7
Implements hook_node_access_records().
File
- pmperson/
pmperson.module, line 669
Code
function pmperson_node_access_records($node) {
if (empty($node->status)) {
// Lets Drupal take care of permission on unpublished nodes.
return array();
}
$type = is_string($node) ? $node : $node->type;
$grants = array();
if ($type == 'pmperson') {
// Project Management Person: view all
$grants[] = array(
'realm' => 'pmperson_view_all',
'gid' => 0,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Person: view own
$grants[] = array(
'realm' => 'pmperson_view_own',
'gid' => $node->uid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Person: view of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmperson_view_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Person: view when linked to own user account
if (isset($node->user_uid) && !empty($node->user_uid)) {
$grants[] = array(
'realm' => 'pmperson_view_linked',
'gid' => $node->user_uid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Person: edit all
$grants[] = array(
'realm' => 'pmperson_update_all',
'gid' => 0,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Person: edit own
$grants[] = array(
'realm' => 'pmperson_update_own',
'gid' => $node->uid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Person: edit of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmperson_update_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Person: edit when linked to own user account
if (isset($node->user_uid) && !empty($node->user_uid)) {
$grants[] = array(
'realm' => 'pmperson_update_linked',
'gid' => $node->user_uid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Person: delete all
$grants[] = array(
'realm' => 'pmperson_delete_all',
'gid' => 0,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
// Project Management Person: delete own
$grants[] = array(
'realm' => 'pmperson_delete_own',
'gid' => $node->uid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
// Project Management Person: delete of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmperson_delete_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
}
// Project Management Person: delete when linked to own user account
if (isset($node->user_uid) && !empty($node->user_uid)) {
$grants[] = array(
'realm' => 'pmperson_delete_linked',
'gid' => $node->user_uid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
}
}
return $grants;
}