From 9bdedea400e4bbd7d55a1989b348d0860f6111a6 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 5 Apr 2006 02:15:10 +0000 Subject: [PATCH] Changed how the "edited by" message appears in the posts edited by admin --- mod/forum/lib.php | 12 ------- mod/forum/post.php | 90 ++++++++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index a578445438..96ef8c57a5 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -2468,18 +2468,6 @@ function forum_update_post($post,&$message) { $post->modified = time(); - if ($USER->id != $post->userid) { // Not the original author - $data->name = ''. - fullname($USER).''; - $data->date = userdate($post->modified); - $editedby = get_string('editedby', 'forum', $data); - if ($post->format == FORMAT_HTML) { - $post->message .= '

('.$editedby.')

'; - } else { - $post->message .= "\n\n(".$editedby.')'; - } - } - if (!$post->parent) { // Post is a discussion starter - update discussion title too set_field("forum_discussions", "name", $post->subject, "id", $post->discussion); } diff --git a/mod/forum/post.php b/mod/forum/post.php index 39249e6f42..b2bd7091db 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -103,7 +103,7 @@ } if ($realpost->userid <> $USER->id && !isadmin()){ - error ("you can not update this post"); + error("You can not update this post"); } if (get_field('forum', 'type', 'id', $forum) == 'news' && !$post->parent) { @@ -124,28 +124,29 @@ error(get_string("couldnotupdate", "forum"), $errordestination); } } + if (!isset($post->error)) { - if (forum_update_post($post,$message)) { + if (forum_update_post($post,$message)) { - add_to_log($course->id, "forum", "update post", - "discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id); + add_to_log($course->id, "forum", "update post", + "discuss.php?d=$post->discussion&parent=$post->id", "$post->id", $cm->id); - $timemessage = 2; - if (!empty($message)) { // if we're printing stuff about the file upload - $timemessage = 4; - } - $message .= '
'.get_string("postupdated", "forum"); + $timemessage = 2; + if (!empty($message)) { // if we're printing stuff about the file upload + $timemessage = 4; + } + $message .= '
'.get_string("postupdated", "forum"); - if ($subscribemessage = forum_post_subscription($post)) { - $timemessage = 4; - } - redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage); + if ($subscribemessage = forum_post_subscription($post)) { + $timemessage = 4; + } + redirect(forum_go_back_to("discuss.php?d=$post->discussion#$post->id"), $message.$subscribemessage, $timemessage); - } else { - error(get_string("couldnotupdate", "forum"), $errordestination); - } - exit; + } else { + error(get_string("couldnotupdate", "forum"), $errordestination); + } + exit; } } else if ($post->discussion) { // Adding a new post to an existing discussion @@ -199,35 +200,34 @@ if ($newstopic && empty($post->timeenddisabled) && $discussion->timeend <= $discussion->timestart) { $post->error = get_string('timestartenderror', 'forum'); } else { + $message = ''; + if ($discussion->id = forum_add_discussion($discussion,$message)) { - $message = ''; - if ($discussion->id = forum_add_discussion($discussion,$message)) { - - add_to_log($course->id, "forum", "add discussion", - "discuss.php?d=$discussion->id", "$discussion->id", $cm->id); + add_to_log($course->id, "forum", "add discussion", + "discuss.php?d=$discussion->id", "$discussion->id", $cm->id); - $timemessage = 2; - if (!empty($message)) { // if we're printing stuff about the file upload - $timemessage = 4; - } - $message .= '
'.get_string("postadded", "forum", format_time($CFG->maxeditingtime)); + $timemessage = 2; + if (!empty($message)) { // if we're printing stuff about the file upload + $timemessage = 4; + } + $message .= '
'.get_string("postadded", "forum", format_time($CFG->maxeditingtime)); - if ($post->mailnow) { - $message .= get_string("postmailnow", "forum"); - $timemessage = 4; - } + if ($post->mailnow) { + $message .= get_string("postmailnow", "forum"); + $timemessage = 4; + } - if ($subscribemessage = forum_post_subscription($discussion)) { - $timemessage = 4; - } + if ($subscribemessage = forum_post_subscription($discussion)) { + $timemessage = 4; + } - redirect(forum_go_back_to("view.php?f=$post->forum"), $message.$subscribemessage, $timemessage); + redirect(forum_go_back_to("view.php?f=$post->forum"), $message.$subscribemessage, $timemessage); - } else { - error(get_string("couldnotadd", "forum"), $errordestination); - } + } else { + error(get_string("couldnotadd", "forum"), $errordestination); + } - exit; + exit; } } } @@ -694,6 +694,18 @@ } echo ''; + if ($USER->id != $post->userid) { // Not the original author, so add a message to the end + $data->date = userdate($post->modified); + if ($post->format == FORMAT_HTML) { + $data->name = ''. + fullname($USER).''; + $post->message .= '

('.get_string('editedby', 'forum', $data).')

'; + } else { + $data->name = fullname($USER); + $post->message .= "\n\n(".get_string('editedby', 'forum', $data).')'; + } + } + print_simple_box_start("center"); require("post.html"); print_simple_box_end(); -- 2.39.5