diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 1f6160deae2..5b08c41b4e8 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -4354,16 +4354,13 @@ function forum_add_attachment($post, $forum, $cm, $mform=null, $unused=null) { /** * Add a new post in an existing discussion. * - * @global object - * @global object - * @global object - * @param object $post - * @param mixed $mform - * @param string $unused formerly $message, renamed in 2.8 as it was unused. + * @param stdClass $post The post data + * @param mixed $mform The submitted form + * @param string $unused * @return int */ function forum_add_new_post($post, $mform, $unused = null) { - global $USER, $CFG, $DB; + global $USER, $DB; $discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion)); $forum = $DB->get_record('forum', array('id' => $discussion->forum)); @@ -4402,18 +4399,15 @@ function forum_add_new_post($post, $mform, $unused = null) { } /** - * Update a post + * Update a post. * - * @global object - * @global object - * @global object - * @param object $post - * @param mixed $mform - * @param string $message - * @return bool + * @param stdClass $post The post to update + * @param mixed $mform The submitted form + * @param string $unused + * @return bool */ -function forum_update_post($post, $mform, &$message) { - global $USER, $CFG, $DB; +function forum_update_post($post, $mform, $unused = null) { + global $DB; $discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion)); $forum = $DB->get_record('forum', array('id' => $discussion->forum)); @@ -4442,7 +4436,7 @@ function forum_update_post($post, $mform, &$message) { $DB->update_record('forum_discussions', $discussion); - forum_add_attachment($post, $forum, $cm, $mform, $message); + forum_add_attachment($post, $forum, $cm, $mform); if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) { forum_tp_mark_post_read($post->userid, $post, $post->forum); diff --git a/mod/forum/post.php b/mod/forum/post.php index 653fe365ee8..1933800e6fe 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -729,7 +729,7 @@ if ($mform_post->is_cancelled()) { } $updatepost = $fromform; //realpost $updatepost->forum = $forum->id; - if (!forum_update_post($updatepost, $mform_post, $message)) { + if (!forum_update_post($updatepost, $mform_post)) { print_error("couldnotupdate", "forum", $errordestination); } @@ -741,10 +741,10 @@ if ($mform_post->is_cancelled()) { } if ($realpost->userid == $USER->id) { - $message .= '
'.get_string("postupdated", "forum"); + $message .= get_string("postupdated", "forum"); } else { $realuser = $DB->get_record('user', array('id' => $realpost->userid)); - $message .= '
'.get_string("editedpostupdated", "forum", fullname($realuser)); + $message .= get_string("editedpostupdated", "forum", fullname($realuser)); } $subscribemessage = forum_post_subscription($fromform, $forum, $discussion); @@ -790,7 +790,7 @@ if ($mform_post->is_cancelled()) { $message = ''; $addpost = $fromform; $addpost->forum=$forum->id; - if ($fromform->id = forum_add_new_post($addpost, $mform_post, $message)) { + if ($fromform->id = forum_add_new_post($addpost, $mform_post)) { $subscribemessage = forum_post_subscription($fromform, $forum, $discussion); if (!empty($fromform->mailnow)) { @@ -903,7 +903,7 @@ if ($mform_post->is_cancelled()) { $discussion->groupid = $group; $message = ''; - if ($discussion->id = forum_add_discussion($discussion, $mform_post, $message)) { + if ($discussion->id = forum_add_discussion($discussion, $mform_post)) { $params = array( 'context' => $modcontext,