function date_timezone_requirements in Date 6
Same name and namespace in other branches
- 5.2 date_timezone/date_timezone.install \date_timezone_requirements()
- 6.2 date_timezone/date_timezone.install \date_timezone_requirements()
Implementation of hook_requirements(). Make sure a site timezone name has been selected.
File
- date_timezone/
date_timezone.install, line 20 - Installation file for Date Timezone
Code
function date_timezone_requirements($phase) {
$requirements = array();
$t = get_t();
$error = FALSE;
$value = array();
switch ($phase) {
case 'runtime':
$tz_name = variable_get('date_default_timezone_name', NULL);
if ($tz_name === NULL) {
$error = TRUE;
$severity = REQUIREMENT_ERROR;
$value = $t('The Date Timezone module requires you to !link.', array(
'!link' => l($t('set the site timezone name'), 'admin/settings/date-time'),
));
}
elseif (function_exists('date_create')) {
$date = date_make_date('now', $tz_name);
if (date_offset_get($date) != variable_get('date_default_timezone', 0)) {
$error = TRUE;
$value = $t('The !link may not be correct.', array(
'!link' => l($t('site timezone name'), 'admin/settings/date-time'),
));
$severity = REQUIREMENT_WARNING;
}
}
}
if ($error) {
$requirements['date_default_timezone'] = array(
'title' => $t('Date Timezone requirements'),
'value' => $value,
'severity' => $severity,
);
}
return $requirements;
}