-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEvents.php
59 lines (50 loc) · 1.7 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
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\blockmodules;
use humhub\components\Controller;
use humhub\modules\calendar\widgets\CalendarControls;
use humhub\modules\calendar\widgets\ConfigureButton;
use humhub\modules\user\widgets\AccountMenu;
use Yii;
use yii\base\ActionEvent;
use yii\base\WidgetEvent;
use yii\helpers\Url;
class Events
{
public static function onControllerAction(ActionEvent $event)
{
/** @var Controller $controller */
$controller = $event->sender;
/** @var Module $module */
$module = Yii::$app->getModule('blockmodules');
if (in_array($controller->id . '.' . $event->action->id, $module->forbiddenActions)) {
$event->isValid = false;
$event->result = Yii::$app->response->redirect(['/activity/user']);
}
}
public static function onAccountMenu($event)
{
/** @var AccountMenu $accountMenu */
$accountMenu = $event->sender;
$accountMenu->deleteItemByUrl(Url::to(['/user/account/edit-modules']));
}
/**
* Remove "Add profile calendar" gear button on the top right of the page /calendar/global/index
* @param WidgetEvent $event
* @return void
*/
public static function onCalendarControlsBeforeRun(WidgetEvent $event)
{
/** @var CalendarControls $calendarControls */
$calendarControls = $event->sender;
foreach ($calendarControls->widgets as $key => $widget) {
if (in_array(ConfigureButton::class, $widget, true)) {
unset($calendarControls->widgets[$key]);
}
}
}
}