You are here

function revision_all_settings_form_submit in Revision All 7.2

Same name and namespace in other branches
  1. 8 revision_all.module \revision_all_settings_form_submit()
  2. 6 revision_all.module \revision_all_settings_form_submit()
  3. 7 revision_all.module \revision_all_settings_form_submit()

Processes the settings form.

Parameters

array $form The form being processed.:

array $form_state The state of the form upon submission.:

File

./revision_all.module, line 118
Permits configuring content revision settings from a central location. Also makes alterations to existing forms based on user specified settings.

Code

function revision_all_settings_form_submit(&$form, &$form_state) {
  $content_types = node_type_get_names();
  $revision_settings = $form_state['values']['revision_all'];
  $revision_all_types = $revision_settings['revision_all_types'];
  $revision_types = $revision_settings['revision_types']['types'];
  while ($type = current($content_types)) {
    $key = key($content_types);
    $type_settings = array();
    $settings_key = '';
    $should_revision = $revision_all_types || $revision_types[$type];
    $currently_revision = revision_all_type_is_revisioned($key, $settings_key, $type_settings);

    // Set the correct revision settings for the different content types.
    if ($should_revision && $currently_revision === FALSE) {
      $type_settings[] = 'revision';
    }
    elseif ($currently_revision !== FALSE && !$should_revision) {
      unset($type_settings[$currently_revision]);
    }
    variable_set($settings_key, $type_settings);
    next($content_types);
  }

  // Remove the revision types from being stored since we have already updated the content type settings.
  unset($revision_settings['revision_types']);
  variable_set('revision_all', $revision_settings);
  drupal_set_message(t('Revisioning Set'));
}