1 view.inc view::access($displays = NULL, $account = NULL)

Determine if the given user has access to the view. Note that this sets the display handler if it hasn't been.

File

core/modules/views/includes/view.inc, line 1518
Provides the view object type and associated methods.

Class

view

Code

function access($displays = NULL, $account = NULL) {
  // No one should have access to disabled views.
  if (!empty($this->disabled)) {
    return FALSE;
  }

  if (!isset($this->current_display)) {
    $this->init_display();
  }

  if (!$account) {
    $account = $GLOBALS['user'];
  }

  // We can't use choose_display() here because that function
  // calls this one.
  $displays = (array) $displays;
  foreach ($displays as $display_id) {
    if (!empty($this->display[$display_id]->handler)) {
      if ($this->display[$display_id]->handler->access($account)) {
        return TRUE;
      }
    }
  }

  return FALSE;
}