You are here

function pmtimetracking_node_grants in Drupal PM (Project Management) 7

Implements hook_node_grants().

File

pmtimetracking/pmtimetracking.module, line 748
Main module functions for PM Timetracking.

Code

function pmtimetracking_node_grants($account, $op) {
  if (module_exists('pmperson')) {
    _pmperson_user_load($account);
  }
  $grants = array();
  switch ($op) {
    case 'view':
      if (user_access('Project Management Timetracking: view all', $account)) {
        $grants['pmtimetracking_view_all'] = array(
          0,
        );
      }
      if (user_access('Project Management Timetracking: view own', $account)) {
        $grants['pmtimetracking_view_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management Timetracking: view of user organization', $account) and !empty($account->pmorganization_nid)) {
        $grants['pmtimetracking_view_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      break;
    case 'update':
      if (user_access('Project Management Timetracking: edit all', $account)) {
        $grants['pmtimetracking_update_all'] = array(
          0,
        );
      }
      if (user_access('Project Management Timetracking: edit own', $account)) {
        $grants['pmtimetracking_update_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management Timetracking: edit of user organization', $account) and !empty($account->pmorganization_nid)) {
        $grants['pmtimetracking_update_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      break;
    case 'delete':
      if (user_access('Project Management Timetracking: delete all', $account)) {
        $grants['pmtimetracking_delete_all'] = array(
          0,
        );
      }
      if (user_access('Project Management Timetracking: delete own', $account)) {
        $grants['pmtimetracking_delete_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management Timetracking: delete of user organization', $account) and !empty($account->pmorganization_nid)) {
        $grants['pmtimetracking_delete_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      break;
  }
  return $grants;
}