You are here

function strongarm_form_alter in Strongarm 6

Implementation of hook_form_alter().

File

./strongarm.module, line 122

Code

function strongarm_form_alter(&$form, &$form_state, $form_id) {
  $pattern = '';
  $position = STRONGARM_PATTERN_PREFIX;
  if (!empty($form['#submit']) && is_array($form['#submit']) && in_array('system_settings_form_submit', $form['#submit'])) {
    $lockdown = TRUE;
  }
  else {
    if ($form_id == 'node_type_form') {
      $lockdown = TRUE;
      $pattern = $form['#node_type']->type;
      $position = STRONGARM_PATTERN_SUFFIX;
    }
    else {
      if (arg(0) === 'admin' && $form_id != 'strongarm_admin_form') {
        $lockdown = TRUE;
      }
    }
  }
  if (!empty($lockdown) && variable_get('strongarm_mode', STRONGARM_MODE_STRONG) == STRONGARM_MODE_STRONG) {
    module_load_include('inc', 'strongarm', 'strongarm.admin');
    drupal_add_css(drupal_get_path('module', 'strongarm') . '/strongarm.css');
    if (_strongarm_lockdown($form, $pattern, $position) && variable_get('strongarm_show_messages', TRUE)) {
      drupal_set_message(t('The highlighted fields may need to retain their current values for your site to operate properly. Settings may be disabled or reverted automatically if they are not compatible with one or more of your site\'s modules.'), 'warning', FALSE);
      if (user_access('administer site configuration')) {
        drupal_set_message(t('You can change locked-in settings by switching to "Allow variable overrides" on the !admin_page.', array(
          '!admin_page' => l(t('Strongarm admin page'), 'admin/settings/strongarm'),
        )), 'warning', FALSE);
      }
    }
  }

  // Clear strongarm & variable caches on modules page.
  if ($form_id == 'system_module') {
    strongarm_flush_caches();
  }
}