You are here

function node_expire_settings_form_submit in Node expire 5

Implementation of hook_form_submit()

File

./node_expire.module, line 337
Alerts administrators of possibly outdated materials and optionally unpublishes them.

Code

function node_expire_settings_form_submit($form_id, $form_values) {

  // Do we want to reset to the defaults?
  if ($form_values['op'] == t('Reset to defaults')) {
    variable_del('node-expire-body');
    variable_del('node-expire-book-props');
    variable_del('node-expire-cc');
    variable_del('node-expire-enable-email');
    variable_del('node-expire-renotify');
    variable_del('node-expire-subject');
    variable_del('node-expire-unpublishtime');
    drupal_set_message(t('Settings reset back to defaults.'));
  }
  else {

    // Only allow inheritance for book pages.
    if (!module_exists('book')) {
      variable_del('node-expire-book-props');
    }
    else {
      variable_set('node-expire-book-props', $form_values['book_inherit']);
    }

    // Blank body resets to default
    if (!$form_values['body']) {
      variable_del('node-expire-body');
    }
    else {
      variable_set('node-expire-body', $form_values['body']);
    }

    // Blank subject resets to default
    if (!$form_values['subject']) {
      variable_del('node-expire-subject');
    }
    else {
      variable_set('node-expire-subject', $form_values['subject']);
    }

    // All other settings can be saved as-is.
    variable_set('node-expire-enable-email', $form_values['enabled']);
    variable_set('node-expire-cc', $form_values['cc']);
    variable_set('node-expire-renotify', $form_values['renotify']);
    variable_set('node-expire-unpublishtime', $form_values['unpublishtime']);
    drupal_set_message(t('Saved new settings.'));
  }
}