You are here

function date_update_6001 in Date 6.2

Get rid of jscalendar popup widget. Originally update_5201, but that was broken.

File

date/date.install, line 91

Code

function date_update_6001() {
  include_once drupal_get_path('module', 'content') . '/content.install';
  if ($abort = content_check_update('date')) {
    return $abort;
  }
  drupal_load('module', 'content');
  $ret = array();
  if (db_result(db_query("SELECT COUNT(*) FROM {" . content_instance_tablename() . "} WHERE widget_type = 'date_js'"))) {
    $replace = module_exists('date_popup') ? 'date_popup' : 'date_text';
    $result = db_query("SELECT field_name, type_name, widget_type from {" . content_instance_tablename() . "} where widget_type = 'date_js'");
    while ($widget = db_fetch_array($result)) {
      db_query("UPDATE {" . content_instance_tablename() . "} SET widget_type = '{$replace}' WHERE field_name = '%s' AND type_name = '%s'", $widget['field_name'], $widget['type_name']);
    }
    drupal_set_message(t('All date fields using the jscalendar widget have been changed to use the text widget instead, since the jscalendar widget is no longer supported. Enable the Date Popup module to make a jQuery popup calendar available and edit the field settings to select it.'));
    content_clear_type_cache();
  }
  return $ret;
}