function mcd_submit in Maintenance Countdown 6
Same name and namespace in other branches
- 7 mcd.module \mcd_submit()
Add system_site_maintenance_settings form submit processing.
We need to use date("c"), because drupal-6 function format_date() does not support "c".
See also
1 string reference to 'mcd_submit'
- mcd_form_system_site_maintenance_settings_alter in ./
mcd.module - Implements hook_form_FORM_ID_alter().
File
- ./
mcd.module, line 137 - This module provides the maintenance page with nice countdown timer. So now you may set time for your maintenance work and your visitors will see when time is up.
Code
function mcd_submit($form, &$form_state) {
// If website offline
if (variable_get('site_offline', 0) == 1) {
// get time like 1315776380
$starttime = time();
$offtime = array(
variable_get('mcd_months', 0) . ' months',
variable_get('mcd_days', 0) . ' days',
variable_get('mcd_hours', 0) . ' hours',
variable_get('mcd_minutes', 0) . ' minutes',
variable_get('mcd_seconds', 0) . ' seconds',
);
$stoptime = strtotime(date("c", $starttime) . " +" . implode(" ", $offtime));
// save stop-time in var, output like 1315776380
variable_set('mcd_stoptime', $stoptime);
// for messages
$start = format_date($starttime, 'small');
$stop = format_date($stoptime, 'small');
watchdog('mcd', 'Maintenance time @start — @stop', array(
'@start' => $start,
'@stop' => $stop,
), WATCHDOG_INFO);
if ($starttime == $stoptime) {
variable_set('mcd_maintenance', 0);
drupal_set_message(t('The timer is not set, because the time is not given.'), 'warning');
}
else {
variable_set('mcd_maintenance', 1);
drupal_set_message(t('Maintenance time @start — @stop', array(
'@start' => $start,
'@stop' => $stop,
)));
}
}
else {
variable_set('mcd_maintenance', 0);
drupal_set_message(t('Site on-line.'));
watchdog('mcd', 'Site on-line', NULL, WATCHDOG_INFO);
}
// Rebuild some caches
drupal_rebuild_theme_registry();
// it does cache_clear_all('theme_registry', 'cache', TRUE);
// If setted cache lifefime, then clear page cache
if (variable_get('cache_lifetime', 0) > 0) {
cache_clear_all('*', 'cache_page', TRUE);
drupal_set_message(t('Page cache was cleared!'));
}
}