You are here

function notifications_send_intervals_form_submit in Notifications 6

Same name and namespace in other branches
  1. 5 notifications.admin.inc \notifications_send_intervals_form_submit()
  2. 6.4 notifications.admin.inc \notifications_send_intervals_form_submit()
  3. 6.2 notifications.admin.inc \notifications_send_intervals_form_submit()
  4. 6.3 notifications.admin.inc \notifications_send_intervals_form_submit()

Form submit for time intervals

File

./notifications.admin.inc, line 179

Code

function notifications_send_intervals_form_submit($form, &$form_state) {
  $form_values = $form_state['values'];
  if ($form_values['op'] == t('Reset to defaults')) {
    variable_del('notifications_send_intervals');
    variable_del('notifications_digest_methods');
  }
  else {
    $intervals = array();
    $digest = array();
    foreach ($form_values['intervals'] as $index => $values) {
      if (is_numeric($values['time']) && $values['name']) {
        $unit = $values['unit'] ? (int) $values['unit'] : 1;
        $time = (int) $values['time'] * $unit;
        $intervals[$time] = $values['name'];
        $digest[$time] = $values['digest'];
      }
    }
    ksort($intervals);
    variable_set('notifications_send_intervals', $intervals);
    variable_set('notifications_digest_methods', $digest);
  }
  drupal_set_message(t('The time intervals for your subscriptions have been updated'));
}