You are here

function views_php_check_access in Views PHP 8

Same name and namespace in other branches
  1. 6 views_php.module \views_php_check_access()
  2. 7.2 views_php.module \views_php_check_access()
  3. 7 views_php.module \views_php_check_access()

Menu access callback function; use PHP code to determine whether a user as access.

1 call to views_php_check_access()
ViewsPhp::access in src/Plugin/views/access/ViewsPhp.php
Determine if the current user has access or not.

File

./views_php.module, line 17
Allows to use PHP in views.

Code

function views_php_check_access($php_access, $view_name, $display_id, $account = NULL) {
  $user = \Drupal::currentUser();
  static $function = array();
  if (!isset($account)) {
    $account = $user;
  }
  if (!isset($function[$view_name . ':' . $display_id])) {
    $function[$view_name . ':' . $display_id] = create_function('$view_name, $display_id, $account', $php_access . ';');
  }
  ob_start();
  $access = (bool) $function[$view_name . ':' . $display_id]($view_name, $display_id, $account);
  ob_end_clean();
  return $access;
}