You are here

function node_revision_delete_form_submit in Node Revision Delete 7.2

Same name and namespace in other branches
  1. 7 node_revision_delete.module \node_revision_delete_form_submit()

Form submit handler for the settings form.

File

./node_revision_delete.admin.inc, line 114
Calls results to administration's pages for the Node Revision Delete module.

Code

function node_revision_delete_form_submit($form, &$form_state) {
  variable_set('node_revision_delete_cron', $form_state['values']['node_revision_delete_cron']);
  variable_set('node_revision_delete_time', $form_state['values']['node_revision_delete_time']);
  $node_revision_delete_content_types = node_revision_delete_content_types();
  if ($form_state['values']['run_now'] && count($node_revision_delete_content_types)) {

    // Set up the batch job.
    $operations = array();
    foreach ($node_revision_delete_content_types as $content_type => $revisions_to_keep) {
      $operations[] = array(
        'node_revision_delete_batch_process',
        array(
          $content_type,
          $revisions_to_keep,
        ),
      );
    }
    $batch = array(
      'operations' => $operations,
      'title' => t('Node Revision Delete batch job'),
      'init_message' => t('Starting...'),
      'error_message' => t('An error occurred'),
      'finished' => 'node_revision_delete_batch_finish',
      'file' => drupal_get_path('module', 'node_revision_delete') . '/node_revision_delete.batch.inc',
    );
    batch_set($batch);
  }
  drupal_set_message(t('Settings Saved Successfully.'));
}