]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18541 replace script - now also replaces within well known html blocks. Merged...
authorstronk7 <stronk7>
Thu, 12 Mar 2009 19:04:53 +0000 (19:04 +0000)
committerstronk7 <stronk7>
Thu, 12 Mar 2009 19:04:53 +0000 (19:04 +0000)
admin/replace.php

index da9a99a95aa50f6199dcce458b2a6e93d798c8ce..67fd9da523933b30228da4a880309e5dd16beb03 100644 (file)
@@ -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();