-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathEvents.php
41 lines (33 loc) · 1.05 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
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\blockprofilechanges;
use humhub\components\Controller;
use humhub\modules\user\widgets\AccountMenu;
use Yii;
use yii\base\ActionEvent;
use yii\helpers\Url;
use yii\web\HttpException;
class Events
{
public static function onControllerAction(ActionEvent $event)
{
/** @var Controller $controller */
$controller = $event->sender;
/** @var Module $module */
$module = Yii::$app->getModule('block-profile-changes');
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']));
}
}