You are here

function imagefield_update_6003 in ImageField 6.3

Convert image field type to filefield.

File

./imagefield.install, line 57

Code

function imagefield_update_6003() {
  $ret = array();
  if (!module_exists('content')) {
    $ret['#abort'] = array(
      'success' => FALSE,
      'query' => t('Content module must be enabled before ImageField can be updated.'),
    );
    return $ret;
  }
  if (drupal_get_installed_schema_version('filefield', TRUE) < 6001) {
    $ret['#abort'] = array(
      'success' => FALSE,
      'query' => t('FileField must be updated to Drupal 6 before ImageField can be updated.'),
    );
    return $ret;
  }
  $ret[] = update_sql("UPDATE {" . content_field_tablename() . "} SET type = 'filefield', module = 'filefield', active = 1 WHERE module = 'imagefield' OR type = 'image'");
  $ret[] = update_sql("UPDATE {" . content_instance_tablename() . "} SET widget_type = 'imagefield_widget', widget_module = 'imagefield', widget_active = 1 WHERE widget_type = 'image' OR widget_type = 'imagefield_widget'");
  content_clear_type_cache();
  return $ret;
}