/**
* 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));
}
/**
- * 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));
$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);
}
return false;
}
+
+/**
+ * Manage inplace editable saves.
+ *
+ * @param string $itemtype The type of item.
+ * @param int $itemid The ID of the item.
+ * @param mixed $newvalue The new value
+ * @return string
+ */
+function mod_forum_inplace_editable($itemtype, $itemid, $newvalue) {
+ global $DB, $PAGE;
+
+ if ($itemtype === 'digestoptions') {
+ // The itemid is the forumid.
+ $forum = $DB->get_record('forum', array('id' => $itemid), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $forum->course), '*', MUST_EXIST);
+ $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
+ $context = context_module::instance($cm->id);
+
+ $PAGE->set_context($context);
+ require_login($course, false, $cm);
+ forum_set_user_maildigest($forum, $newvalue);
+
+ $renderer = $PAGE->get_renderer('mod_forum');
+ return $renderer->render_digest_options($forum, $newvalue);
+ }
+}