You are here

function views_check_perm in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 8.3 views.module \views_check_perm()
  2. 6.3 views.module \views_check_perm()
  3. 6.2 views.module \views_check_perm()

Access callback for the views_plugin_access_perm access plugin.

Determine if the specified user has access to a view on the basis of permissions. If the $account argument is omitted, the current user is used.

1 call to views_check_perm()
views_plugin_access_perm::access in plugins/views_plugin_access_perm.inc
Determine if the current user has access or not.
1 string reference to 'views_check_perm'
views_plugin_access_perm::get_access_callback in plugins/views_plugin_access_perm.inc
Determine the access callback and arguments.

File

./views.module, line 1146
Primarily Drupal hooks and global API functions to manipulate views.

Code

function views_check_perm($perms, $account = NULL) {

  // Backward compatibility to ensure also a single permission string is
  // properly processed.
  $perms = is_array($perms) ? $perms : array(
    $perms,
  );
  if (user_access('access all views', $account)) {
    return TRUE;
  }

  // Perms are handled as OR, as soon one permission allows access TRUE is
  // returned.
  foreach ($perms as $perm) {
    if (user_access($perm, $account)) {
      return TRUE;
    }
  }
  return FALSE;
}