-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEvents.php
More file actions
72 lines (64 loc) · 2.15 KB
/
Events.php
File metadata and controls
72 lines (64 loc) · 2.15 KB
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
<?php
/**
* Move content
* @link https://www.cuzy.app
* @license https://www.cuzy.app/cuzy-license
* @author [Marc FARRE](https://marc.fun)
*/
namespace humhub\modules\moveContent;
use humhub\helpers\ControllerHelper;
use humhub\modules\admin\permissions\ManageUsers;
use humhub\modules\admin\widgets\UserMenu;
use humhub\modules\ui\menu\MenuLink;
use Throwable;
use Yii;
use yii\base\Event;
use yii\base\InvalidConfigException;
class Events
{
/**
* @param Event $event
* @throws InvalidConfigException|Throwable
*/
public static function onAdminUserMenuInit($event)
{
/** @var UserMenu $menu */
$menu = $event->sender;
if (Yii::$app->user->can(ManageUsers::class)) {
$menu->addEntry(new MenuLink([
'label' => Yii::t('MoveContentModule.base', 'Move content'),
'url' => ['/move-content/user/content'],
'sortOrder' => 2000,
'isActive' => ControllerHelper::isActivePath('move-content', 'user', 'content'),
'isVisible' => true,
]));
}
if (Yii::$app->user->can(ManageUsers::class)) {
$menu->addEntry(new MenuLink([
'label' => Yii::t('MoveContentModule.base', 'Move group users'),
'url' => ['/move-content/user/group'],
'sortOrder' => 2000,
'isActive' => ControllerHelper::isActivePath('move-content', 'user', 'group'),
'isVisible' => true,
]));
}
}
/**
* @param Event $event
* @throws InvalidConfigException|Throwable
*/
public static function onAdminSpaceMenuInit($event)
{
/** @var UserMenu $menu */
$menu = $event->sender;
if (Yii::$app->user->can(ManageUsers::class)) {
$menu->addEntry(new MenuLink([
'label' => Yii::t('MoveContentModule.base', 'Move content'),
'url' => ['/move-content/space/content'],
'sortOrder' => 2000,
'isActive' => ControllerHelper::isActivePath('move-content', 'space', 'content'),
'isVisible' => true,
]));
}
}
}