Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31636 Comments - Call display callback when adding a new comment.

  • Loading branch information...
commit e3f6d84b15e70429cea2702b11eef79dc16f887b 1 parent 86c1de4
Damyon Wiese damyon authored

Showing 1 changed file with 16 additions and 2 deletions. Show diff stats Hide diff stats

  1. +16 2 comment/lib.php
18 comment/lib.php
@@ -530,7 +530,6 @@ public function get_comments($page = '') {
530 530 $url = new moodle_url('/user/view.php', array('id'=>$u->id, 'course'=>$this->courseid));
531 531 $c->profileurl = $url->out(false);
532 532 $c->fullname = fullname($u);
533   - $c->time = userdate($c->timecreated, get_string('strftimerecent', 'langconfig'));
534 533 $c->content = format_text($c->content, $c->format, $formatoptions);
535 534 $c->avatar = $OUTPUT->user_picture($u, array('size'=>18));
536 535
@@ -629,12 +628,27 @@ public function add($content, $format = FORMAT_MOODLE) {
629 628 $cmt_id = $DB->insert_record('comments', $newcmt);
630 629 if (!empty($cmt_id)) {
631 630 $newcmt->id = $cmt_id;
632   - $newcmt->time = userdate($now, get_string('strftimerecent', 'langconfig'));
  631 + $newcmt->strftimeformat = get_string('strftimerecent', 'langconfig');
633 632 $newcmt->fullname = fullname($USER);
634 633 $url = new moodle_url('/user/view.php', array('id' => $USER->id, 'course' => $this->courseid));
635 634 $newcmt->profileurl = $url->out();
636 635 $newcmt->content = format_text($newcmt->content, $format, array('overflowdiv'=>true));
637 636 $newcmt->avatar = $OUTPUT->user_picture($USER, array('size'=>16));
  637 +
  638 + $commentlist = array($newcmt);
  639 +
  640 + if (!empty($this->plugintype)) {
  641 + // Call the display callback to allow the plugin to format the newly added comment.
  642 + $commentlist = plugin_callback($this->plugintype,
  643 + $this->pluginname,
  644 + 'comment',
  645 + 'display',
  646 + array($commentlist, $this->comment_param),
  647 + $commentlist);
  648 + $newcmt = $commentlist[0];
  649 + }
  650 + $newcmt->time = userdate($newcmt->timecreated, $newcmt->strftimeformat);
  651 +
638 652 return $newcmt;
639 653 } else {
640 654 throw new comment_exception('dbupdatefailed');

0 comments on commit e3f6d84

Please sign in to comment.
Something went wrong with that request. Please try again.