// then he can proceed // MDL-7066 if (!($realpost->userid == $USER->id && (has_capability('mod/hsuforum:replypost', $modcontext) || has_capability('mod/hsuforum:startdiscussion', $modcontext)) || has_capability('mod/hsuforum:editanypost', $modcontext))) { print_error('cannotupdatepost', 'hsuforum'); } // If the user has access to all groups and they are changing the group, then update the post. if ($contextcheck) { if (empty($fromform->groupinfo)) { $fromform->groupinfo = -1; } $DB->set_field('hsuforum_discussions', 'groupid', $fromform->groupinfo, array('firstpost' => $fromform->id)); } $updatepost = $fromform; //realpost $updatepost->forum = $forum->id; if (!hsuforum_update_post($updatepost, $mform_post, $message)) { print_error("couldnotupdate", "hsuforum", $errordestination); } // MDL-11818 if ($forum->type == 'single' && $updatepost->parent == '0') { // updating first post of single discussion type -> updating forum intro $forum->intro = $updatepost->message; $forum->timemodified = time(); $DB->update_record("hsuforum", $forum); } $timemessage = 2; if (!empty($message)) { // if we're printing stuff about the file upload $timemessage = 4; } if ($realpost->userid == $USER->id) {
/** * 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); } }