| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: php.inc,v 1.1.2.4 2010/07/15 20:41:17 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * Plugin to provide access control based on evaluated PHP. 7 */ 8 9 /** 10 * Plugins are described by creating a $plugin array which will be used 11 * by the system that includes this file. 12 */ 13 $plugin = array( 14 'title' => t("PHP Code"), 15 'description' => t('Control access through arbitrary PHP code.'), 16 'callback' => 'ctools_php_ctools_access_check', 17 'default' => array('description' => '', 'php' => ''), 18 'settings form' => 'ctools_php_ctools_access_settings', 19 'summary' => 'ctools_php_ctools_access_summary', 20 'all contexts' => TRUE, 21 ); 22 23 /** 24 * Settings form for the 'by perm' access plugin 25 * 26 * @todo Need a way to provide a list of all available contexts to be used by 27 * the eval-ed PHP. 28 */ 29 function ctools_php_ctools_access_settings(&$form, &$form_state, $conf) { 30 $perms = array(); 31 32 $form['settings']['description'] = array( 33 '#type' => 'textfield', 34 '#title' => t('Administrative desc'), 35 '#default_value' => $conf['description'], 36 '#description' => t('A description for this test for administrative purposes.'), 37 ); 38 $form['settings']['php'] = array( 39 '#type' => 'textarea', 40 '#title' => t('PHP Code'), 41 '#default_value' => $conf['php'], 42 '#description' => t('Access will be granted if the following PHP code returns <code>TRUE</code>. Do not include <?php ?>. Note that executing incorrect PHP-code can break your Drupal site. All contexts will be available in the <em>$contexts</em> variable.'), 43 ); 44 if (!user_access('use PHP for block visibility')) { 45 $form['settings']['php']['#disabled'] = TRUE; 46 $form['settings']['php']['#value'] = $conf['php']; 47 $form['settings']['php']['#description'] .= ' ' . t('You do not have sufficient permissions to edit PHP code.'); 48 } 49 } 50 51 /** 52 * Check for access. 53 */ 54 function ctools_php_ctools_access_check($__conf, $contexts) { 55 $access = eval($__conf['php']); 56 return $access; 57 } 58 59 /** 60 * Provide a summary description based upon the checked roles. 61 */ 62 function ctools_php_ctools_access_summary($conf, $contexts) { 63 return !empty($conf['description']) ? check_plain($conf['description']) : t('No description'); 64 }
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 |