-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEvents.php
40 lines (33 loc) · 1.15 KB
/
Events.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*
*/
namespace humhub\modules\subscriptions;
use Yii;
use yii\base\BaseObject;
use humhub\modules\subscriptions\models\SnippetModuleSettings;
use humhub\modules\subscriptions\widgets\Subscribers;
use humhub\modules\subscriptions\permissions\ViewWidget;
/*
* @var $user \humhub\modules\user\models\User
* @author David Born ([staxDB](https://github.com/staxDB))
*/
class Events extends BaseObject
{
public static function onSpaceSidebarInit($event)
{
if (Yii::$app->user->isGuest) {
return;
}
$space = $event->sender->space;
$settings = SnippetModuleSettings::instantiate();
if ($space->isModuleEnabled('subscriptions')) {
if ($space->permissionManager->can(ViewWidget::class)) {
$event->sender->addWidget(Subscribers::class, ['maxSubscribers' => $settings->mySubscribersSnippetMaxItems, 'space' => $space], ['sortOrder' => $settings->mySubscribersSnippetSortOrder]);
}
}
}
}