} $event = \mod_hsuforum\event\post_updated::create($params); $event->add_record_snapshot('hsuforum_discussions', $discussion); $event->trigger(); redirect(hsuforum_go_back_to("{$discussionurl}"), $message . $subscribemessage, $timemessage); exit; } else { if ($fromform->discussion) { // Adding a new post to an existing discussion // Before we add this we must check that the user will not exceed the blocking threshold. hsuforum_check_blocking_threshold($thresholdwarning); unset($fromform->groupid); $message = ''; $addpost = $fromform; $addpost->forum = $forum->id; if ($fromform->id = hsuforum_add_new_post($addpost, $mform_post, $message)) { $timemessage = 2; if (!empty($message)) { // if we're printing stuff about the file upload $timemessage = 4; } if ($subscribemessage = hsuforum_post_subscription($fromform, $forum)) { $timemessage = 4; } if (!empty($fromform->mailnow)) { $message .= get_string("postmailnow", "hsuforum"); $timemessage = 4; } else { $message .= '<p>' . get_string("postaddedsuccess", "hsuforum") . '</p>'; $message .= '<p>' . get_string("postaddedtimeleft", "hsuforum", format_time($CFG->maxeditingtime)) . '</p>'; }
/** * Save the post to the DB * * @param object $discussion * @param object $post * @param upload_file $uploader */ public function save_post($discussion, $post, upload_file $uploader) { $message = ''; // Because the following functions require these... $post->forum = $discussion->forum; $post->course = $discussion->course; $post->timestart = $discussion->timestart; $post->timeend = $discussion->timeend; if (!empty($post->id)) { hsuforum_update_post($post, null, $message, $uploader); } else { hsuforum_add_new_post($post, null, $message, $uploader); } }