-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvents.php
42 lines (37 loc) · 1.06 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
<?php
namespace gm\humhub\modules\converter;
use Yii;
use yii\base\Event;
use yii\helpers\Url;
use humhub\widgets\TopMenu;
use humhub\modules\ui\menu\MenuLink;
use humhub\modules\user\models\Group;
/**
* Class Events
*
* Handles events for the SQL Converter module.
*/
class Events
{
/**
* Event handler for the "TopMenuInit" event.
*
* @param Event $event
*/
public static function onTopMenuInit($event)
{
/** @var TopMenu $menu */
$menu = $event->sender;
// If currently logged-in user is in admin group
$isAdmin = Group::getAdminGroup()->isMember(Yii::$app->user->identity);
// Only show the menu for users in admin group
if ($isAdmin) {
$menu->addEntry(new MenuLink([
'label' => Yii::t('FaqModule.base', '<strong>SQL</strong> Converter'),
'icon' => 'fa-database',
'url' => Url::to(['/converter/sql-converter/index']),
'sortOrder' => 92000,
]));
}
}
}