function htmlpurifier_update_7000 in HTML Purifier 7.2
Same name and namespace in other branches
- 7 htmlpurifier.install \htmlpurifier_update_7000()
Migrate filter settings into D7 format from D6
File
- ./
htmlpurifier.install, line 140 - Install, update and uninstall functions for the HTML Purifier module.
Code
function htmlpurifier_update_7000() {
// Make sure {d6_upgrade_filter} exists. It won't exist for people on
// native D7 sites (not upgraded from D6).
$d6_table = 'd6_upgrade_filter';
$module = 'htmlpurifier';
if (db_table_exists($d6_table)) {
$query = db_select($d6_table)
->fields($d6_table, array(
'format',
'weight',
'delta',
))
->condition('module', $module)
->distinct()
->execute();
foreach ($query as $record) {
// Pull out the filter settings from variables
$settings = array();
$settings['htmlpurifier_help'] = variable_get("htmlpurifier_help_{$record->format}", NULL);
variable_del("htmlpurifier_help_{$record->format}");
$settings['htmlpurifier_basic_config'] = variable_get("htmlpurifier_config_{$record->format}", NULL);
variable_del("htmlpurifier_config_{$record->format}");
// Determine the filter type (basic/advanced)
$filter_name = $module . "_basic";
if ($record->delta == '1') {
$filter_name = $module . "_advanced";
}
// Store away in the new D7 manner
db_insert('filter')
->fields(array(
'format' => $record->format,
'module' => $module,
'name' => $filter_name,
'weight' => $record->weight,
'settings' => serialize($settings),
'status' => 1,
))
->execute();
}
// Double caching was removed in D7
variable_del(variable_get("htmlpurifier_doublecache", NULL));
// Remove all entries from the migration table
db_delete($d6_table)
->condition('module', $module)
->execute();
// Drop d6 migration table if it is empty
$count = db_select($d6_table)
->fields($d6_table, array(
'fid',
))
->countQuery()
->execute()
->fetchField();
if ($count === 0) {
db_drop_table($d6_table);
}
}
}