From: skodak Date: Sat, 26 Aug 2006 18:08:18 +0000 (+0000) Subject: trusttext cleaning in glossary upgrade - definitions and comments X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=907cf318210537b244b310348383329bb970346e;p=moodle.git trusttext cleaning in glossary upgrade - definitions and comments --- diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index 286f703995..5274c55ca7 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -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; } diff --git a/mod/glossary/db/postgres7.php b/mod/glossary/db/postgres7.php index da118f4d90..7eb5baca52 100644 --- a/mod/glossary/db/postgres7.php +++ b/mod/glossary/db/postgres7.php @@ -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; } diff --git a/mod/glossary/version.php b/mod/glossary/version.php index b8fed5571d..3237b2a4c5 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -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) ?>