function pmproject_node_access_records in Drupal PM (Project Management) 7
Implements hook_node_access_records().
File
- pmproject/
pmproject.module, line 693
Code
function pmproject_node_access_records($node) {
if (empty($node->status)) {
// Lets Drupal take care of permission to unpublished nodes.
return array();
}
$type = is_string($node) ? $node : $node->type;
$grants = array();
if ($type == 'pmproject') {
// Project Management Project: view all
$grants[] = array(
'realm' => 'pmproject_view_all',
'gid' => 0,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Project: view own
$grants[] = array(
'realm' => 'pmproject_view_own',
'gid' => $node->uid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Project: view of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmproject_view_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Project: view if project manager
if (isset($node->manager_nid) && !empty($node->manager_nid)) {
$grants[] = array(
'realm' => 'pmproject_view_if_manager',
'gid' => $node->manager_nid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Project: view if assigned to project
if (isset($node->assigned_nid) && !empty($node->assigned_nid)) {
$grants[] = array(
'realm' => 'pmproject_view_if_assigned',
'gid' => $node->assigned_nid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Project: edit all
$grants[] = array(
'realm' => 'pmproject_update_all',
'gid' => 0,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Project: edit own
$grants[] = array(
'realm' => 'pmproject_update_own',
'gid' => $node->uid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Project: edit of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmproject_update_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Project: edit if project manager
if (isset($node->manager_nid) && !empty($node->manager_nid)) {
$grants[] = array(
'realm' => 'pmproject_update_if_manager',
'gid' => $node->manager_nid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Project: edit if assigned to project
if (isset($node->assigned_nid) && !empty($node->assigned_nid)) {
$grants[] = array(
'realm' => 'pmproject_update_if_assigned',
'gid' => $node->assigned_nid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Project: delete all
$grants[] = array(
'realm' => 'pmproject_delete_all',
'gid' => 0,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
// Project Management Project: delete own
$grants[] = array(
'realm' => 'pmproject_delete_own',
'gid' => $node->uid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
// Project Management Project: delete of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmproject_delete_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
}
// Project Management Project: delete if project manager
if (isset($node->manager_nid) && !empty($node->manager_nid)) {
$grants[] = array(
'realm' => 'pmproject_delete_if_manager',
'gid' => $node->manager_nid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
}
// Project Management Project: delete if assigned to project
if (isset($node->assigned_nid) && !empty($node->assigned_nid)) {
$grants[] = array(
'realm' => 'pmproject_delete_if_assigned',
'gid' => $node->assigned_nid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
}
}
return $grants;
}