|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* RBAC implementation for HiPanel |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://github.com/hiqdev/hipanel-rbac |
|
7
|
|
|
* @package hipanel-rbac |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hipanel\rbac; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Initer for AuthManager. |
|
16
|
|
|
* |
|
17
|
|
|
* @author Andrii Vasyliev <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
class Initer |
|
20
|
|
|
{ |
|
21
|
3 |
|
public static function init(AuthManager $auth) |
|
22
|
|
|
{ |
|
23
|
3 |
|
$auth->setRole('client'); |
|
24
|
3 |
|
$auth->setRole('support'); |
|
25
|
3 |
|
$auth->setRole('admin'); |
|
26
|
3 |
|
$auth->setRole('manager'); |
|
27
|
3 |
|
$auth->setRole('reseller'); |
|
28
|
3 |
|
$auth->setRole('owner'); |
|
29
|
3 |
|
$auth->setRole('freezer'); |
|
30
|
3 |
|
$auth->setRole('billManager'); |
|
31
|
|
|
|
|
32
|
3 |
|
$auth->setPermission('deposit'); |
|
33
|
3 |
|
$auth->setPermission('supporting'); |
|
34
|
3 |
|
$auth->setPermission('manage'); |
|
35
|
3 |
|
$auth->setPermission('administrate'); |
|
36
|
3 |
|
$auth->setPermission('resell'); |
|
37
|
3 |
|
$auth->setPermission('own'); |
|
38
|
3 |
|
$auth->setPermission('root'); |
|
39
|
3 |
|
$auth->setPermission('freeze'); |
|
40
|
3 |
|
$auth->setPermission('unfreeze'); |
|
41
|
3 |
|
$auth->setPermission('delete-bills'); |
|
42
|
3 |
|
$auth->setPermission('edit-bills'); |
|
43
|
|
|
|
|
44
|
3 |
|
$auth->setChild('client', 'deposit'); |
|
45
|
|
|
|
|
46
|
3 |
|
$auth->setChild('support', 'supporting'); |
|
47
|
|
|
|
|
48
|
3 |
|
$auth->setChild('admin', 'support'); |
|
49
|
3 |
|
$auth->setChild('admin', 'administrate'); |
|
50
|
|
|
|
|
51
|
3 |
|
$auth->setChild('manager', 'support'); |
|
52
|
3 |
|
$auth->setChild('manager', 'manage'); |
|
53
|
|
|
|
|
54
|
3 |
|
$auth->setChild('reseller', 'manager'); |
|
55
|
3 |
|
$auth->setChild('reseller', 'resell'); |
|
56
|
|
|
|
|
57
|
3 |
|
$auth->setChild('owner', 'reseller'); |
|
58
|
3 |
|
$auth->setChild('owner', 'own'); |
|
59
|
|
|
|
|
60
|
3 |
|
$auth->setChild('freezer', 'freeze'); |
|
61
|
3 |
|
$auth->setChild('freezer', 'unfreeze'); |
|
62
|
|
|
|
|
63
|
3 |
|
$auth->setChild('billManager', 'delete-bills'); |
|
64
|
3 |
|
$auth->setChild('billManager', 'edit-bills'); |
|
65
|
|
|
|
|
66
|
3 |
|
$auth->setAssignment('freezer', 'sol'); |
|
|
|
|
|
|
67
|
3 |
|
$auth->setAssignment('freezer', 'andre'); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
3 |
|
$auth->setAssignment('manager', 'sol'); |
|
|
|
|
|
|
70
|
|
|
|
|
71
|
3 |
|
$auth->setAssignment('billManager', 'sol'); |
|
|
|
|
|
|
72
|
3 |
|
$auth->setAssignment('billManager', 'margo'); |
|
|
|
|
|
|
73
|
3 |
|
$auth->setAssignment('billManager', 'dsr'); |
|
|
|
|
|
|
74
|
3 |
|
$auth->setAssignment('billManager', 'olgadsr'); |
|
|
|
|
|
|
75
|
|
|
|
|
76
|
3 |
|
|
|
77
|
3 |
|
$auth->saveBasicAssignments(); |
|
78
|
|
|
} |
|
79
|
3 |
|
|
|
80
|
|
|
public static function reinit(AuthManager $auth) |
|
81
|
3 |
|
{ |
|
82
|
3 |
|
$auth->removeAll(); |
|
83
|
3 |
|
static::init($auth); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: