| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: arg_length.inc,v 1.1.2.2 2010/07/14 01:30:19 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * Plugin to provide access control/visibility based on length of 7 * simplecontext argument (in URL). 8 */ 9 10 /** 11 * Plugins are described by creating a $plugin array which will be used 12 * by the system that includes this file. 13 */ 14 $plugin = array( 15 'title' => t("Arg length"), 16 'description' => t('Control access by length of simplecontext argument.'), 17 'callback' => 'ctools_plugin_example_arg_length_ctools_access_check', 18 'settings form' => 'ctools_plugin_example_arg_length_ctools_access_settings', 19 'summary' => 'ctools_plugin_example_arg_length_ctools_access_summary', 20 'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'), 21 ); 22 23 /** 24 * Settings form for the 'by role' access plugin. 25 */ 26 function ctools_plugin_example_arg_length_ctools_access_settings(&$form, &$form_state, $conf) { 27 $form['settings']['greater_than'] = array( 28 '#type' => 'radios', 29 '#title' => t('Grant access if simplecontext argument length is'), 30 '#options' => array(1 => t('Greater than'), 0 => t('Less than or equal to')), 31 '#default_value' => $conf['greater_than'], 32 ); 33 $form['settings']['arg_length'] = array( 34 '#type' => 'textfield', 35 '#title' => t('Length of simplecontext argument'), 36 '#size' => 3, 37 '#default_value' => $conf['arg_length'], 38 '#description' => t('Access/visibility will be granted based on arg length.'), 39 ); 40 } 41 42 /** 43 * Check for access. 44 */ 45 function ctools_plugin_example_arg_length_ctools_access_check($conf, $context) { 46 // As far as I know there should always be a context at this point, but this 47 // is safe. 48 if (empty($context) || empty($context->data)) { 49 return FALSE; 50 } 51 $compare = ($context->arg_length > $conf['arg_length']); 52 if (($compare && $conf['greater_than']) || (!$compare && !$conf['greater_than'])) { 53 return TRUE; 54 } 55 return FALSE; 56 } 57 58 /** 59 * Provide a summary description based upon the checked roles. 60 */ 61 function ctools_plugin_example_arg_length_ctools_access_summary($conf, $context) { 62 return t('Simpletext argument must be !comp @length characters', 63 array('!comp' => $conf['greater_than'] ? 'greater than' : 'less than or equal to', 64 '@length' => $conf['arg_length'])); 65 } 66
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |