You are here

function finder_php_setting in Finder 6

Same name and namespace in other branches
  1. 7 finder.module \finder_php_setting()

Modify a PHP setting element.

Used for security reasons to prevent an unauthorized user editing the field. Also makes variables available for the PHP input.

Parameters

$element: The original array for the element.

$variables: Array where keys are variable names (without the $) to make available in the PHP, and the values are descriptions already passed through t().

4 calls to finder_php_setting()
finder_admin_edit in includes/finder.admin.inc
Admin finder edit page.
finder_optionwidgets_finder_admin_element_rewrite_bits in modules/finder_optionwidgets/finder_optionwidgets.module
Add settings to the form pertaining to rewrites.
finder_views_form_finder_admin_edit_alter in modules/finder_views/finder_views.module
Implementation of hook_form_FORM_ID_alter().
finder_views_form_finder_admin_element_edit_alter in modules/finder_views/finder_views.module
Implementation of hook_form_FORM_ID_alter().

File

./finder.module, line 1732
The finder module.

Code

function finder_php_setting($element, $variables = array()) {
  if (user_access('administer finder PHP settings')) {
    $var_list = array();
    foreach ($variables as $variable => $description) {
      $var_list[] = '<em>$' . $variable . '</em> - ' . $description;
    }
    if (!empty($var_list)) {
      $element['#description'] = (isset($element['#description']) ? $element['#description'] : '') . '<div>' . t('Available variables') . ':' . theme('item_list', $var_list) . '</div>';
    }
  }
  else {
    $element['#disabled'] = TRUE;
    $element['#prefix'] = '<div class="messages warning">' . t("You don't have permission to modify <em>!setting</em>.", array(
      '!setting' => $element['#title'],
    )) . '</div>' . (isset($element['#prefix']) ? $element['#prefix'] : '');
    $element['#value'] = $element['#default_value'];
  }
  return $element;
}