function mcd_submit in Maintenance Countdown 7
Same name and namespace in other branches
- 6 mcd.module \mcd_submit()
Add system_site_maintenance_settings form submit processing.
1 string reference to 'mcd_submit'
- mcd_form_alter in ./
mcd.module - Implements hook_form_alter().
File
- ./
mcd.module, line 236 - mcd.module
Code
function mcd_submit($form, &$form_state) {
// If website offline
if (variable_get('maintenance_mode', 0) == 1) {
// get time like 1315776380
$starttime = REQUEST_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(format_date($starttime, 'custom', 'c') . " +" . 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);
}
// Update the registry based on the latest files listed in the DB.
registry_rebuild();
// If cache lifetime has been set, then clear page cache
if (variable_get('cache_lifetime', 0) > 0) {
drupal_clear_css_cache();
drupal_clear_js_cache();
cache_clear_all('*', 'cache', TRUE);
cache_clear_all('*', 'cache_page', TRUE);
}
}