*/
define('FORMAT_MARKDOWN', '4'); // Markdown-formatted text http://daringfireball.net/projects/markdown/
-/**
- * TRUSTTEXT marker - if present in text, text cleaning should be bypassed
- */
-define('TRUSTTEXT', '#####TRUSTTEXT#####');
-
/**
* A moodle_url comparison using this flag will return true if the base URLs match, params are ignored
*/
* Legacy function, used for cleaning of old forum and glossary text only.
*
* @global object
- * @param string $text text that may contain TRUSTTEXT marker
- * @return text without any TRUSTTEXT marker
+ * @param string $text text that may contain legacy TRUSTTEXT marker
+ * @return text without legacy TRUSTTEXT marker
*/
function trusttext_strip($text) {
- global $CFG;
-
while (true) { //removing nested TRUSTTEXT
$orig = $text;
$text = str_replace('#####TRUSTTEXT#####', '', $text);
if ($oldversion < 2009042002) {
$trustmark = '#####TRUSTTEXT#####';
- $rs = $DB->get_recordset_sql("SELECT * FROM {forum_posts} WHERE message LIKE '$trustmark%'");
+ $rs = $DB->get_recordset_sql("SELECT * FROM {forum_posts} WHERE message LIKE ?", array($trustmark.'%'));
foreach ($rs as $post) {
- if (strpos($post->entrycomment, $trustmark) !== 0) {
- // probably lowercase in some DBs
+ if (strpos($post->message, $trustmark) !== 0) {
+ // probably lowercase in some DBs?
continue;
}
- $post->message = trusttext_strip($post->message);
+ $post->message = str_replace($trustmark, '', $post->message);
$post->messagetrust = 1;
$DB->update_record('forum_posts', $post);
}
if ($oldversion < 2009042004) {
$trustmark = '#####TRUSTTEXT#####';
- $rs = $DB->get_recordset_sql("SELECT * FROM {glossary_entries} WHERE definition LIKE '$trustmark%'");
+ $rs = $DB->get_recordset_sql("SELECT * FROM {glossary_entries} WHERE definition LIKE ?", array($trustmark.'%'));
foreach ($rs as $entry) {
if (strpos($entry->definition, $trustmark) !== 0) {
// probably lowercase in some DBs
continue;
}
- $entry->definition = trusttext_strip($entry->definition);
+ $entry->definition = str_replace($trustmark, '', $entry->definition);
$entry->definitiontrust = 1;
$DB->update_record('glossary_entries', $entry);
}
if ($oldversion < 2009042005) {
$trustmark = '#####TRUSTTEXT#####';
- $rs = $DB->get_recordset_sql("SELECT * FROM {glossary_comments} WHERE entrycomment LIKE '$trustmark%'");
+ $rs = $DB->get_recordset_sql("SELECT * FROM {glossary_comments} WHERE entrycomment LIKE ?", array($trustmark.'%'));
foreach ($rs as $comment) {
if (strpos($comment->entrycomment, $trustmark) !== 0) {
// probably lowercase in some DBs
continue;
}
- $comment->entrycomment = trusttext_strip($comment->entrycomment);
+ $comment->entrycomment = str_replace($trustmark, '', $comment->entrycomment);
$comment->entrycommenttrust = 1;
$DB->update_record('glossary_comments', $comment);
}