View source
<?php
include_once './' . drupal_get_path('module', 'date_api') . '/date_api.module';
variable_set('date_max_year', 4000);
variable_set('date_min_year', 1);
variable_set('date_php_min_year', 1901);
variable_set('date_api_version', '5.2');
variable_get('date_default_timezone_name', NULL);
function date_api_install() {
$ret = array();
$ret = db_query("ALTER TABLE {users} ADD timezone_name varchar(50) NOT NULL default ''");
return $ret;
}
function date_api_uninstall() {
$ret = array();
$ret[] = db_query("ALTER TABLE {users} DROP timezone_name");
cache_clear_all('date_timezone_identifiers_list', 'cache');
$variables = array(
'date_api_version',
'date_min_year',
'date_max_year',
'date_php_min_year',
'date_db_tz_support',
);
foreach ($variables as $variable) {
variable_del($variable);
}
return $ret;
}
function date_api_requirements($phase) {
$requirements = array();
$t = get_t();
$tz_name = variable_get('date_default_timezone_name', NULL);
$error = FALSE;
if (version_compare(PHP_VERSION, '5.2', '<') && !module_exists('date_php4')) {
$error = TRUE;
$severity = REQUIREMENT_ERROR;
$value = $t('The Date API module requires the !link for PHP versions less than 5.2.', array(
'!link' => l($t('Date PHP4 module'), 'admin/build/modules'),
));
}
if ($error) {
$requirements['date_php4'] = array(
'title' => $t('Date API requirements'),
'value' => $value,
'severity' => $severity,
);
}
return $requirements;
}
function date_api_update_5000() {
$ret = array();
$ret[] = update_sql("ALTER TABLE {users} ADD timezone_name varchar(50) NOT NULL default ''");
return $ret;
}
function date_api_update_5200() {
$ret = array();
include_once './includes/install.inc';
$module_list = array();
$result = db_query("SELECT name FROM {system} WHERE status = 1 AND name IN ('date', 'date_copy', 'calendar', 'calendar_ical')");
while ($row = db_fetch_object($result)) {
$module_list[] = $row->name;
}
if (!empty($module_list)) {
$module_list = array_merge(array(
'date_timezone',
), $module_list);
}
if (!function_exists('date_create')) {
$module_list[] = 'date_php4';
}
if (module_exists('jscalendar')) {
$module_list[] = 'date_popup';
}
drupal_install_modules($module_list);
module_rebuild_cache();
$ret[] = array(
'success' => TRUE,
'query' => implode(', ', $module_list),
);
return $ret;
}