function pmticket_node_grants in Drupal PM (Project Management) 7
Implements hook_node_grants().
File
- pmticket/
pmticket.module, line 898 - 1: Hooks 2: Access functions
Code
function pmticket_node_grants($account, $op) {
if (module_exists('pmperson')) {
_pmperson_user_load($account);
if (!empty($account->pmteam) and is_array($account->pmteam)) {
$assigned_nids = $account->pmteam;
}
if (isset($account->pmperson_nid) and !empty($account->pmperson_nid)) {
$assigned_nids[] = $account->pmperson_nid;
}
}
$grants = array();
switch ($op) {
case 'view':
if (user_access('Project Management Ticket: view all', $account)) {
$grants['pmticket_view_all'] = array(
0,
);
}
if (user_access('Project Management Ticket: view own', $account)) {
$grants['pmticket_view_own'] = array(
$account->uid,
);
}
if (user_access('Project Management Ticket: view of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmticket_view_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
if (isset($account->pmperson_nid)) {
if (user_access('Project Management Ticket: view if assigned to ticket', $account)) {
$grants['pmticket_view_if_assigned'] = $assigned_nids;
}
}
break;
case 'update':
if (user_access('Project Management Ticket: edit all', $account)) {
$grants['pmticket_update_all'] = array(
0,
);
}
if (user_access('Project Management Ticket: edit own', $account)) {
$grants['pmticket_update_own'] = array(
$account->uid,
);
}
if (user_access('Project Management Ticket: edit of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmticket_update_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
if (isset($account->pmperson_nid)) {
if (user_access('Project Management Ticket: edit if assigned to ticket', $account)) {
$grants['pmticket_update_if_assigned'] = $assigned_nids;
}
}
break;
case 'delete':
if (user_access('Project Management Ticket: delete all', $account)) {
$grants['pmticket_delete_all'] = array(
0,
);
}
if (user_access('Project Management Ticket: delete own', $account)) {
$grants['pmticket_delete_own'] = array(
$account->uid,
);
}
if (user_access('Project Management Ticket: delete of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmticket_delete_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
if (isset($account->pmperson_nid)) {
if (user_access('Project Management Ticket: delete if assigned to ticket', $account)) {
$grants['pmticket_delete_if_assigned'] = $assigned_nids;
}
}
break;
}
return $grants;
}