- <?php
- * @file
- * Install, update and uninstall functions for the Date module.
- */
-
- * Implements hook_field_schema().
- */
- function date_field_schema($field) {
- $db_columns = array();
- switch ($field['type']) {
- case 'datestamp':
- $db_columns['value'] = array(
- 'type' => 'int',
- 'not null' => FALSE,
- 'sortable' => TRUE,
- 'views' => TRUE,
- );
- break;
-
- case 'datetime':
- $db_columns['value'] = array(
- 'type' => 'datetime',
- 'mysql_type' => 'datetime',
- 'not null' => FALSE,
- 'sortable' => TRUE,
- 'views' => TRUE,
- );
- break;
-
- default:
- $db_columns['value'] = array(
- 'type' => 'varchar',
- 'length' => 20,
- 'not null' => FALSE,
- 'sortable' => TRUE,
- 'views' => TRUE,
- );
- break;
- }
-
-
- if (!empty($field['settings']['todate'])) {
- $db_columns['value2'] = $db_columns['value'];
-
-
-
- $db_columns['value2']['views'] = FALSE;
- }
-
- if (isset($field['settings']['tz_handling']) && $field['settings']['tz_handling'] == 'date') {
- $db_columns['timezone'] = array(
- 'type' => 'varchar',
- 'length' => 50,
- 'not null' => FALSE,
- 'sortable' => TRUE,
- 'views' => FALSE,
- );
- $db_columns['offset'] = array(
- 'type' => 'int',
- 'not null' => FALSE,
- 'sortable' => TRUE,
- 'views' => FALSE,
- );
- if (!empty($field['settings']['todate'])) {
- $db_columns['offset2'] = array(
- 'type' => 'int',
- 'not null' => FALSE,
- 'sortable' => TRUE,
- 'views' => FALSE);
- }
- }
- return array('columns' => $db_columns);
- }
-
- * Implements hook_update_last_removed().
- */
- function date_update_last_removed() {
- return 7004;
- }
-
- * Upgrade configuration from Drupal 7 Date module.
- */
- function date_update_1000() {
-
- }
-
- * Remove legacy Date API and Date Popup configurations.
- */
- function date_update_1001() {
- config('date_api.settings')->delete();
- config('date.settings')->delete();
-
-
- update_variable_del('date_popup_timepicker');
-
-
- db_query("DELETE FROM {system} WHERE name IN ('date_api', 'date_popup', 'date_views') AND type = 'module'");
- }
-
- * Remove entries with null values from date field tables.
- */
- function date_update_1002() {
-
- $fields = field_info_fields();
- foreach ($fields as $field_name => $field) {
- if (in_array($field['type'], array('date', 'datetime', 'datestamp'))) {
- db_delete('field_data_' . $field_name)
- ->isNull($field_name . '_value')
- ->execute();
- db_delete('field_revision_' . $field_name)
- ->isNull($field_name . '_value')
- ->execute();
- }
- }
- }