diff --git a/htmlpurifier.install b/htmlpurifier.install index 841d09a..dced4bf 100644 --- a/htmlpurifier.install +++ b/htmlpurifier.install @@ -189,7 +189,7 @@ function htmlpurifier_requirements($phase) { ); } } - + return $requirements; } @@ -216,19 +216,71 @@ function htmlpurifier_update_6200() { } variable_set("htmlpurifier_config_$format", $config_data); } - + return array(); } function htmlpurifier_update_6201() {} /** - * TODO: Perform the D6->D7 upgrade. * - * We need to update filter names and settings, in the same way that - * filter_update_7003() and filter_update_7004() do. + * Migrate filter settings into D7 format from D6 */ -// function htmlpurifier_update_7000() { -// } +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(); + foreach ($query->execute() 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) + $filterName = $module . "_basic"; + if ($record->delta == '1'){ + $filterName = $module . "_advanced"; + } + // Store away in the new D7 manner + db_insert('filter') + ->fields(array( + 'format' => $record->format, + 'module' => $module, + 'name' => $filterName, + '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 + $query = db_select($d6_table) + ->fields($d6_table, array('fid')); + if (mysql_num_rows($query) == 0){ + db_drop_table($d6_table); + } + } +} +/** + * Clean up the D6 cache_htmlpurifier schema since it was a clone of the system cache schema + */ +function htmlpurifier_update_7001() { + if (db_field_exists('cache_htmlpurifier', 'headers')){ + db_drop_field('cache_htmlpurifier', 'headers'); + } +} // vim: syntax=php