| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: views_plugin_access_role.inc,v 1.2.4.1 2010/03/10 21:03:25 merlinofchaos Exp $ 3 4 /** 5 * Access plugin that provides role-based access control. 6 */ 7 class views_plugin_access_role extends views_plugin_access { 8 function access($account) { 9 return views_check_roles(array_filter($this->options['role']), $account); 10 } 11 12 function get_access_callback() { 13 return array('views_check_roles', array(array_filter($this->options['role']))); 14 } 15 16 function summary_title() { 17 $count = count($this->options['role']); 18 if ($count < 1) { 19 return t('No role(s) selected'); 20 } 21 else if ($count > 1) { 22 return t('Multiple roles'); 23 } 24 else { 25 $rids = views_ui_get_roles(); 26 $rid = array_shift($this->options['role']); 27 return $rids[$rid]; 28 } 29 } 30 31 function option_defaults(&$options) { 32 $options['role'] = array(); 33 } 34 35 function options_form(&$form, &$form_state) { 36 $form['role'] = array( 37 '#type' => 'checkboxes', 38 '#title' => t('Role'), 39 '#default_value' => $this->options['role'], 40 '#options' => views_ui_get_roles(), 41 '#description' => t('Only the checked roles will be able to access this display. Note that users with "access all views" can see any view, regardless of role.'), 42 ); 43 } 44 45 function options_validate(&$form, &$form_state) { 46 if (!array_filter($form_state['values']['access_options']['role'])) { 47 form_error($form['role'], t('You must select at least one role if type is "by role"')); 48 } 49 } 50 51 function options_submit(&$form, &$form_state) { 52 // I hate checkboxes. 53 $form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']); 54 } 55 } 56 57 58
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |