Contributions API

Calling all Drupal developers!

Help us get this on the first page of Digg. DIGG NOW!

Modules in 6

views_access

Definition

views_access()
contributions/views/views.module, line 406

Description

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.

Code

<?php
function views_access() {
  if (user_access('access all views')) {
    return TRUE;
  }

  $args = func_get_args();
  foreach ($args as $arg) {
    if ($arg === TRUE) {
      return TRUE;
    }

    if (!is_array($arg)) {
      continue;
    }

    list($callback, $arguments) = $arg;
    if (function_exists($callback) && call_user_func_array($callback, $arguments)) {
      return TRUE;
    }
  }

  return FALSE;
}
?>