} // if user has edit any post capability // or has either startnewdiscussion or reply capability and is editting own post // then he can proceed // MDL-7066 if (!($realpost->userid == $USER->id && (has_capability('mod/forum:replypost', $modcontext) || has_capability('mod/forum:startdiscussion', $modcontext)) || has_capability('mod/forum:editanypost', $modcontext))) { print_error('cannotupdatepost', 'forum'); } // If the user has access to all groups and they are changing the group, then update the post. if ($contextcheck) { $DB->set_field('forum_discussions', 'groupid', $fromform->groupinfo, array('firstpost' => $fromform->id)); } $updatepost = $fromform; //realpost $updatepost->forum = $forum->id; if (!forum_update_post($updatepost, $mform_post, $message)) { print_error("couldnotupdate", "forum", $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("forum", $forum); } $timemessage = 2; if (!empty($message)) { // if we're printing stuff about the file upload $timemessage = 4; } $message .= '<br />' . get_string("postupdated", "forum");
$DB->set_field('forum_discussions', 'groupid', $fromform->groupinfo, array('firstpost' => $fromform->id)); } // When editing first post/discussion. if (!$fromform->parent) { if (has_capability('mod/forum:pindiscussions', $modcontext)) { // Can change pinned if we have capability. $fromform->pinned = !empty($fromform->pinned) ? FORUM_DISCUSSION_PINNED : FORUM_DISCUSSION_UNPINNED; } else { // We don't have the capability to change so keep to previous value. unset($fromform->pinned); } } $updatepost = $fromform; //realpost $updatepost->forum = $forum->id; if (!forum_update_post($updatepost, $mform_post)) { print_error("couldnotupdate", "forum", $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("forum", $forum); } if ($realpost->userid == $USER->id) { $message .= get_string("postupdated", "forum"); } else { $realuser = $DB->get_record('user', array('id' => $realpost->userid)); $message .= get_string("editedpostupdated", "forum", fullname($realuser)); }