} // 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;
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;
}
}
$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;
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;
}
$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);
if (!isset($discussion->timeend)) {
$discussion->timeend = 0;
}
+
+trusttext_prepare_edit($post->message, $post->format, $usehtmleditor, $modcontext);
+
?>
<form name="theform" method="post" action="post.php" enctype="multipart/form-data">
<table border="0" cellpadding="5">
$errordestination = $SESSION->fromurl;
}
- $post->subject = strip_tags($post->subject, '<lang><span>'); // Strip all tags except lang
+ $post->subject = clean_param(strip_tags($post->subject, '<lang><span>'), PARAM_CLEAN); // Strip all tags except multilang
- //$post->message = clean_text($post->message, $post->format); // Clean up any bad tags
+ //$post->message will be cleaned later before display
$post->attachment = isset($_FILES['attachment']) ? $_FILES['attachment'] : NULL;
$cm->id = 0;
}
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ trusttext_after_edit($post->message, $modcontext);
if (!$post->subject or !$post->message) {
$post->error = get_string("emptymessage", "forum");
$timemessage = 4;
}
- if ($post->mailnow) {
+ if (!empty($post->mailnow)) {
$message .= get_string("postmailnow", "forum");
$timemessage = 4;
}
require_login($course->id, false, $cm);
+ $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($post->discussion) {
if (! $toppost = get_record("forum_posts", "discussion", $post->discussion, "parent", 0)) {
//Use highlight() with nonsense tags to spot search terms in the
//actual text content first. fiedorow - 9/2/2005
$missing_terms = "";
- $message = highlight($strippedsearch,format_text($post->message, $post->format, NULL, $course->id),
+ $options = new object();
+ $options->trusttext = true;
+ // detect TRUSTTEXT marker before first call to format_text
+ if (trusttext_present($post->message)) {
+ $ttpresent = true;
+ } else {
+ $ttpresent = false;
+ }
+ $message = highlight($strippedsearch,format_text($post->message, $post->format, $options, $course->id),
0,'<fgw9sdpq4>','</fgw9sdpq4>');
foreach ($searchterms as $searchterm) {
$missing_terms .= " $searchterm";
}
}
+ // now is the right time to strip the TRUSTTEXT marker, we will add it later if needed
+ $post->message = trusttext_strip($post->message);
$message = str_replace('<fgw9sdpq4>','<span class="highlight">',$message);
$message = str_replace('</fgw9sdpq4>','</span>',$message);
if ($missing_terms) {
$strmissingsearchterms = get_string('missingsearchterms','forum');
$post->message = '<p class="highlight2">'.$strmissingsearchterms.' '.$missing_terms.'</p>'.$message;
+ $ttpresent = false;
} else {
$post->message = $message;
}
$fulllink = "<a href=\"discuss.php?d=$post->discussion#$post->id\">".get_string("postincontext", "forum")."</a>";
//search terms already highlighted - fiedorow - 9/2/2005
$SESSION->forum_search = true;
+
+ // reconstruct the TRUSTTEXT properly after processing
+ if ($ttpresent) {
+ $post->message = trusttext_mark($post->message);
+ } else {
+ $post->message = trusttext_strip($post->message); //make 100% sure TRUSTTEXT marker was not created during processing
+ }
forum_print_post($post, $course->id, false, false, false, false, $fulllink);
unset($SESSION->forum_search);
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2006081800;
-$module->requires = 2006080900; // Requires this Moodle version
+$module->version = 2006082700;
+$module->requires = 2006082600; // Requires this Moodle version
$module->cron = 60;
?>