You are here

function view::access in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 includes/view.inc \view::access()
  2. 7.3 includes/view.inc \view::access()

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

File

includes/view.inc, line 1100
view.inc Provides the view object type and associated methods.

Class

view
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Code

function access($displays = NULL, $account = NULL) {

  // Noone 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;
}