function pmtask_node_grants in Drupal PM (Project Management) 7
Implements hook_node_grants().
File
- pmtask/
pmtask.module, line 957
Code
function pmtask_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 Task: view all', $account)) {
$grants['pmtask_view_all'] = array(
0,
);
}
if (user_access('Project Management Task: view own', $account)) {
$grants['pmtask_view_own'] = array(
$account->uid,
);
}
if (user_access('Project Management Task: view of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmtask_view_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
if (isset($account->pmperson_nid)) {
if (user_access('Project Management Task: view if assigned to task', $account)) {
$grants['pmtask_view_if_assigned'] = $assigned_nids;
}
}
break;
case 'update':
if (user_access('Project Management Task: edit all', $account)) {
$grants['pmtask_update_all'] = array(
0,
);
}
if (user_access('Project Management Task: edit own', $account)) {
$grants['pmtask_update_own'] = array(
$account->uid,
);
}
if (user_access('Project Management Task: edit of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmtask_update_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
if (isset($account->pmperson_nid)) {
if (user_access('Project Management Task: edit if assigned to task', $account)) {
$grants['pmtask_update_if_assigned'] = $assigned_nids;
}
}
break;
case 'delete':
if (user_access('Project Management Task: delete all', $account)) {
$grants['pmtask_delete_all'] = array(
0,
);
}
if (user_access('Project Management Task: delete own', $account)) {
$grants['pmtask_delete_own'] = array(
$account->uid,
);
}
if (user_access('Project Management Task: delete of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmtask_delete_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
if (isset($account->pmperson_nid)) {
if (user_access('Project Management Task: delete if assigned to task', $account)) {
$grants['pmtask_delete_if_assigned'] = $assigned_nids;
}
}
break;
}
return $grants;
}