function pmteam_node_grants in Drupal PM (Project Management) 7
Implements hook_node_grants().
File
- pmteam/
pmteam.module, line 556 - Functionality for the Project Management Team module Organized into the following sections:
Code
function pmteam_node_grants($account, $op) {
$assigned_nids = array();
if (module_exists('pmperson')) {
_pmperson_user_load($account);
if (!empty($account->pmteam) and is_array($account->pmteam)) {
$assigned_nids = $account->pmteam;
}
}
$grants = array();
switch ($op) {
case 'view':
if (user_access('Project Management Team: view all', $account)) {
$grants['pmteam_view_all'] = array(
0,
);
}
if (user_access('Project Management Team: view own', $account)) {
$grants['pmteam_view_own'] = array(
$account->uid,
);
}
if (!empty($assigned_nids) and user_access('Project Management Team: view belonged', $account)) {
$grants['pmteam_view_if_belonged'] = $assigned_nids;
}
break;
case 'update':
if (user_access('Project Management Team: edit all', $account)) {
$grants['pmteam_update_all'] = array(
0,
);
}
if (user_access('Project Management Team: edit own', $account)) {
$grants['pmteam_update_own'] = array(
$account->uid,
);
}
if (!empty($assigned_nids) and user_access('Project Management Team: edit belonged', $account)) {
$grants['pmteam_update_if_belonged'] = $assigned_nids;
}
break;
case 'delete':
if (user_access('Project Management Team: delete all', $account)) {
$grants['pmteam_delete_all'] = array(
0,
);
}
if (user_access('Project Management Team: delete own', $account)) {
$grants['pmteam_delete_own'] = array(
$account->uid,
);
}
if (!empty($assigned_nids) and user_access('Project Management Team: delete belonged', $account)) {
$grants['pmteam_delete_if_belonged'] = $assigned_nids;
}
break;
}
return $grants;
}