• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

plugins/views_plugin_access_perm.inc

00001 <?php
00002 
00006 class views_plugin_access_perm extends views_plugin_access {
00007   function access($account) {
00008     return views_check_perm($this->options['perm'], $account);
00009   }
00010 
00011   function get_access_callback() {
00012     return array('views_check_perm', array($this->options['perm']));
00013   }
00014 
00015   function summary_title() {
00016     $permissions = module_invoke_all('permission');
00017     if (isset($permissions[$this->options['perm']])) {
00018       return $permissions[$this->options['perm']]['title'];
00019     }
00020 
00021     return t($this->options['perm']);
00022   }
00023 
00024 
00025   function option_definition() {
00026     $options = parent::option_definition();
00027     $options['perm'] = array('default' => 'access content');
00028 
00029     return $options;
00030   }
00031 
00032   function options_form(&$form, &$form_state) {
00033     parent::options_form($form, $form_state);
00034     $perms = array();
00035     $module_info = system_get_info('module');
00036 
00037     // Get list of permissions
00038     foreach (module_implements('permission') as $module) {
00039       $permissions = module_invoke($module, 'permission');
00040       foreach ($permissions as $name => $perm) {
00041         $perms[$module_info[$module]['name']][$name] = strip_tags($perm['title']);
00042       }
00043     }
00044 
00045     asort($perms);
00046 
00047     $form['perm'] = array(
00048       '#type' => 'select',
00049       '#options' => $perms,
00050       '#title' => t('Permission'),
00051       '#default_value' => $this->options['perm'],
00052       '#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.'),
00053     );
00054   }
00055 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1