You are here

function pmperson_node_grants in Drupal PM (Project Management) 7

Implements hook_node_grants().

File

pmperson/pmperson.module, line 805

Code

function pmperson_node_grants($account, $op) {
  if (!isset($account->pmorganization_nid)) {
    _pmperson_user_load($account);
  }
  $grants = array();
  switch ($op) {
    case 'view':
      if (user_access('Project Management Person: view all', $account)) {
        $grants['pmperson_view_all'] = array(
          0,
        );
      }
      if (user_access('Project Management Person: view own', $account)) {
        $grants['pmperson_view_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management Person: view of user organization', $account)) {
        $grants['pmperson_view_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      if (user_access('Project Management Person: view when linked to own user account', $account)) {
        $grants['pmperson_view_linked'] = array(
          $account->uid,
        );
      }
      break;
    case 'update':
      if (user_access('Project Management Person: edit all', $account)) {
        $grants['pmperson_update_all'] = array(
          0,
        );
      }
      if (user_access('Project Management Person: edit own', $account)) {
        $grants['pmperson_update_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management Person: edit of user organization', $account)) {
        $grants['pmperson_update_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      if (user_access('Project Management Person: edit when linked to own user account', $account)) {
        $grants['pmperson_update_linked'] = array(
          $account->uid,
        );
      }
      break;
    case 'delete':
      if (user_access('Project Management Person: delete all', $account)) {
        $grants['pmperson_delete_all'] = array(
          0,
        );
      }
      if (user_access('Project Management Person: delete own', $account)) {
        $grants['pmperson_delete_own'] = array(
          $account->uid,
        );
      }
      if (user_access('Project Management Person: delete of user organization', $account)) {
        $grants['pmperson_delete_if_user_organization'] = array(
          $account->pmorganization_nid,
        );
      }
      if (user_access('Project Management Person: delete when linked to own user account', $account)) {
        $grants['pmperson_delete_linked'] = array(
          $account->uid,
        );
      }
      break;
  }
  return $grants;
}