You are here

function domain_entity_get_user_available_domains in Domain Access Entity 7

Same name and namespace in other branches
  1. 8 domain_entity.module \domain_entity_get_user_available_domains()

Return a list of domain id's, accessible by the current user.

Parameters

stdClass $user: Drupal user account.

Return value

array List of domain id's.

6 calls to domain_entity_get_user_available_domains()
domain_entity_entity_access_callback in ./domain_entity.module
Entity access callback.
domain_entity_query_alter in ./domain_entity.module
Implements hook_query_alter().
domain_entity_views_handler_filter_domain_domain_id::get_value_options in includes/domain_entity_views_handler_filter_domain_domain_id.inc
Override views_handler_filter_in_operator::get_value_options().
domain_entity_views_handler_filter_domain_domain_id::value_form in includes/domain_entity_views_handler_filter_domain_domain_id.inc
Override views_handler_filter_in_operator::value_form().
domain_entity_views_handler_filter_domain_domain_source::get_value_options in domain_entity_source/includes/domain_entity_views_handler_filter_domain_domain_source.inc
Override views_handler_filter_in_operator::get_value_options().

... See full list

File

./domain_entity.module, line 175
Defines field (e.g. domain_entity) for entities, and access query alter.

Code

function domain_entity_get_user_available_domains($account = NULL) {
  if (!is_object($account)) {
    global $user;
    $account = $user;
  }

  // Get the current user list of granted domain id:
  // the current domain id OR for middle-office editors:
  // the list of assigned domain(s) id.
  $current_domain = domain_get_domain();
  $accessible_domain_ids = array(
    $current_domain['domain_id'],
  );

  // Middle office editors with permission see in administration,
  // entity from her lists of assigned domains.
  if (path_is_admin(current_path()) && user_access('access entities affiliate on assigned domains', $account)) {
    $user_domain = domain_get_user_domains($account);
    $accessible_domain_ids = !empty($user_domain) ? $user_domain : $accessible_domain_ids;
  }
  return $accessible_domain_ids;
}