From 0b51200b8c54c27f469d35e4f12f4ab58bfd7c4f Mon Sep 17 00:00:00 2001 From: buddh4 Date: Fri, 20 Oct 2017 20:48:13 +0200 Subject: [PATCH] Fixed wrong Comment date issue in notification mails --- .../humhub/modules/comment/models/Comment.php | 8 +++++--- .../notifications/views/mails/newComment.php | 16 ++++++++-------- .../components/ContentAddonActiveRecord.php | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/protected/humhub/modules/comment/models/Comment.php b/protected/humhub/modules/comment/models/Comment.php index bb05199113..42186e24fd 100644 --- a/protected/humhub/modules/comment/models/Comment.php +++ b/protected/humhub/modules/comment/models/Comment.php @@ -8,6 +8,7 @@ namespace humhub\modules\comment\models; +use humhub\modules\user\models\User; use Yii; use humhub\modules\post\models\Post; use humhub\modules\content\interfaces\ContentOwner; @@ -105,8 +106,6 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner /** * After Saving of comments, fire an activity - * - * @return type */ public function afterSave($insert, $changedAttributes) { @@ -123,6 +122,9 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner $followers = $this->getCommentedRecord()->getFollowers(null, true); $this->filterMentionings($followers, $mentionedUsers); + // Update updated_at etc.. + $this->refresh(); + \humhub\modules\comment\notifications\NewComment::instance() ->from(Yii::$app->user->getIdentity()) ->about($this) @@ -140,7 +142,7 @@ class Comment extends ContentAddonActiveRecord implements ContentOwner $this->updateContentSearch(); - return parent::afterSave($insert, $changedAttributes); + parent::afterSave($insert, $changedAttributes); } /** diff --git a/protected/humhub/modules/comment/notifications/views/mails/newComment.php b/protected/humhub/modules/comment/notifications/views/mails/newComment.php index 904c97f074..46b166adcd 100644 --- a/protected/humhub/modules/comment/notifications/views/mails/newComment.php +++ b/protected/humhub/modules/comment/notifications/views/mails/newComment.php @@ -6,12 +6,12 @@ /* @var $isNew boolean */ /* @var $isNew boolean */ /* @var $originator \humhub\modules\user\models\User */ -/* @var source yii\db\ActiveRecord */ -/* @var contentContainer \humhub\modules\content\components\ContentContainerActiveRecord */ -/* @var space humhub\modules\space\models\Space */ -/* @var record \humhub\modules\notification\models\Notification */ -/* @var html string */ -/* @var text string */ +/* @var $source yii\db\ActiveRecord */ +/* @var $contentContainer \humhub\modules\content\components\ContentContainerActiveRecord */ +/* @var $space humhub\modules\space\models\Space */ +/* @var $record \humhub\modules\notification\models\Notification */ +/* @var $html string */ +/* @var $text string */ ?> beginContent('@notification/views/layouts/mail.php', $_params_); ?> @@ -25,7 +25,7 @@ humhub\widgets\mails\MailCommentEntry::widget([ 'originator' => $originator, 'comment' => $comment, - 'date' => $date, + 'date' => $comment->updated_at, 'space' => $space ]); ?> @@ -51,7 +51,7 @@ humhub\widgets\mails\MailContentEntry::widget([ 'originator' => $contentRecord->owner, 'content' => $contentRecord, - 'date' => $date, + 'date' => $contentRecord->content->updated_at, 'space' => $space ]); ?> diff --git a/protected/humhub/modules/content/components/ContentAddonActiveRecord.php b/protected/humhub/modules/content/components/ContentAddonActiveRecord.php index 45b7f69429..5aeb3d0aa3 100644 --- a/protected/humhub/modules/content/components/ContentAddonActiveRecord.php +++ b/protected/humhub/modules/content/components/ContentAddonActiveRecord.php @@ -202,7 +202,7 @@ class ContentAddonActiveRecord extends ActiveRecord implements ContentOwner $this->getSource()->content->updateStreamSortTime(); } - return parent::afterSave($insert, $changedAttributes); + parent::afterSave($insert, $changedAttributes); } public function getUser()