function pmticket_node_access_records in Drupal PM (Project Management) 7
Implements hook_node_access_records().
File
- pmticket/
pmticket.module, line 763 - 1: Hooks 2: Access functions
Code
function pmticket_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 == 'pmticket') {
// Project Management Ticket: view all
$grants[] = array(
'realm' => 'pmticket_view_all',
'gid' => 0,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Ticket: view own
$grants[] = array(
'realm' => 'pmticket_view_own',
'gid' => $node->uid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Ticket: view of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmticket_view_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Ticket: view if assigned to ticket
if (isset($node->assigned_nid) && !empty($node->assigned_nid)) {
$grants[] = array(
'realm' => 'pmticket_view_if_assigned',
'gid' => $node->assigned_nid,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Ticket: edit all
$grants[] = array(
'realm' => 'pmticket_update_all',
'gid' => 0,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Ticket: edit own
$grants[] = array(
'realm' => 'pmticket_update_own',
'gid' => $node->uid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
// Project Management Ticket: edit of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmticket_update_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Ticket: edit if assigned to ticket
if (isset($node->assigned_nid) && !empty($node->assigned_nid)) {
$grants[] = array(
'realm' => 'pmticket_update_if_assigned',
'gid' => $node->assigned_nid,
'grant_view' => 0,
'grant_update' => 1,
'grant_delete' => 0,
'priority' => 0,
);
}
// Project Management Ticket: delete all
$grants[] = array(
'realm' => 'pmticket_delete_all',
'gid' => 0,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
// Project Management Ticket: delete own
$grants[] = array(
'realm' => 'pmticket_delete_own',
'gid' => $node->uid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
// Project Management Ticket: delete of user organization
if (isset($node->organization_nid) && !empty($node->organization_nid)) {
$grants[] = array(
'realm' => 'pmticket_delete_if_user_organization',
'gid' => $node->organization_nid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
}
// Project Management Ticket: delete if assigned to ticket
if (isset($node->assigned_nid) && !empty($node->assigned_nid)) {
$grants[] = array(
'realm' => 'pmticket_delete_if_assigned',
'gid' => $node->assigned_nid,
'grant_view' => 0,
'grant_update' => 0,
'grant_delete' => 1,
'priority' => 0,
);
}
}
return $grants;
}