$t('Date API'), 'value' => $t('Missing system date settings'), 'description' => implode(' ', array_merge($error_messages, $success_messages)), 'severity' => REQUIREMENT_ERROR, ); } else { $requirements['date'] = array( 'title' => $t('Date API'), 'value' => $t('System date settings'), 'description' => implode(' ', $success_messages), ); } } return $requirements; } /** * Implements hook_install(). */ function date_api_install() { // Only set the message if Drupal itself is already installed. if (variable_get('install_task') == 'done') { // Ensure translations don't break at install time. $t = get_t(); // date_api_set_variables can install date_timezone. The // date_timezone_install() function does a module_enable('date_api'). This // means that date_api_enable() can be called before date_api_install() // finishes! So the date_api schema needs to be installed before this line! date_api_set_variables(); $message = $t('The Date API requires that you set up the site timezone and first day of week settings and the date format settings to function correctly.', array('@regional_settings' => url('admin/config/regional/settings'), '@regional_date_time' => url('admin/config/regional/date-time'))); drupal_set_message(filter_xss_admin($message), 'warning'); } } /** * Implements hook_enable(). */ function date_api_enable() { date_api_set_variables(); } /** * Implements hook_uninstall(). */ function date_api_uninstall() { 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', 'date_api_use_iso8601', ); foreach ($variables as $variable) { variable_del($variable); } if (db_table_exists('views_display')) { $displays = array( 'date_nav', ); db_query("DELETE FROM {views_display} WHERE display_plugin IN ('" . implode("','", $displays) . "')"); db_query("DELETE FROM {cache_views}"); } } /** * Implements hook_update_last_removed(). */ function date_api_update_last_removed() { return 6005; } /** * Move old date format to new date format tables,and delete the old tables. * * Insert only values that don't already exist in the new tables, in * case new version of those custom values have already been created. */ function date_api_update_7000() { // Move format data from the old 'date_format_types' table to the new // 'date_format_type' table. if (db_table_exists('date_format_types')) { // Find all the custom entries in the D6 table. $result = db_select('date_format_types', 'old_formats') ->fields('old_formats', array('type', 'title', 'locked')) ->condition('locked', 0) ->execute() ->fetchAll(PDO::FETCH_ASSOC); // Iterate over all the old values. foreach ($result as $row) { // See if this value already exists in the new table // (it might have been added manually before this update got run). $count = db_select('date_format_type', 'new_formats') ->condition('type', $row['type']) ->countQuery() ->execute() ->fetchField(); // If the value is missing, insert it. // Do nothing if it already exists, assume the value in the // new table trumps the old values. if (empty($count)) { db_insert('date_format_type') ->fields(array( 'type' => $row['type'], 'title' => $row['title'], 'locked' => $row['locked'], )) ->execute(); } } // Drop the old table. db_drop_table('date_format_types'); } // Move format data from the old 'date_formats' table (which was renamed to // 'd6_date_formats') to the new 'date_formats' table. if (db_table_exists('d6_date_formats')) { // Find all the custom entries in the D6 table. $result = db_select('d6_date_formats', 'old_formats') ->fields('old_formats', array('format', 'type', 'locked')) ->condition('type', 'custom') ->execute() ->fetchAll(PDO::FETCH_ASSOC); // Iterate over all the old values. foreach ($result as $row) { // See if this value already exists in the new table (it might have been // added manually before this update got run). $count = db_select('date_formats', 'new_formats') ->condition('format', $row['format']) ->condition('type', $row['type']) ->countQuery() ->execute() ->fetchField(); // If the value is missing, insert it. Do nothing if it already exists, // assume the value in the new table trumps the old values. if (empty($count)) { db_insert('date_formats') ->fields(array( 'format' => $row['format'], 'type' => $row['type'], 'locked' => $row['locked'], )) ->execute(); } } // Drop the old table. db_drop_table('d6_date_formats'); } // Move format data from the old 'date_format_locale' table (which was renamed // to 'd6_date_format_locale') to the new 'date_format_locale' table. if (db_table_exists('d6_date_format_locale')) { // Find all the custom entries in the D6 table. $result = db_select('d6_date_format_locale', 'old_formats') ->fields('old_formats', array('format', 'type', 'language')) ->condition('type', 'custom') ->execute() ->fetchAll(PDO::FETCH_ASSOC); // Iterate over all the old values. foreach ($result as $row) { // See if this value already exists in the new table (it might have been // added manually before this update got run). $count = db_select('date_format_locale', 'new_formats') ->condition('format', $row['format']) ->condition('type', $row['type']) ->condition('language', $row['language']) ->countQuery() ->execute() ->fetchField(); // If the value is missing, insert it. // Do nothing if it already exists, assume the value in the // new table trumps the old values. if (empty($count)) { db_insert('date_format_locale') ->fields(array( 'format' => $row['format'], 'type' => $row['type'], 'language' => $row['language'], )) ->execute(); } } // Drop the old table. db_drop_table('d6_date_format_locale'); } } /** * Drop D6 timezone_name field on {users} after upgrading to D7. */ function date_api_update_7001() { if (db_field_exists('users', 'timezone_name')) { db_drop_field('users', 'timezone_name'); } }