diff --git a/mod/forum/db/mysql.php b/mod/forum/db/mysql.php index a22eafbc67b..58f758db217 100644 --- a/mod/forum/db/mysql.php +++ b/mod/forum/db/mysql.php @@ -46,6 +46,9 @@ function forum_upgrade($oldversion) { execute_sql(" UPDATE `forum` SET `open` = 2 WHERE `open` = 1 "); execute_sql(" UPDATE `forum` SET `open` = 1 WHERE `open` = 0 "); } + if ($oldversion < 2002101001) { + execute_sql(" ALTER TABLE `forum_posts` ADD `format` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL AFTER `message` "); + } return true; diff --git a/mod/forum/db/mysql.sql b/mod/forum/db/mysql.sql index 1c67e847cce..eb831cf90eb 100644 --- a/mod/forum/db/mysql.sql +++ b/mod/forum/db/mysql.sql @@ -47,6 +47,7 @@ CREATE TABLE forum_posts ( mailed tinyint(1) unsigned NOT NULL default '0', subject varchar(255) NOT NULL default '', message text NOT NULL, + format tinyint(2) NOT NULL default '0', attachment VARCHAR(100) NOT NULL default '', totalscore tinyint(4) NOT NULL default '0', PRIMARY KEY (id) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index a427cffdd67..f361f6e7c11 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -24,6 +24,7 @@ $FORUM_OPEN_MODES = array ("2" => get_string("openmode2", "forum"), "1" => get_string("openmode1", "forum"), "0" => get_string("openmode0", "forum") ); + $FORUM_SHORT_POST = 300; // Less than this is "short" $FORUM_LONG_POST = 600; // More than this is "long" @@ -123,7 +124,7 @@ function forum_make_mail_post(&$post, $user, $touser, $course, $output .= ""; } - $output .= text_to_html($post->message); + $output .= format_text($post->message, $post->format); $output .= "
";
@@ -202,14 +203,14 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
if ($link && (strlen($post->message) > $FORUM_LONG_POST)) {
// Print shortened version
- echo text_to_html(forum_shorten_post($post->message));
+ echo format_text(forum_shorten_post($post->message), $post->format);
$numwords = count_words($post->message);
echo "wwwroot/mod/forum/discuss.php?d=$post->discussion\">";
echo get_string("readtherest", "forum");
echo " (".get_string("numwords", "", $numwords).")...";
} else {
// Print whole message
- echo text_to_html($post->message);
+ echo format_text($post->message, $post->format);
}
echo " ";
diff --git a/mod/forum/post.html b/mod/forum/post.html
index b7842cc3381..614377cc462 100644
--- a/mod/forum/post.html
+++ b/mod/forum/post.html
@@ -1,4 +1,4 @@
-
+
+ if ($usehtmleditor) { ?>
+
+ } ?>
+
diff --git a/mod/forum/post.php b/mod/forum/post.php
index c0842eb81b3..7d7b014efb4 100644
--- a/mod/forum/post.php
+++ b/mod/forum/post.php
@@ -14,7 +14,7 @@
$post = (object)$HTTP_POST_VARS;
$post->subject = strip_tags($post->subject); // Strip all tags
- $post->message = cleantext($post->message); // Clean up any bad tags
+ $post->message = clean_text($post->message, $post->format); // Clean up any bad tags
$post->attachment = $HTTP_POST_FILES["attachment"];
@@ -262,6 +262,10 @@
$strforums = get_string("modulenameplural", "forum");
+ if ($usehtmleditor = can_use_richtext_editor()) {
+ $onsubmit = "onsubmit=\"copyrichtext(theform.message);\"";
+ }
+
$navmiddle = "id\">$strforums -> id\">$forum->name";
if ($course->category) {
diff --git a/mod/forum/version.php b/mod/forum/version.php
index 1168cda88be..b320fedd205 100644
--- a/mod/forum/version.php
+++ b/mod/forum/version.php
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002100300;
+$module->version = 2002101001;
$module->cron = 60;
?>