You are here

function strongarm_admin_form in Strongarm 6.2

Same name and namespace in other branches
  1. 6 strongarm.admin.inc \strongarm_admin_form()
  2. 7.2 strongarm.admin.inc \strongarm_admin_form()

Variable management strongarm form.

1 string reference to 'strongarm_admin_form'
strongarm_menu in ./strongarm.module
Implementation of hook_menu().

File

./strongarm.admin.inc, line 6

Code

function strongarm_admin_form($form_state) {
  global $conf;
  $vars = strongarm_vars_load(TRUE, TRUE);
  $form = array(
    '#theme' => 'strongarm_admin_form',
  );
  foreach ($vars as $name => $variable) {
    if ($variable->export_type & EXPORT_IN_CODE) {
      $default = ctools_get_default_object('variable', $name);

      // If variable value does not match global $conf, this value has been
      // hardcoded (e.g. in settings.php) and has been allowed to pass
      // through. It cannot be reverted.
      $hardcoded = FALSE;
      $restorable = FALSE;
      if (isset($conf[$name]) && $conf[$name] !== $variable->value) {
        $storage = t('Hardcoded');
        $hardcoded = TRUE;
      }
      elseif (!empty($variable->in_code_only)) {
        $storage = t('In code');
        $restorable = TRUE;
      }
      elseif ($variable->value != $default->value) {
        $storage = t('Overridden');
        $restorable = TRUE;
      }
      else {
        $storage = t('Saved to DB');
      }
      $value = $hardcoded ? $conf[$name] : $variable->value;

      // If the variable is in the database and differs from its code value,
      // allow administrator to revert its value.
      if ($restorable) {
        $form['revert']['#tree'] = TRUE;
        $form['revert'][$name]['revert'] = array(
          '#type' => 'checkbox',
        );
        $form['revert'][$name]['value'] = array(
          '#type' => 'value',
          '#value' => $default->value,
        );
      }
      $form['name'][$name] = array(
        '#type' => 'markup',
        '#value' => $name,
      );
      $form['storage'][$name] = array(
        '#type' => 'markup',
        '#value' => $storage,
      );
      $form['value'][$name] = array(
        '#type' => 'markup',
        '#value' => check_plain(_strongarm_readable($value)),
      );
    }
  }
  if (!empty($form['revert'])) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Restore values to DB'),
      '#submit' => array(
        'strongarm_admin_revert_submit',
      ),
    );
  }
  return $form;
}