From 52cb014ea357c8c074caf286d197efd463f854c9 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 19 Feb 2013 11:11:40 +0800 Subject: [PATCH] MDL-31636 Comments - Call display callback when adding a new comment. --- comment/lib.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/comment/lib.php b/comment/lib.php index c423ef16b7e..9ca0a412ee1 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -530,7 +530,6 @@ class comment { $url = new moodle_url('/user/view.php', array('id'=>$u->id, 'course'=>$this->courseid)); $c->profileurl = $url->out(false); $c->fullname = fullname($u); - $c->time = userdate($c->timecreated, get_string('strftimerecent', 'langconfig')); $c->content = format_text($c->content, $c->format, $formatoptions); $c->avatar = $OUTPUT->user_picture($u, array('size'=>18)); @@ -629,12 +628,27 @@ class comment { $cmt_id = $DB->insert_record('comments', $newcmt); if (!empty($cmt_id)) { $newcmt->id = $cmt_id; - $newcmt->time = userdate($now, get_string('strftimerecent', 'langconfig')); + $newcmt->strftimeformat = get_string('strftimerecent', 'langconfig'); $newcmt->fullname = fullname($USER); $url = new moodle_url('/user/view.php', array('id' => $USER->id, 'course' => $this->courseid)); $newcmt->profileurl = $url->out(); $newcmt->content = format_text($newcmt->content, $format, array('overflowdiv'=>true)); $newcmt->avatar = $OUTPUT->user_picture($USER, array('size'=>16)); + + $commentlist = array($newcmt); + + if (!empty($this->plugintype)) { + // Call the display callback to allow the plugin to format the newly added comment. + $commentlist = plugin_callback($this->plugintype, + $this->pluginname, + 'comment', + 'display', + array($commentlist, $this->comment_param), + $commentlist); + $newcmt = $commentlist[0]; + } + $newcmt->time = userdate($newcmt->timecreated, $newcmt->strftimeformat); + return $newcmt; } else { throw new comment_exception('dbupdatefailed'); -- 2.43.0