123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?php
- 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',
- 'pgsql_type' => 'timestamp without time zone',
- 'sqlite_type' => 'varchar',
- 'sqlsrv_type' => 'smalldatetime',
- '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
- );
- }
- }
- if (isset($field['settings']['repeat']) && $field['settings']['repeat'] == 1) {
- $db_columns['rrule'] = array(
- 'type' => 'text',
- 'not null' => FALSE,
- 'sortable' => FALSE,
- 'views' => FALSE,
- );
- }
- return array('columns' => $db_columns);
- }
- function date_update_last_removed() {
- return 6005;
- }
- function date_update_7000() {
- $instances = field_info_instances();
- foreach ($instances as $entity_type => $entities) {
- foreach ($entities as $bundle => $fields) {
- foreach ($fields as $field_name => $instance) {
- if (in_array($instance['widget']['type'], array('date_popup'))) {
- $changed = FALSE;
- foreach ($instance['display'] as $context => $display) {
- if ($display['type'] != 'date_default' && $display['type'] != 'date_interval' && $display['type'] != 'hidden') {
- $instance['display'][$context]['type'] = 'date_default';
- $instance['display'][$context]['settings']['format_type'] = str_replace('date_', '', $display['type']);
- $changed = TRUE;
- }
- }
- if ($changed) {
- field_update_instance($instance);
- }
- }
- }
- }
- }
- }
- function date_update_7001() {
- $query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC));
- $query->join('field_config', 'fc', 'fc.id = fci.field_id');
- $query->fields('fci');
- $query->condition(db_or()->condition('fc.type', 'date')->condition('fc.type', 'datestamp')->condition('fc.type', 'datetime'));
- $results = $query->execute();
- foreach ($results as $record) {
- $instance = unserialize($record['data']);
- if (in_array($instance['widget']['type'], array(
- 'date_popup_repeat',
- 'date_text_repeat',
- 'date_select_repeat'
- ))) {
- $instance['widget']['type'] = str_replace('_repeat', '', $instance['widget']['type']);
- db_update('field_config_instance')
- ->fields(array(
- 'data' => serialize($instance),
- ))
- ->condition('field_name', $record['field_name'])
- ->condition('entity_type', $record['entity_type'])
- ->condition('bundle', $record['bundle'])
- ->execute();
- }
- }
- field_cache_clear();
- drupal_set_message(t('The widgets for repeating dates have changed. Please check the Display Fields page for each content type that has repeating date fields and confirm that the right widget has been selected.'), 'warning');
- }
- function date_update_7002() {
- drupal_set_message(t("The <em>All Day</em> functionality has been moved into a separate module. This new module provides the option to add an <em>All Day</em> checkbox to toggle time on and off for date fields. It also contains the theme that displays the <em>All Day</em> text on fields that have no time. For consistency with prior code, it has been automatically enabled. If you don't want the <em>All Day</em> functionality you can disable this module."));
- module_enable(array('date_all_day'));
- }
- function date_update_7003() {
- drupal_set_message(t("The <em>Date Repeat</em> integration for Date fields is being moved into a separate module. For consistency with prior code, it has been automatically enabled if the Date Repeat API module is enabled. If you don't use <em>Date Repeat</em> functionality in your fields, you can disable this module."));
- if (module_exists('date_repeat')) {
- module_enable(array('date_repeat_field'));
- }
- }
- function date_update_7004() {
-
- $query = db_select('field_config_instance', 'fci', array('fetch' => PDO::FETCH_ASSOC));
- $query->join('field_config', 'fc', 'fc.id = fci.field_id');
- $query->fields('fci');
- $query->condition(db_or()->condition('fc.type', 'date')->condition('fc.type', 'datestamp')->condition('fc.type', 'datetime'));
- $results = $query->execute();
-
- foreach ($results as $record) {
- $instance = unserialize($record['data']);
- if (in_array($instance['widget']['type'], array('date_text'))) {
- $instance['widget']['settings']['increment'] = 1;
- db_update('field_config_instance')
- ->fields(array(
- 'data' => serialize($instance),
- ))
- ->condition('field_name', $record['field_name'])
- ->condition('entity_type', $record['entity_type'])
- ->condition('bundle', $record['bundle'])
- ->execute();
- }
- }
- field_cache_clear();
- drupal_set_message(t('Date text widgets have been updated to use an increment of 1.'));
- }
- function date_update_7005() {
-
- date_update_7004();
- }
|