forked from ersten/humhub-module-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CkMapModuleEvents.php
99 lines (80 loc) · 3.63 KB
/
CkMapModuleEvents.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
class CkMapModuleEvents
{
public static function onTopMenuInit($event)
{
$user = Yii::app()->user->getModel();
// if( $user->isModuleEnabled( 'k_map' ) )
{
$event->sender->addItem( array(
'label' => Yii::t('CkMapModule.base', 'Map'),
// 'url' => Yii::app()->createUrl( '//map/global/index', array( 'uguid' => Yii::app()->user->guid ) ),
'url' => Yii::app()->createUrl( '//map', array( 'uguid' => Yii::app()->user->guid ) ),
'icon' => '<i class="fa fa-calendar"></i>',
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'map' && Yii::app()->controller->id == 'global'),
'sortOrder' => 300,
));
}
}
public static function onSpaceMenuInit($event)
{
$space = Yii::app()->getController()->getSpace();
if ($space->isModuleEnabled('calendar')) {
$event->sender->addItem(array(
'label' => Yii::t('CkMapModule.base', 'Map'),
'url' => Yii::app()->createUrl('//calendar/view/index', array('sguid' => $space->guid)),
'icon' => '<i class="fa fa-calendar"></i>',
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'calendar'),
));
}
}
public static function onProfileMenuInit($event)
{
$user = Yii::app()->getController()->getUser();
// Is Module enabled on this workspace?
if ($user->isModuleEnabled('calendar')) {
$event->sender->addItem(array(
'label' => Yii::t('CkMapModule.base', 'Map'),
'url' => Yii::app()->createUrl('//calendar/view/index', array('uguid' => $user->guid)),
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'calendar'),
));
}
}
public static function onSpaceSidebarInit($event)
{
$space = null;
if (isset(Yii::app()->params['currentSpace'])) {
$space = Yii::app()->params['currentSpace'];
}
if (Yii::app()->getController() instanceof ContentContainerController && Yii::app()->getController()->contentContainer instanceof Space) {
$space = Yii::app()->getController()->contentContainer;
}
if ($space != null) {
if ($space->isModuleEnabled('calendar')) {
$event->sender->addWidget('application.modules.calendar.widgets.NextEventsSidebarWidget', array('contentContainer' => $space), array('sortOrder' => 550));
}
}
}
public static function onDashboardSidebarInit($event)
{
$user = Yii::app()->user->getModel();
if ($user->isModuleEnabled('calendar')) {
$event->sender->addWidget('application.modules.calendar.widgets.NextEventsSidebarWidget', array(), array('sortOrder' => 550));
}
}
public static function onProfileSidebarInit($event)
{
$user = null;
if (isset(Yii::app()->params['currentUser'])) {
$user = Yii::app()->params['currentUser'];
}
if (Yii::app()->getController() instanceof ContentContainerController && Yii::app()->getController()->contentContainer instanceof User) {
$user = Yii::app()->getController()->contentContainer;
}
if ($user != null) {
if ($user->isModuleEnabled('calendar')) {
$event->sender->addWidget('application.modules.calendar.widgets.NextEventsSidebarWidget', array('contentContainer' => $user), array('sortOrder' => 550));
}
}
}
}