File tree 4 files changed +41
-2
lines changed
4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change 8
8
9
9
namespace yii \web ;
10
10
11
+ use skeeks \cms \rbac \CmsManager ;
11
12
/**
12
- * Class Application
13
- * @package yii\web
13
+ * @property CmsManager $authManager
14
+ * @author Semenov Alexander <semenov@skeeks.com>
14
15
*/
15
16
class Application
16
17
{
Original file line number Diff line number Diff line change 9
9
namespace skeeks \cms \rbac ;
10
10
11
11
use yii \base \InvalidConfigException ;
12
+ use yii \helpers \ArrayHelper ;
12
13
13
14
/**
14
15
* Class CmsManager
@@ -32,6 +33,10 @@ public function init()
32
33
parent ::init ();
33
34
}
34
35
36
+ /**
37
+ * Доступ суперадминистратора
38
+ */
39
+ const PERMISSION_ROOT_ACCESS = 'cms.root ' ;
35
40
/**
36
41
* Доступ к админке
37
42
*/
@@ -83,4 +88,29 @@ static public function protectedPermissions()
83
88
];
84
89
}
85
90
91
+ /**
92
+ * @return array|\yii\rbac\Item[]|\yii\rbac\Role[]
93
+ */
94
+ public function getAvailableRoles ()
95
+ {
96
+ if (!\Yii::$ app ->user ->identity || !\Yii::$ app ->user ->identity ) {
97
+ return $ this ->getRoles ();
98
+ }
99
+
100
+ $ roles = $ this ->getRoles ();
101
+
102
+ if (!$ roles ) {
103
+ return [];
104
+ }
105
+
106
+ $ result = [];
107
+ if (\Yii::$ app ->user ->can (self ::PERMISSION_ROOT_ACCESS )) {
108
+ return $ roles ;
109
+ }
110
+
111
+ ArrayHelper::remove ($ roles , self ::ROLE_ROOT );
112
+
113
+ return $ roles ;
114
+ }
115
+
86
116
}
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ public function init()
44
44
$ this ->modelShowAttribute = "name " ;
45
45
$ this ->modelPkAttribute = "name " ;
46
46
$ this ->modelClassName = Permission::className ();
47
+
48
+ $ this ->generateAccessActions = false ;
49
+ $ this ->permissionName = CmsManager::PERMISSION_ROOT_ACCESS ;
50
+
47
51
parent ::init ();
48
52
}
49
53
Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ public function init()
40
40
$ this ->modelShowAttribute = "name " ;
41
41
$ this ->modelPkAttribute = "name " ;
42
42
$ this ->modelClassName = Role::className ();
43
+
44
+ $ this ->generateAccessActions = false ;
45
+ $ this ->permissionName = CmsManager::PERMISSION_ROOT_ACCESS ;
46
+
43
47
parent ::init ();
44
48
}
45
49
You can’t perform that action at this time.
0 commit comments