diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index 1d9f981c57..c8208508d3 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -6,6 +6,7 @@ HumHub Change Log ------------------------- - Fix #3647: GroupID field is not translatable in Registration Form +- Fix #3655: Fix CommentLink widget Comment class usage conflict 1.3.15 (August 22, 2019) diff --git a/protected/humhub/modules/comment/widgets/CommentLink.php b/protected/humhub/modules/comment/widgets/CommentLink.php index ffe5c3604a..6de09e8a2f 100644 --- a/protected/humhub/modules/comment/widgets/CommentLink.php +++ b/protected/humhub/modules/comment/widgets/CommentLink.php @@ -8,7 +8,10 @@ namespace humhub\modules\comment\widgets; -use humhub\modules\comment\models\Comment; +use humhub\components\ActiveRecord; +use humhub\components\Widget; +use humhub\modules\comment\models\Comment as CommentModel; +use humhub\modules\comment\Module; use Yii; /** @@ -16,14 +19,14 @@ use Yii; * * @since 0.5 */ -class CommentLink extends \yii\base\Widget +class CommentLink extends Widget { const MODE_INLINE = 'inline'; const MODE_POPUP = 'popup'; /** - * Content Object + * @var ActiveRecord */ public $object; @@ -33,22 +36,26 @@ class CommentLink extends \yii\base\Widget * inline: Show comments on the same page with CommentsWidget (default) * popup: Open comments popup, display only link * - * @var type + * @var string */ public $mode; + /** - * Executes the widget. + * @inheritDoc */ public function run() { + /** @var Module $module */ + $module = Yii::$app->getModule('comment'); + if ($this->mode == "") { $this->mode = self::MODE_INLINE; } - if (!Yii::$app->getModule('comment')->canComment($this->object->content)) { - return; + if (!$module->canComment($this->object->content)) { + return ''; } return $this->render('link', [ @@ -62,11 +69,11 @@ class CommentLink extends \yii\base\Widget /** * Returns count of existing comments * - * @return Int Comment Count + * @return Int the total amount of comments */ public function getCommentsCount() { - return Comment::GetCommentCount(get_class($this->object), $this->object->getPrimaryKey()); + return CommentModel::GetCommentCount(get_class($this->object), $this->object->getPrimaryKey()); } }