diff --git a/mod/forum/db/mysql.php b/mod/forum/db/mysql.php index 9b239d47d38..6cd2a9f6063 100644 --- a/mod/forum/db/mysql.php +++ b/mod/forum/db/mysql.php @@ -267,7 +267,17 @@ function forum_upgrade($oldversion) { } // End if. } - + + if ($oldversion < 2006082700) { + $sql = "UPDATE {$CFG->prefix}forum_posts SET message = REPLACE(message, '".TRUSTTEXT."', '');"; + $likecond = sql_ilike()." '%".TRUSTTEXT."%'"; + while (true) { + if (!count_records_select('forum_posts', "message $likecond")) { + break; + } + execute_sql($sql); + } + } return true; diff --git a/mod/forum/db/postgres7.php b/mod/forum/db/postgres7.php index 8e2435b399b..6603f91363a 100644 --- a/mod/forum/db/postgres7.php +++ b/mod/forum/db/postgres7.php @@ -179,6 +179,56 @@ function forum_upgrade($oldversion) { execute_sql("INSERT INTO {$CFG->prefix}log_display (module, action, mtable, field) VALUES ('forum', 'user report', 'user', 'firstname||\' \'||lastname')"); } + if ($oldversion < 2006081800) { + // Upgrades for new roles and capabilities support. + require_once($CFG->dirroot.'/mod/forum/lib.php'); + + $forummod = get_record('modules', 'name', 'forum'); + + if ($forums = get_records('forum')) { + + if (!$studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) { + notice('Default student role was not found. Roles and permissions '. + 'for all your forums will have to be manually set after '. + 'this upgrade.'); + } + if (!$guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) { + notice('Default guest role was not found. Roles and permissions '. + 'for teacher forums will have to be manually set after '. + 'this upgrade.'); + } + + foreach ($forums as $forum) { + if (!forum_convert_to_roles($forum, $forummod->id, + $studentroles, $guestroles)) { + notice('Forum with id '.$forum->id.' was not upgraded'); + } + } + + // Drop column forum.open. + modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN open;'); + + // Drop column forum.assesspublic. + modify_database('', 'ALTER TABLE prefix_forum DROP COLUMN assesspublic;'); + + // We need to rebuild all the course caches to refresh the state of + // the forum modules. + rebuild_course_cache(); + + } // End if. + } + + if ($oldversion < 2006082700) { + $sql = "UPDATE {$CFG->prefix}forum_posts SET message = REPLACE(message, '".TRUSTTEXT."', '');"; + $likecond = sql_ilike()." '%".TRUSTTEXT."%'"; + while (true) { + if (!count_records_select('forum_posts', "message $likecond")) { + break; + } + execute_sql($sql); + } + } + return true; } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 410047e3179..f567bc89920 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -666,7 +666,7 @@ function forum_make_mail_text($course, $forum, $discussion, $post, $userfrom, $u } $posttext .= "\n".$strbynameondate."\n"; $posttext .= "---------------------------------------------------------------------\n"; - $posttext .= format_text_email($post->message, $post->format); + $posttext .= format_text_email(trusttext_strip($post->message), $post->format); $posttext .= "\n\n"; if ($post->attachment) { $post->course = $course->id; @@ -1650,7 +1650,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course, if (empty($formattedtextid) or $formattedtextid != $post->id) { // Recalculate the formatting $options = new Object; $options->para = true; - $formattedtext = format_text($post->message, $post->format, $options, $course->id); + $formattedtext = format_text(trusttext_strip($post->message), $post->format, $options, $course->id); $formattedtextid = $post->id; } @@ -1867,6 +1867,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link $options = new Object; $options->para = false; + $options->trusttext = true; if ($link and (strlen(strip_tags($post->message)) > $CFG->forum_longpost)) { // Print shortened version echo format_text(forum_shorten_post($post->message), $post->format, $options, $courseid); diff --git a/mod/forum/post.html b/mod/forum/post.html index 03a2b9b7591..62d065d3953 100644 --- a/mod/forum/post.html +++ b/mod/forum/post.html @@ -13,6 +13,9 @@ if (!isset($discussion->timestart)) { if (!isset($discussion->timeend)) { $discussion->timeend = 0; } + +trusttext_prepare_edit($post->message, $post->format, $usehtmleditor, $modcontext); + ?>