system_update_6018

Versions
6
system_update_6018()

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

Related topics

Code

modules/system/system.install, line 1497

<?php
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;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.