You are here

function domain_views_get_grants in Domain Views 7

Helper function to return the node grants for this user.

Parameters

$account: The account object of the user requesting the View.

Return value

$grants An array indicating which domains the user may access.

1 call to domain_views_get_grants()
domain_views_access in ./domain_views.module
Access callback for use with domain_views_plugin_access.

File

./domain_views.module, line 146
Provides a Views filter for the Domain Access module.

Code

function domain_views_get_grants($account = NULL) {
  global $user, $_domain;
  static $grants;
  if (empty($account)) {
    $account = $user;
  }
  if (isset($grants[$account->uid])) {
    return $grants[$account->uid];
  }
  $user_grants = domain_node_grants($account, 'view');

  // Domain All gets in the way of normal grants.
  if (!empty($user_grants['domain_all'])) {
    $user_grants['domain_id'] = array(
      $_domain['domain_id'],
    );
    _domain_views_alter_grants($user_grants, $account, 'view');
  }
  $grants[$account->uid] = $user_grants;
  return $grants[$account->uid];
}