-
Notifications
You must be signed in to change notification settings - Fork 3
/
Events.php
60 lines (51 loc) · 1.48 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace themroc\humhub\modules\mail_in;
use Yii;
use yii\helpers\Url;
use humhub\components\console\Application;
use themroc\humhub\modules\mail_in\widgets\Sidebar;
class Events
{
public static function onConsoleApplicationInit($event)
{
$application= $event->sender;
$application->controllerMap['mail_in'] = commands\ConsoleController::class;
}
/**
* Defines what to do if admin menu is initialized.
*
* @param $event
*/
public static function onAdminMenuInit($event)
{
if (Yii::$app->user->isGuest || empty($event) || empty($event->sender))
return;
$event->sender->addItem([
'group'=> 'manage',
'label'=> 'Mail in',
'url'=> Url::to(['/mail_in/admin']),
'icon'=> '<i class="fa fa-envelope-o"></i>',
'isActive'=> (Yii::$app->controller->module && Yii::$app->controller->module->id == 'mail_in' && Yii::$app->controller->id == 'admin'),
'sortOrder'=> 90000,
]);
}
/**
* Defines what to do if space sidebar is initialized.
*
* @param $event
*/
public static function onSidebarInit($event)
{
if (Yii::$app->user->isGuest || empty($event) || empty($event->sender))
return;
$space = $event->sender->space;
if (empty($space) || ! $space->isModuleEnabled('mail_in') || ! $space->getSetting('showaddr', 'mail_in'))
return;
$event->sender->addWidget(Sidebar::className(), [
'address'=> $space->getSetting('address', 'mail_in'),
'title'=> 'Space',
], [
'sortOrder'=> $space->getSetting('sortorder', 'mail_in'),
]);
}
}