/[drupal]/contributions/modules/views/plugins/views_plugin_access_perm.inc
ViewVC logotype

Contents of /contributions/modules/views/plugins/views_plugin_access_perm.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Wed Jan 7 23:31:13 2009 UTC (10 months, 2 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, DRUPAL-6--2-6, DRUPAL-6--2-5, DRUPAL-6--2-4, DRUPAL-6--2-3, DRUPAL-6--3-0-ALPHA1, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--3, DRUPAL-7--3
Changes since 1.2: +2 -2 lines
File MIME type: text/x-php
#343047 by alienbrain: Allow all handlers to participate in view validation.
1 <?php
2 // $Id: views_plugin_access_perm.inc,v 1.2 2008/09/17 22:26:55 merlinofchaos Exp $
3
4 /**
5 * Access plugin that provides permission-based access control.
6 */
7 class views_plugin_access_perm extends views_plugin_access {
8 function access($account) {
9 return user_access($this->options['perm'], $account);
10 }
11
12 function get_access_callback() {
13 return array('user_access', array($this->options['perm']));
14 }
15
16 function summary_title() {
17 return t($this->options['perm']);
18 }
19
20 function option_defaults(&$options) {
21 $options['perm'] = 'access content';
22 }
23
24 function options_form(&$form, &$form_state) {
25 $perms = array();
26 // Get list of permissions
27 foreach (module_list(FALSE, FALSE, TRUE) as $module) {
28 if ($permissions = module_invoke($module, 'perm')) {
29 $perms[$module] = drupal_map_assoc($permissions);
30 }
31 }
32 $form['perm'] = array(
33 '#type' => 'select',
34 '#options' => $perms,
35 '#title' => t('Permission'),
36 '#default_value' => $this->options['perm'],
37 '#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.'),
38 );
39 }
40 }

  ViewVC Help
Powered by ViewVC 1.1.2