1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Hosting Plugin for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
6
|
|
|
* @package hipanel-module-hosting |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\menus; |
12
|
|
|
|
13
|
|
|
use Yii; |
14
|
|
|
|
15
|
|
|
class SidebarMenu extends \hiqdev\yii2\menus\Menu |
16
|
|
|
{ |
17
|
|
|
public function items() |
18
|
|
|
{ |
19
|
|
|
$user = Yii::$app->user; |
20
|
|
|
|
21
|
|
|
$menu = [ |
22
|
|
|
'ipam' => [ |
23
|
|
|
'label' => Yii::t('hipanel.hosting.ipam', 'IP Address Management'), |
24
|
|
|
'url' => '#', |
25
|
|
|
'icon' => 'fa-sitemap', |
26
|
|
|
'items' => [ |
27
|
|
|
'aggregate' => [ |
28
|
|
|
'label' => Yii::t('hipanel.hosting.ipam', 'Aggregates'), |
29
|
|
|
'url' => ['/hosting/aggregate/index'], |
30
|
|
|
], |
31
|
|
|
'prefixes' => [ |
32
|
|
|
'label' => Yii::t('hipanel.hosting.ipam', 'Prefixes'), |
33
|
|
|
'url' => ['/hosting/prefix/index'], |
34
|
|
|
], |
35
|
|
|
], |
36
|
|
|
'visible' => Yii::$app->user->can('test.alpha'), |
37
|
|
|
], |
38
|
|
|
'hosting' => [ |
39
|
|
|
'label' => Yii::t('hipanel:hosting', 'Hosting'), |
40
|
|
|
'url' => '#', |
41
|
|
|
'icon' => 'fa-sitemap', |
42
|
|
|
'visible' => false, |
43
|
|
|
'items' => [ |
44
|
|
|
'accounts' => [ |
45
|
|
|
'label' => Yii::t('hipanel:hosting', 'Accounts'), |
46
|
|
|
'url' => ['/hosting/account/index'], |
47
|
|
|
'icon' => 'fa-user', |
48
|
|
|
'visible' => $user->can('account.read'), |
49
|
|
|
], |
50
|
|
|
'dbs' => [ |
51
|
|
|
'label' => Yii::t('hipanel:hosting', 'Databases'), |
52
|
|
|
'url' => ['/hosting/db/index'], |
53
|
|
|
'icon' => 'fa-database', |
54
|
|
|
'visible' => $user->can('db.read'), |
55
|
|
|
], |
56
|
|
|
'hdomains' => [ |
57
|
|
|
'label' => Yii::t('hipanel:hosting', 'Domains'), |
58
|
|
|
'url' => ['/hosting/hdomain/index'], |
59
|
|
|
'icon' => 'fa-globe', |
60
|
|
|
'visible' => $user->can('hdomain.read'), |
61
|
|
|
], |
62
|
|
|
'mails' => [ |
63
|
|
|
'label' => Yii::t('hipanel:hosting', 'Mailboxes'), |
64
|
|
|
'url' => ['/hosting/mail/index'], |
65
|
|
|
'icon' => 'fa-envelope-o', |
66
|
|
|
'visible' => ((bool) Yii::getAlias('@mail', false)) && $user->can('mail.read'), |
67
|
|
|
], |
68
|
|
|
'backuping' => [ |
69
|
|
|
'label' => Yii::t('hipanel:hosting', 'Backups settings'), |
70
|
|
|
'icon' => 'fa-archive', |
71
|
|
|
'url' => ['/hosting/backuping/index'], |
72
|
|
|
'visible' => $user->can('backuping.read'), |
73
|
|
|
], |
74
|
|
|
'backup' => [ |
75
|
|
|
'label' => Yii::t('hipanel:hosting', 'Backups'), |
76
|
|
|
'icon' => 'fa-archive', |
77
|
|
|
'url' => ['/hosting/backup/index'], |
78
|
|
|
'visible' => $user->can('backup.read'), |
79
|
|
|
], |
80
|
|
|
'crontab' => [ |
81
|
|
|
'label' => Yii::t('hipanel:hosting', 'Crons'), |
82
|
|
|
'icon' => 'fa-clock-o', |
83
|
|
|
'url' => ['/hosting/crontab/index'], |
84
|
|
|
'visible' => $user->can('crontab.read'), |
85
|
|
|
], |
86
|
|
|
'ip' => [ |
87
|
|
|
'label' => Yii::t('hipanel:hosting', 'IP addresses'), |
88
|
|
|
'icon' => 'fa-location-arrow', |
89
|
|
|
'url' => ['/hosting/ip/index'], |
90
|
|
|
'visible' => $user->can('ip.read'), |
91
|
|
|
], |
92
|
|
|
'service' => [ |
93
|
|
|
'label' => Yii::t('hipanel:hosting', 'Services'), |
94
|
|
|
'icon' => 'fa-terminal', |
95
|
|
|
'url' => ['/hosting/service/index'], |
96
|
|
|
'visible' => $user->can('service.read'), |
97
|
|
|
], |
98
|
|
|
'request' => [ |
99
|
|
|
'label' => Yii::t('hipanel:hosting', 'Requests'), |
100
|
|
|
'icon' => 'fa-tasks', |
101
|
|
|
'url' => ['/hosting/request/index'], |
102
|
|
|
'visible' => $user->can('request.read'), |
103
|
|
|
], |
104
|
|
|
], |
105
|
|
|
], |
106
|
|
|
]; |
107
|
|
|
|
108
|
|
|
foreach ($menu['hosting']['items'] as $sub) { |
109
|
|
|
if ((bool) $sub['visible'] === true || !isset($sub['visible'])) { |
110
|
|
|
$menu['hosting']['visible'] = true; |
111
|
|
|
break; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
$menu['hosting']['visible'] = (Yii::$app->params['module.hosting.is_public'] || $user->can('support')) |
116
|
|
|
&& ($menu['hosting']['visible'] || $user->can('dns.read')); |
117
|
|
|
|
118
|
|
|
return $menu; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|