-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Events.php
43 lines (35 loc) · 1.26 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
41
42
43
<?php
namespace humhub\modules\adsense;
use Yii;
use yii\helpers\Url;
use humhub\modules\ui\menu\MenuLink;
use humhub\modules\ui\icon\widgets\Icon;
use humhub\modules\admin\widgets\AdminMenu;
use humhub\modules\user\helpers\AuthHelper;
use humhub\modules\admin\permissions\ManageModules;
class Events
{
public static function onAdminMenuInit($event)
{
if (!Yii::$app->user->can(ManageModules::class)) {
return;
}
/** @var AdminMenu $menu */
$menu = $event->sender;
$menu->addEntry(new MenuLink([
'label' => Yii::t('AdsenseModule.base', 'AdSense Settings'),
'url' => Url::toRoute('/adsense/admin/index'),
'icon' => Icon::get('google'),
'isActive' => Yii::$app->controller->module && Yii::$app->controller->module->id == 'adsense' && Yii::$app->controller->id == 'admin',
'sortOrder' => 650,
'isVisible' => true,
]));
}
public static function addAdFrame($event)
{
if (Yii::$app->user->isGuest || Yii::$app->user->identity && AuthHelper::isGuestAccessEnabled())
{
$event->sender->addWidget(widgets\AdFrame::class, [], ['sortOrder' => Yii::$app->getModule('adsense')->settings->get('sort')]);
}
}
}