You are here

function autocomplete_widgets_update_6001 in Autocomplete Widgets for Text and Number Fields 6

Update all Autocomplete Widgets for new case sensitive option.

File

./autocomplete_widgets.install, line 51
Module installation/uninstallation hooks.

Code

function autocomplete_widgets_update_6001() {
  drupal_load('module', 'content');
  if ($abort = content_check_update('autocomplete_widgets')) {
    return $abort;
  }
  $ret = array();
  $result = db_query("SELECT field_name, type_name, widget_settings FROM {content_node_field_instance} WHERE (widget_type = 'autocomplete_widgets_allowvals' OR widget_type = 'autocomplete_widgets_flddata')");
  while ($field = db_fetch_object($result)) {
    $widget_settings = unserialize($field->widget_settings);
    if (!isset($widget_settings['autocomplete_case'])) {
      $widget_settings['autocomplete_case'] = 1;
      $widget_settings = serialize($widget_settings);
      $success = db_query("UPDATE {content_node_field_instance} SET widget_settings = '%s' WHERE type_name = '%s' AND field_name = '%s'", $widget_settings, $field->type_name, $field->field_name);
      $ret[] = array(
        'success' => $success !== FALSE,
        'query' => strtr('Updating definition of the Autocomplete Widget for field %field-name in type %type-name.', array(
          '%field-name' => $field->field_name,
          '%type-name' => $field->type_name,
        )),
      );
    }
  }
  if (!empty($ret)) {
    content_clear_type_cache();
  }
  return $ret;
}