From 36fa17855fdc0972bb9414c6cf5f6ba1661c888c Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 12 Mar 2009 19:04:53 +0000 Subject: [PATCH] MDL-18541 replace script - now also replaces within well known html blocks. Merged from 19_STABLE --- admin/replace.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/admin/replace.php b/admin/replace.php index da9a99a95aa..67fd9da5239 100644 --- a/admin/replace.php +++ b/admin/replace.php @@ -40,6 +40,20 @@ if (!db_replace($search, $replace)) { print_simple_box_end(); +/// Try to replace some well-known serialised contents (html blocks) +notify('Replacing in html blocks...'); +$sql = "SELECT bi.* + FROM {$CFG->prefix}block_instance bi + JOIN {$CFG->prefix}block b ON b.id = bi.blockid + WHERE b.name = 'html'"; +if ($instances = $DB->get_records_sql($sql)) { + foreach ($instances as $instance) { + $blockobject = block_instance('html', $instance); + $blockobject->config->text = str_replace($search, $replace, $blockobject->config->text); + $blockobject->instance_config_commit($blockobject->pinned); + } +} + /// Rebuild course cache which might be incorrect now notify('Rebuilding course cache...', 'notifysuccess'); rebuild_course_cache();