diff --git a/protected/humhub/modules/comment/widgets/CommentLink.php b/protected/humhub/modules/comment/widgets/CommentLink.php index 1e74ee8c32..9cce0f6fa0 100644 --- a/protected/humhub/modules/comment/widgets/CommentLink.php +++ b/protected/humhub/modules/comment/widgets/CommentLink.php @@ -50,22 +50,30 @@ class CommentLink extends Widget /** @var Module $module */ $module = Yii::$app->getModule('comment'); + + if ( + !$module->canComment($this->object) + || ( + CommentModel::isSubComment($this->object) + && !$module->canComment($this->object->content->getPolymorphicRelation()) + ) + ){ + return ''; + } if (empty($this->mode)) { $this->mode = self::MODE_INLINE; } - if ($module->canComment($this->object) || CommentModel::isSubComment($this->object) && $module->canComment($this->object->content->getPolymorphicRelation())){ - return $this->render('link', [ - 'id' => $this->object->getUniqueId(), - 'mode' => $this->mode, - 'objectModel' => get_class($this->object), - 'objectId' => $this->object->getPrimaryKey(), - 'commentCount' => CommentModel::GetCommentCount(get_class($this->object), $this->object->getPrimaryKey()), - 'isNestedComment' => ($this->object instanceof CommentModel), - 'comment' => $this->object, - 'module' => $module - ]); - } + return $this->render('link', [ + 'id' => $this->object->getUniqueId(), + 'mode' => $this->mode, + 'objectModel' => get_class($this->object), + 'objectId' => $this->object->getPrimaryKey(), + 'commentCount' => CommentModel::GetCommentCount(get_class($this->object), $this->object->getPrimaryKey()), + 'isNestedComment' => ($this->object instanceof CommentModel), + 'comment' => $this->object, + 'module' => $module + ]); } }