You are here

function redhen_relation_access in RedHen CRM 7

Access callback for viewing and managing relations on the RedHen connection pages.

Parameters

string $op: Operation.

$entity: Entity.

$account: User account to check permission for.

$entity_type: The type of entity being checked.

Return value

bool Access grant.

1 string reference to 'redhen_relation_access'
redhen_relation_menu in modules/redhen_relation/redhen_relation.module
Implements hook_menu().

File

modules/redhen_relation/redhen_relation.module, line 248
Redhen CRM Relation Module.

Code

function redhen_relation_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
  global $user;
  $account = isset($account) ? $account : $user;
  $permissions = redhen_relation_role_get_permissions($account);
  $entity_type = $entity_type ? $entity_type : $entity
    ->entityType();
  $type = $entity_type == 'redhen_contact' ? 'contact' : 'org';
  if (entity_access($op, $entity_type, $entity) && user_access("{$op} redhen {$type} connections")) {
    return TRUE;
  }
  if (($op == 'edit' || $op == 'view') && $entity_type == 'redhen_org' && isset($permissions[$entity->org_id]) && $permissions[$entity->org_id]['add_connection'] !== 0) {
    return TRUE;
  }
  return FALSE;
}