-
Notifications
You must be signed in to change notification settings - Fork 5
/
CalendarPlusModuleEvents.php
executable file
·138 lines (113 loc) · 4.88 KB
/
CalendarPlusModuleEvents.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
/**
* HumHub
* Copyright © 2014 The HumHub Project
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*/
/**
* Description of CalendarEvents
*
* @author luke
*/
class CalendarPlusModuleEvents
{
public static function onTopMenuInit($event)
{
if (Yii::app()->user->isGuest) {
return;
}
$user = Yii::app()->user->getModel();
if ($user->isModuleEnabled('calendarplus')) {
$event->sender->addItem(array(
'label' => Yii::t('CalendarPlusModule.base', 'Calendar'),
'url' => Yii::app()->createUrl('//calendarplus/global/index', array('uguid' => Yii::app()->user->guid)),
'icon' => '<i class="fa fa-calendar"></i>',
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'calendarplus' && Yii::app()->controller->id == 'global'),
'sortOrder' => 300,
));
}
}
public static function onSpaceMenuInit($event)
{
$space = Yii::app()->getController()->getSpace();
if ($space->isModuleEnabled('calendarplus')) {
$event->sender->addItem(array(
'label' => Yii::t('CalendarPlusModule.base', 'Calendar'),
'group' => 'modules',
'url' => Yii::app()->createUrl('//calendarplus/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('calendarplus')) {
$event->sender->addItem(array(
'label' => Yii::t('CalendarPlusModule.base', 'Calendar'),
'url' => Yii::app()->createUrl('//calendarplus/view/index', array('uguid' => $user->guid)),
'isActive' => (Yii::app()->controller->module && Yii::app()->controller->module->id == 'calendar'),
));
}
}
public static function onSpaceSidebarInit($event)
{
if (Yii::app()->user->isGuest) {
return;
}
$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('calendarplus')) {
$event->sender->addWidget('application.modules.calendarplus.widgets.NextEventsSidebarWidget', array('contentContainer' => $space), array('sortOrder' => 550));
}
}
}
public static function onDashboardSidebarInit($event)
{
if (Yii::app()->user->isGuest) {
return;
}
$user = Yii::app()->user->getModel();
if ($user->isModuleEnabled('calendarplus')) {
$event->sender->addWidget('application.modules.calendarplus.widgets.NextEventsSidebarWidget', array(), array('sortOrder' => 550));
}
}
public static function onProfileSidebarInit($event)
{
if (Yii::app()->user->isGuest) {
return;
}
$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('calendarplus')) {
$event->sender->addWidget('application.modules.calendarplus.widgets.NextEventsSidebarWidget', array('contentContainer' => $user), array('sortOrder' => 550));
}
}
}
}