]> git.mjollnir.org Git - moodle.git/commitdiff
trusttext cleaning in glossary upgrade - definitions and comments
authorskodak <skodak>
Sat, 26 Aug 2006 18:08:18 +0000 (18:08 +0000)
committerskodak <skodak>
Sat, 26 Aug 2006 18:08:18 +0000 (18:08 +0000)
mod/glossary/db/mysql.php
mod/glossary/db/postgres7.php
mod/glossary/version.php

index 286f703995e81b28291767ef56ec793b9adc3bc5..5274c55ca75a88db833afddef69f6c042e8b0eb7 100644 (file)
@@ -418,6 +418,24 @@ function glossary_upgrade($oldversion) {
         $wtm->update( 'glossary_comments','text','format',$sql );
     }
 
+    if ($oldversion < 2006082600) {
+        $sql1 = "UPDATE {$CFG->prefix}glossary_entries SET definition = REPLACE(definition, '".TRUSTTEXT."', '');";
+        $sql2 = "UPDATE {$CFG->prefix}glossary_comments SET comment = REPLACE(comment, '".TRUSTTEXT."', '');";
+        $likecond = sql_ilike()." '%".TRUSTTEXT."%'";
+        while (true) {
+            if (!count_records_select('glossary_entries', "definition $likecond")) {
+                break;
+            }
+            execute_sql($sql1);
+        }
+        while (true) {
+            if (!count_records_select('glossary_comments', "comment $likecond")) {
+                break;
+            }
+            execute_sql($sql2);
+        }
+    }
+
   return true;
 }
 
index da118f4d908b1f41d0159789d9c577d894933bcb..7eb5baca520bf132794fb8659d3e0a616d8f1007 100644 (file)
@@ -182,6 +182,25 @@ function glossary_upgrade($oldversion) {
         table_column('glossary','allowprintview','allowprintview','smallint','4','unsigned','1');
     }
 
+    if ($oldversion < 2006082600) {
+        $sql1 = "UPDATE {$CFG->prefix}glossary_entries SET definition = REPLACE(definition, '".TRUSTTEXT."', '');";
+        $sql2 = "UPDATE {$CFG->prefix}glossary_comments SET comment = REPLACE(comment, '".TRUSTTEXT."', '');";
+        $likecond = sql_ilike()." '%".TRUSTTEXT."%'";
+        while (true) {
+            if (!count_records_select('glossary_entries', "definition $likecond")) {
+                break;
+            }
+            execute_sql($sql1);
+        }
+        while (true) {
+            if (!count_records_select('glossary_comments', "comment $likecond")) {
+                break;
+            }
+            execute_sql($sql2);
+        }
+    }
+
+
   return true;
 }
 
index b8fed5571d10b5651faf9aa69fb8a3c7acaf621e..3237b2a4c57fb9f6d20c38f484b1ebb06d97f7d5 100644 (file)
@@ -5,8 +5,8 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2006080900;
-$module->requires = 2006080900;  // Requires this Moodle version
+$module->version  = 2006082600;
+$module->requires = 2006082600;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)
 
 ?>