mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 14:18:27 +01:00
Fix #4743: LikeLink also when no CanLike permission
This commit is contained in:
parent
44237e1eaf
commit
5d2db8ad73
@ -12,6 +12,7 @@ HumHub Changelog
|
|||||||
- Fix #4649: Success message rendered although password validation failed
|
- Fix #4649: Success message rendered although password validation failed
|
||||||
- Fix #4717: Repsonsive layout alignment issue on small screens
|
- Fix #4717: Repsonsive layout alignment issue on small screens
|
||||||
- Fix #4715: Call to `Content::canArchive()` throws error on global content
|
- Fix #4715: Call to `Content::canArchive()` throws error on global content
|
||||||
|
- Fix #4743: Hide "Like" link when no permission "Can like"
|
||||||
|
|
||||||
|
|
||||||
1.7.1 (November 27, 2020)
|
1.7.1 (November 27, 2020)
|
||||||
|
@ -92,10 +92,6 @@ class Events extends \yii\base\BaseObject
|
|||||||
*/
|
*/
|
||||||
public static function onWallEntryLinksInit($event)
|
public static function onWallEntryLinksInit($event)
|
||||||
{
|
{
|
||||||
if (!static::getModule()->isEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$event->sender->addWidget(widgets\LikeLink::class, ['object' => $event->sender->object], ['sortOrder' => 10]);
|
$event->sender->addWidget(widgets\LikeLink::class, ['object' => $event->sender->object], ['sortOrder' => 10]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@ use yii\helpers\Html;
|
|||||||
use humhub\modules\like\Module;
|
use humhub\modules\like\Module;
|
||||||
use humhub\modules\like\models\Like as LikeModel;
|
use humhub\modules\like\models\Like as LikeModel;
|
||||||
use humhub\modules\content\components\ContentActiveRecord;
|
use humhub\modules\content\components\ContentActiveRecord;
|
||||||
|
use humhub\modules\content\components\ContentContainerActiveRecord;
|
||||||
|
use humhub\modules\like\permissions\CanLike;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This widget is used to show a like link inside the wall entry controls.
|
* This widget is used to show a like link inside the wall entry controls.
|
||||||
*
|
*
|
||||||
@ -24,15 +27,26 @@ class LikeLink extends \yii\base\Widget
|
|||||||
*/
|
*/
|
||||||
public $object;
|
public $object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
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)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::beforeRun();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the widget.
|
* Executes the widget.
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
if (Yii::$app->getModule('like')->isEnabled === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$currentUserLiked = false;
|
$currentUserLiked = false;
|
||||||
/** @var Module $module */
|
/** @var Module $module */
|
||||||
$module = Yii::$app->getModule('like');
|
$module = Yii::$app->getModule('like');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user