Add HTML corrector to HTML formats or replace the old module if it was in use.

Related topics

File

modules/system/system.install, line 1565

Code

function system_update_6018() {
  $ret = array();

  // Disable htmlcorrector.module, if it exists and replace its filter.
  if (module_exists('htmlcorrector')) {
    module_disable(array(
      'htmlcorrector',
    ));
    $ret[] = update_sql("UPDATE {filter_formats} SET module = 'filter', delta = 3 WHERE module = 'htmlcorrector'");
    $ret[] = array(
      'success' => TRUE,
      'query' => 'HTML Corrector module was disabled; this functionality has now been added to core.',
    );
    return $ret;
  }

  // Otherwise, find any format with 'HTML' in its name and add the filter at the end.
  $result = db_query("SELECT format, name FROM {filter_formats} WHERE name LIKE '%HTML%'");
  while ($format = db_fetch_object($result)) {
    $weight = db_result(db_query("SELECT MAX(weight) FROM {filters} WHERE format = %d", $format->format));
    db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format->format, 'filter', 3, max(10, $weight + 1));
    $ret[] = array(
      'success' => TRUE,
      'query' => "HTML corrector filter added to the '" . $format->name . "' input format.",
    );
  }
  return $ret;
}