function pmexpense_node_grants in Drupal PM (Project Management) 7
Implements hook_node_grants().
File
- pmexpense/
pmexpense.module, line 837 - Hook implementations and main functions for PM Expense.
Code
function pmexpense_node_grants($account, $op) {
if (module_exists('pmperson')) {
_pmperson_user_load($account);
}
$grants = array();
switch ($op) {
case 'view':
if (user_access('Project Management expense: view all', $account)) {
$grants['pmexpense_view_all'] = array(
0,
);
}
if (user_access('Project Management expense: view own', $account)) {
$grants['pmexpense_view_own'] = array(
$account->uid,
);
}
if (user_access('Project Management expense: view of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmexpense_view_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
break;
case 'update':
if (user_access('Project Management expense: edit all', $account)) {
$grants['pmexpense_update_all'] = array(
0,
);
}
if (user_access('Project Management expense: edit own', $account)) {
$grants['pmexpense_update_own'] = array(
$account->uid,
);
}
if (user_access('Project Management expense: edit of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmexpense_update_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
break;
case 'delete':
if (user_access('Project Management expense: delete all', $account)) {
$grants['pmexpense_delete_all'] = array(
0,
);
}
if (user_access('Project Management expense: delete own', $account)) {
$grants['pmexpense_delete_own'] = array(
$account->uid,
);
}
if (user_access('Project Management expense: delete of user organization', $account) and !empty($account->pmorganization_nid)) {
$grants['pmexpense_delete_if_user_organization'] = array(
$account->pmorganization_nid,
);
}
break;
}
return $grants;
}