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;
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)
"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"
$output .= "</DIV>";
}
- $output .= text_to_html($post->message);
+ $output .= format_text($post->message, $post->format);
$output .= "<P ALIGN=right><FONT SIZE=-1>";
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 "<A HREF=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion\">";
echo get_string("readtherest", "forum");
echo "</A> (".get_string("numwords", "", $numwords).")...";
} else {
// Print whole message
- echo text_to_html($post->message);
+ echo format_text($post->message, $post->format);
}
echo "<P ALIGN=right><FONT SIZE=-1>";
-<form name="form" method="post" action="post.php" enctype="multipart/form-data">
+<form name="theform" method="post" action="post.php" <?=$onsubmit ?> enctype="multipart/form-data">
<table cellpadding=5>
<tr valign=top>
<td align=right><P><B><? print_string("subject", "forum"); ?>:</B></P></TD>
<tr valign=top>
<td align=right><P><B><? print_string("message", "forum"); ?>:</B><BR><BR><? helpbutton("text", get_string("helptext")) ?></P></TD>
<td>
- <textarea name=message rows=15 cols=50 wrap="virtual"><? p($post->message) ?></textarea>
+ <? if ($usehtmleditor) { ?>
+ <object id="richedit" style="BACKGROUND-COLOR: buttonface" data="../../lib/rte/richedit.html"
+ width="595" height="400" type="text/x-scriptlet" VIEWASTEXT>
+ </object>
+ <TEXTAREA style="display:none" NAME="message" ROWS=1 COLS=50><? p($post->message) ?></TEXTAREA>
+ <? } else { ?>
+ <TEXTAREA name=message rows=15 cols=50 wrap="virtual"><? p($post->message) ?></TEXTAREA>
+ <? } ?>
+
</td>
<td rowspan=2>
<FONT SIZE=1>
</FONT>
</td>
</tr>
+<tr valign=top>
+ <td align=right><P><B><? print_string("formattexttype"); ?>:</B></P></TD>
+ <td>
+ <?PHP
+ $POST_FORMATS = format_text_menu();
+ choose_from_menu($POST_FORMATS, "format", $post->format, ""); ?>
+ </td>
+ <td>
+
+ </td>
+</tr>
<tr valign=top>
<td><P><B><? print_string("attachment", "forum") ?>:<BR>(<? print_string("optional") ?>)</B></P></td>
<td>
<tr valign=top>
</table>
</FORM>
+
+<? if ($usehtmleditor) { ?>
+ <SCRIPT language="JavaScript" event="onload" for="window">
+ document.richedit.options = "history=no;source=no";
+ document.richedit.docHtml = theform.message.innerText;
+ </SCRIPT>
+<? } ?>
+
$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"];
$strforums = get_string("modulenameplural", "forum");
+ if ($usehtmleditor = can_use_richtext_editor()) {
+ $onsubmit = "onsubmit=\"copyrichtext(theform.message);\"";
+ }
+
$navmiddle = "<A HREF=\"../forum/index.php?id=$course->id\">$strforums</A> -> <A HREF=\"view.php?f=$forum->id\">$forum->name</A>";
if ($course->category) {
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002100300;
+$module->version = 2002101001;
$module->cron = 60;
?>