You are here

function date_update_5200 in Date 6

Same name and namespace in other branches
  1. 5.2 date/date.install \date_update_5200()

Version 5.2 updates.

File

date/date.install, line 210

Code

function date_update_5200() {
  date_install_load();
  $ret = array();
  module_enable(array(
    'date_timezone',
  ));

  // Make sure date module loads after date_api.
  $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'date'");

  // No longer using the cached formats.
  cache_clear_all('date_formats', 'cache', TRUE);

  // Granularity names have been changed to conform with keys used in date arrays.
  $replace = array(
    'Y' => 'year',
    'M' => 'month',
    'D' => 'day',
    'H' => 'hour',
    'N' => 'minute',
    'S' => 'second',
  );
  $fields = content_fields();
  foreach ($fields as $field) {
    if (strstr($field['type'], 'date')) {
      $field_settings = unserialize(db_result(db_query("SELECT global_settings from {" . content_field_tablename() . "} where field_name = '%s'", $field['field_name'])));
      $granularity = array();
      foreach ((array) $field_settings['granularity'] as $item) {
        $granularity[] = strtr($item, $replace);
      }
      $field_settings['granularity'] = $granularity;

      // Save the new settings.
      db_query("UPDATE {" . content_field_tablename() . "} SET global_settings = '%s' WHERE field_name='%s'", serialize($field_settings), $field['field_name']);
    }
  }
  content_clear_type_cache();
  return $ret;
}