You are here

function pm_permission_grants_list in Drupal PM (Project Management) 7.3

Same name and namespace in other branches
  1. 8 includes/pm.permission.inc \pm_permission_grants_list()

Helper function for pm_permission_node_grants.

1 call to pm_permission_grants_list()
pm_node_grants in ./pm.module
Implements hook_node_grants().

File

includes/pm.permission.inc, line 615
Main module file for the pm_permission module.

Code

function pm_permission_grants_list($account, $op, $type) {
  $grants = array();
  if (user_access("PM permission {$type}: {$op} all", $account)) {
    $grants["pm_permission_{$type}_{$op}_all"] = array(
      0,
    );
  }
  if (user_access("PM permission {$type}: {$op} own", $account)) {
    $grants["pm_permission_{$type}_{$op}_own"] = array(
      $account->uid,
    );
  }
  if (module_exists('pmorganization')) {
    if (_pm_permission_get_field_name($type, 'parent') or $type == 'pmorganization') {
      $field_name = variable_get("pm_permission_field_org_member_reference", '');
      $pmorganization_nids = _pm_permission_get_entity_id_referenced_to_user('node', 'pmorganization', $field_name, $account->uid);
      $belonged = 'Organization';
      if (user_access("PM permission {$type}: {$op} own {$belonged}", $account) and !empty($pmorganization_nids)) {
        $grants["pm_permission_{$type}_{$op}_belonged_{$belonged}"] = $pmorganization_nids;
      }
    }
  }
  if (module_exists('pmproject')) {
    if (_pm_permission_get_field_name($type, 'pm')) {
      $assigned = 'Project Manager';
      if (user_access("PM permission {$type}: {$op} if {$assigned}", $account)) {
        $grants["pm_permission_{$type}_{$op}_assigned_{$assigned}"] = array(
          $account->uid,
        );
      }
    }
  }
  if (_pm_permission_get_field_name($type, 'assigned')) {
    $assigned = 'Assigned';
    if (user_access("PM permission {$type}: {$op} if {$assigned}", $account)) {
      $grants["pm_permission_{$type}_{$op}_assigned_{$assigned}"] = array(
        $account->uid,
      );
    }
  }
  return $grants;
}