home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (views_plugin_access_perm.inc)

This example Drupal source code file (views_plugin_access_perm.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

access, account, array, as, foreach, function, module, options, permissions, perms, php, return, users, with

The views_plugin_access_perm.inc Drupal example source code

// $Id: views_plugin_access_perm.inc,v 2010/03/10 21:03:19 merlinofchaos Exp $

 * Access plugin that provides permission-based access control.
class views_plugin_access_perm extends views_plugin_access {
  function access($account) {
    return views_check_perm($this->options['perm'], $account);

  function get_access_callback() {
    return array('views_check_perm', array($this->options['perm']));

  function summary_title() {
    return t($this->options['perm']);

  function option_definition() {
    $options = parent::option_definition();
    $options['perm'] = array('default' => 'access content');

    return $options;

  function options_form(&$form, &$form_state) {
    $perms = array();
    // Get list of permissions
    foreach (module_implements('permission') as $module) {
      $permissions = module_invoke($module, 'permission');
      foreach ($permissions as $name => $perm) {
        $perms[$module][$name] = $perm['title'];
    $form['perm'] = array(
      '#type' => 'select',
      '#options' => $perms,
      '#title' => t('Permission'),
      '#default_value' => $this->options['perm'],
      '#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'),

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal views_plugin_access_perm.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.