You are here

function pminvoice_node_grants in Drupal PM (Project Management) 7

Implements hook_node_grants().

File

pminvoice/pminvoice.module, line 1029
1: Hooks (help, perm, init, menu, theme, node_info) 2: Access functions 3: Load organization and project details 4: Invoice create / edit form 5: Invoice node manipulation functions 6: Admin settings 7: Views hook 8: Project Managementinvoiceitem…

Code

function pminvoice_node_grants($account, $op) {
  if (module_exists('pmperson')) {
    _pmperson_user_load($account);
  }
  $grants = array();
  switch ($op) {
    case 'view':
      if (user_access('Project Management invoice: view all', $account)) {
        $grants['pminvoice_view_all'] = array(
          0,
        );
      }
      if (user_access('Project Management invoice: view own', $account)) {
        $grants['pminvoice_view_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management invoice: view of user organization', $account) and !empty($account->pmorganization_nid)) {
        $grants['pminvoice_view_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      break;
    case 'update':
      if (user_access('Project Management invoice: edit all', $account)) {
        $grants['pminvoice_update_all'] = array(
          0,
        );
      }
      if (user_access('Project Management invoice: edit own', $account)) {
        $grants['pminvoice_update_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management invoice: edit of user organization', $account) and !empty($account->pmorganization_nid)) {
        $grants['pminvoice_update_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      break;
    case 'delete':
      if (user_access('Project Management invoice: delete all', $account)) {
        $grants['pminvoice_delete_all'] = array(
          0,
        );
      }
      if (user_access('Project Management invoice: delete own', $account)) {
        $grants['pminvoice_delete_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management invoice: delete of user organization', $account) and !empty($account->pmorganization_nid)) {
        $grants['pminvoice_delete_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      break;
  }
  return $grants;
}