function notifications_send_intervals_form_submit in Notifications 6.4
Same name and namespace in other branches
- 5 notifications.admin.inc \notifications_send_intervals_form_submit()
- 6 notifications.admin.inc \notifications_send_intervals_form_submit()
- 6.2 notifications.admin.inc \notifications_send_intervals_form_submit()
- 6.3 notifications.admin.inc \notifications_send_intervals_form_submit()
Form submit for time intervals
File
- ./
notifications.admin.inc, line 243
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');
variable_del('notifications_default_send_interval');
}
else {
$intervals = $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'];
$build_methods[$time] = $values['build'];
if ($index == $form_values['default']) {
variable_set('notifications_default_send_interval', $time);
}
}
}
ksort($intervals);
variable_set('notifications_send_intervals', $intervals);
variable_set('notifications_digest_methods', $build_methods);
}
drupal_set_message(t('The time intervals for your subscriptions have been updated'));
// Update orphaned notifications with invalid send interval
$valid = array_keys($intervals);
$params = array_merge(array(
variable_get('notifications_default_send_interval', 0),
), $valid);
db_query('UPDATE {notifications} SET send_interval = %d WHERE send_interval NOT IN (' . db_placeholders($valid) . ')', $params);
if ($updated = db_affected_rows()) {
drupal_set_message(format_plural($updated, 'Updated a subscription with invalid interval.', 'Updated @count subscriptions with invalid intervals.'));
}
// Refresh strings after update if translation enabled
if (module_exists('i18nstrings')) {
notifications_locale_refresh();
}
}