Community Documentation

filter_update_7001

7 filter.install filter_update_7001()

Break out "escape HTML filter" option to its own filter.

File

modules/filter/filter.install, line 199
Install, update and uninstall functions for the filter module.

Code

<?php
function filter_update_7001() {
  $result = db_query("SELECT format FROM {filter_format}")->fetchCol();
  $insert = db_insert('filters')->fields(array('format', 'module', 'delta', 'weight'));

  foreach ($result as $format_id) {
    // Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2.
    if (variable_get('filter_html_' . $format_id, 1) == 2) {
      $insert->values(array(
        'format' => $format_id, 
        'module' => 'filter', 
        'delta' => 4, 
        'weight' => 0,
      ));
    }
    variable_del('filter_html_' . $format_id);
  }

  $insert->execute();
}
?>
Login or register to post comments