Permalink
Browse files

Fixed HTML code in post.html (ported from HEAD) and some slightly

better checking of 'course' parameter to post.php.

None of this should really make a difference but it MAY help bug 2212
  • Loading branch information...
moodler
moodler committed Nov 23, 2004
1 parent 0e2d8f7 commit 86fad6838a3268b4a3bc509d56e47e6e58139236
Showing with 42 additions and 38 deletions.
  1. +28 −28 mod/forum/post.html
  2. +14 −10 mod/forum/post.php
View
@@ -1,23 +1,23 @@
<form name="theform" method="post" action="post.php" enctype="multipart/form-data">
<table border="0" cellpadding="5">
<tr valign="top">
- <td align=right><p><b><?php print_string("subject", "forum"); ?>:</b></p></td>
+ <td align="right"><b><?php print_string("subject", "forum"); ?>:</b></td>
<td>
- <input type="text" name="subject" size=60 value="<?php p($post->subject) ?>">
+ <input type="text" name="subject" size="60" value="<?php p($post->subject) ?>" alt="<?php print_string("subject", "forum"); ?>" />
</td>
</tr>
<tr valign="top">
- <td align=right><p><b>
+ <td align="right"><b>
<?php print_string("message", "forum"); ?>:
- </b></p></td>
- <td align=left rowspan=2>
+ </b></td>
+ <td align="left" rowspan="2">
<?php print_textarea($usehtmleditor, 25, 65, 630, 400, "message", $post->message); ?>
</td>
</tr>
<tr valign="top">
- <td align="right" valign="center" nowrap>
+ <td align="right" valign="middle" nowrap="nowrap">
- <font SIZE="1">
+ <font size="1">
<?php
helpbutton("reading", get_string("helpreading"), "moodle", true, true);
echo "<br />";
@@ -39,13 +39,13 @@
-<tr valign=top>
- <td align=right><p><b><?php print_string("formattexttype"); ?>:</b></p></td>
+<tr valign="top">
+ <td align="right"><b><?php print_string("formattexttype"); ?>:</b></td>
<td>
<?php
if ($usehtmleditor) { /// Trying this out for a while
print_string('formathtml');
- echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'">';
+ echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
} else {
choose_from_menu(format_text_menu(), "format", $post->format, "");
}
@@ -55,8 +55,8 @@
</tr>
-<tr valign=top>
- <td align=right><p><b><?php print_string("subscription", "forum") ?>:</b></p></td>
+<tr valign="top">
+ <td align="right"><b><?php print_string("subscription", "forum") ?>:</b></td>
<td>
<?php
if ($forum->forcesubscribe) {
@@ -85,15 +85,15 @@
<?php if ($forum->maxbytes != 1) { // 1 = No attachments at all ?>
-<tr valign=top>
- <td align=right><p><b><?php print_string("attachment", "forum") ?>:<br />(<?php print_string("optional") ?>)&nbsp;</b></p></td>
+<tr valign="top">
+ <td align="right"><b><?php print_string("attachment", "forum") ?>:<br />(<?php print_string("optional") ?>)&nbsp;</b></td>
<td>
<?php $maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes, $forum->maxbytes); ?>
- <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $maxbytes ?>">
- <input type="file" name="attachment" size=40>
- <?php
- helpbutton("attachment", get_string("attachment", "forum"), "forum");
- print_string("maxsize", "", display_size($maxbytes));
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $maxbytes ?>" />
+ <input type="file" name="attachment" size="40" alt="<?php print_string("attachment", "forum") ?>" />
+ <?php
+ helpbutton("attachment", get_string("attachment", "forum"), "forum");
+ print_string("maxsize", "", display_size($maxbytes));
?>
</td>
</tr>
@@ -102,15 +102,15 @@
<tr>
- <td align=center colspan=2>
- <input type="hidden" name=course value="<?php p($post->course) ?>">
- <input type="hidden" name=forum value="<?php p($post->forum) ?>">
- <input type="hidden" name=discussion value="<?php p($post->discussion) ?>">
- <input type="hidden" name=parent value="<?php p($post->parent) ?>">
- <input type="hidden" name=userid value="<?php p($post->userid) ?>">
- <input type="hidden" name=groupid value="<?php p($post->groupid) ?>">
- <input type="hidden" name=edit value="<?php p($post->edit) ?>">
- <input type="submit" value="<?php p(($post->edit) ? get_string('savechanges') : get_string('posttoforum', 'forum')); ?>">
+ <td align="center" colspan="2">
+ <input type="hidden" name="course" value="<?php p($post->course) ?>" />
+ <input type="hidden" name="forum" value="<?php p($post->forum) ?>" />
+ <input type="hidden" name="discussion" value="<?php p($post->discussion) ?>" />
+ <input type="hidden" name="parent" value="<?php p($post->parent) ?>" />
+ <input type="hidden" name="userid" value="<?php p($post->userid) ?>" />
+ <input type="hidden" name="groupid" value="<?php p($post->groupid) ?>" />
+ <input type="hidden" name="edit" value="<?php p($post->edit) ?>" />
+ <input type="submit" value="<?php p(($post->edit) ? get_string('savechanges') : get_string('posttoforum', 'forum')); ?>" />
</td>
</tr>
View
@@ -13,12 +13,16 @@
require_login(0, false); // Script is useless unless they're logged in
if ($post = data_submitted()) {
- if (!empty($post->course)) {
- if ($course = get_record('course', 'id', $post->course)) {
- if (!empty($course->lang)) {
- $CFG->courselang = $course->lang;
- }
- }
+ if (empty($post->course)) {
+ error('No course was defined!');
+ }
+
+ if (!$course = get_record('course', 'id', $post->course)) {
+ error('Could not find specified course!');
+ }
+
+ if (!empty($course->lang)) { // Override current language
+ $CFG->courselang = $course->lang;
}
if (empty($SESSION->fromurl)) {
@@ -33,7 +37,7 @@
$post->attachment = isset($_FILES['attachment']) ? $_FILES['attachment'] : NULL;
- if (!$cm = get_coursemodule_from_instance("forum", $post->forum, $post->course)) { // For the logs
+ if (!$cm = get_coursemodule_from_instance("forum", $post->forum, $course->id)) { // For the logs
$cm->id = 0;
}
@@ -44,7 +48,7 @@
$post->id = $post->edit;
if (forum_update_post($post)) {
- add_to_log($post->course, "forum", "update post",
+ add_to_log($course->id, "forum", "update post",
"discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id);
$message = get_string("postupdated", "forum");
@@ -63,7 +67,7 @@
} else if ($post->discussion) { // Adding a new post to an existing discussion
if ($post->id = forum_add_new_post($post)) {
- add_to_log($post->course, "forum", "add post",
+ add_to_log($course->id, "forum", "add post",
"discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id);
$message = get_string("postadded", "forum", format_time($CFG->maxeditingtime));
@@ -86,7 +90,7 @@
$discussion->intro = $post->message;
if ($discussion->id = forum_add_discussion($discussion)) {
- add_to_log($post->course, "forum", "add discussion",
+ add_to_log($course->id, "forum", "add discussion",
"discuss.php?d=$discussion->id", "$discussion->id", $cm->id);
$message = get_string("postadded", "forum", format_time($CFG->maxeditingtime));

0 comments on commit 86fad68

Please sign in to comment.