function views_access

Determine if the logged in user has access to a view.

This function should only be called from a menu hook or some other embedded source. Each argument is the result of a call to views_plugin_access::get_access_callback() which is then used to determine if that display is accessible. If *any* argument is accessible, then the view is accessible.

2 calls to views_access()
AccessTest::testDynamicAccessPlugin in drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php
Tests dynamic access plugin.
AccessTest::testStaticAccessPlugin in drupal/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php
Tests static access check.
1 string reference to 'views_access'
PathPluginBase::executeHookMenu in drupal/core/modules/views/lib/Drupal/views/Plugin/views/display/PathPluginBase.php
Add this display's path information to Drupal's menu system.

File

drupal/core/modules/views/views.module, line 990
Primarily Drupal hooks and global API functions to manipulate views.

Code

function views_access() {
  $args = func_get_args();
  foreach ($args as $arg) {
    if ($arg === TRUE) {
      return TRUE;
    }
    if (!is_array($arg)) {
      continue;
    }
    list($callback, $arguments) = $arg;
    $arguments = $arguments ? $arguments : array();

    // Bring dynamic arguments to the access callback.
    foreach ($arguments as $key => $value) {
      if (is_int($value) && isset($args[$value])) {
        $arguments[$key] = $args[$value];
      }
    }
    if (function_exists($callback) && call_user_func_array($callback, $arguments)) {
      return TRUE;
    }
  }
  return FALSE;
}