[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/ctools/plugins/access/ -> theme.inc (source)

   1  <?php
   2  // $Id: theme.inc,v 1.1.2.4 2010/07/22 22:38:11 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   * Plugin to provide access control based on user themeission strings.
   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("Current theme"),
  15    'description' => t('Control access by checking which theme is in use.'),
  16    'callback' => 'ctools_theme_ctools_access_check',
  17    'default' => array('theme' => variable_get('theme_default', 'garland')),
  18    'settings form' => 'ctools_theme_ctools_access_settings',
  19    'summary' => 'ctools_theme_ctools_access_summary',
  20  );
  21  
  22  /**
  23   * Settings form for the 'by theme' access plugin
  24   */
  25  function ctools_theme_ctools_access_settings(&$form, &$form_state, $conf) {
  26    $themes = array();
  27    foreach (list_themes() as $key => $theme) {
  28      $themes[$key] = $theme->info['name'];
  29    }
  30  
  31    $form['settings']['theme'] = array(
  32      '#type' => 'select',
  33      '#options' => $themes,
  34      '#title' => t('Themes'),
  35      '#default_value' => $conf['theme'],
  36      '#description' => t('This will only be accessed if the current theme is the selected theme.'),
  37    );
  38  }
  39  
  40  /**
  41   * Check for access.
  42   */
  43  function ctools_theme_ctools_access_check($conf, $context) {
  44    if (!empty($GLOBALS['theme'])) {
  45      $theme = $GLOBALS['theme'];
  46    }
  47    else if (!empty($GLOBALS['custom_theme'])) {
  48      $theme = $GLOBALS['custom_theme'];
  49    }
  50    else if (!empty($GLOBALS['user']->theme)) {
  51      $theme = $GLOBALS['user']->theme;
  52    }
  53    else {
  54      $theme = variable_get('theme_default', 'garland');
  55    }
  56  
  57    return $conf['theme'] == $theme;
  58  }
  59  
  60  /**
  61   * Provide a summary description based upon the checked roles.
  62   */
  63  function ctools_theme_ctools_access_summary($conf, $context) {
  64    if (!isset($conf['theme'])) {
  65      return t('Error, unset theme');
  66    }
  67    $themes = list_themes();
  68  
  69    return t('Current theme is "@theme"', array('@theme' => $themes[$conf['theme']]->info['name']));
  70  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7