Enh #5741: Possibility to Like global contents (#5743)

* Enh #5741: Possibility to Like global contents

* Enh #5741: Possibility to Like global contents

Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
Marc Farré 2022-06-02 21:40:19 +02:00 committed by GitHub
parent e10f7854c0
commit 74b54d4112
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 9 deletions

View File

@ -4,3 +4,4 @@
- Enh #3593: Allow SSO provider to register and auto create username on registration
- Enh #5695: Truncate long profile texts in People cards
- Enh #5602: Added API to inject additional validation rules by modules on demand
- Enh #5741: Possibility to Like global contents

View File

@ -85,11 +85,7 @@ class Module extends \humhub\components\Module
{
$content = $object->content;
if(!isset($content->container)) {
return false;
}
if (!$content->container->can(new permissions\CanLike())) {
if (isset($content->container) && !$content->container->can(new permissions\CanLike())) {
return false;
}

View File

@ -32,10 +32,14 @@ class LikeLink extends \yii\base\Widget
*/
public function beforeRun()
{
if (!Yii::$app->getModule('like')->isEnabled ||
!isset($this->object->content->container) ||
!($this->object->content->container instanceof ContentContainerActiveRecord) ||
!$this->object->content->container->can(CanLike::class)) {
if (
!Yii::$app->getModule('like')->isEnabled ||
(
isset($this->object->content->container) &&
$this->object->content->container instanceof ContentContainerActiveRecord &&
!$this->object->content->container->can(CanLike::class)
)
) {
return false;
}