1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* sysPass |
4
|
|
|
* |
5
|
|
|
* @author nuxsmin |
6
|
|
|
* @link https://syspass.org |
7
|
|
|
* @copyright 2012-2019, Rubén Domínguez nuxsmin@$syspass.org |
8
|
|
|
* |
9
|
|
|
* This file is part of sysPass. |
10
|
|
|
* |
11
|
|
|
* sysPass is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* sysPass is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU General Public License |
22
|
|
|
* along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace SP\DataModel\ItemPreset; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class AccountPermission |
29
|
|
|
* |
30
|
|
|
* @package SP\DataModel |
31
|
|
|
*/ |
32
|
|
|
class AccountPermission |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
private $usersView = []; |
38
|
|
|
/** |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
private $usersEdit = []; |
42
|
|
|
/** |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
private $userGroupsView = []; |
46
|
|
|
/** |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
private $userGroupsEdit = []; |
50
|
|
|
/** |
51
|
|
|
* @var int |
52
|
|
|
*/ |
53
|
|
|
private $mainUsergroupId = 0; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function getUsersView(): array |
59
|
|
|
{ |
60
|
|
|
return $this->usersView; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param array $usersView |
65
|
|
|
* |
66
|
|
|
* @return AccountPermission |
67
|
|
|
*/ |
68
|
|
|
public function setUsersView(array $usersView) |
69
|
|
|
{ |
70
|
|
|
$this->usersView = $usersView; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return array |
77
|
|
|
*/ |
78
|
|
|
public function getUsersEdit(): array |
79
|
|
|
{ |
80
|
|
|
return $this->usersEdit; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param array $usersEdit |
85
|
|
|
* |
86
|
|
|
* @return AccountPermission |
87
|
|
|
*/ |
88
|
|
|
public function setUsersEdit(array $usersEdit) |
89
|
|
|
{ |
90
|
|
|
$this->usersEdit = $usersEdit; |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return array |
97
|
|
|
*/ |
98
|
|
|
public function getUserGroupsView(): array |
99
|
|
|
{ |
100
|
|
|
return $this->userGroupsView; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param array $userGroupsView |
105
|
|
|
* |
106
|
|
|
* @return AccountPermission |
107
|
|
|
*/ |
108
|
|
|
public function setUserGroupsView(array $userGroupsView) |
109
|
|
|
{ |
110
|
|
|
$this->userGroupsView = $userGroupsView; |
111
|
|
|
|
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return array |
117
|
|
|
*/ |
118
|
|
|
public function getUserGroupsEdit(): array |
119
|
|
|
{ |
120
|
|
|
return $this->userGroupsEdit; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param array $userGroupsEdit |
125
|
|
|
* |
126
|
|
|
* @return AccountPermission |
127
|
|
|
*/ |
128
|
|
|
public function setUserGroupsEdit(array $userGroupsEdit) |
129
|
|
|
{ |
130
|
|
|
$this->userGroupsEdit = $userGroupsEdit; |
131
|
|
|
|
132
|
|
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return int |
137
|
|
|
*/ |
138
|
|
|
public function getMainUsergroupId() |
139
|
|
|
{ |
140
|
|
|
return (int)$this->mainUsergroupId; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param int $mainUsergroupId |
145
|
|
|
*/ |
146
|
|
|
public function setMainUsergroupId($mainUsergroupId) |
147
|
|
|
{ |
148
|
|
|
$this->mainUsergroupId = (int)$mainUsergroupId; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return bool |
153
|
|
|
*/ |
154
|
|
|
public function hasItems() |
155
|
|
|
{ |
156
|
|
|
return count($this->usersView) > 0 |
157
|
|
|
|| count($this->usersEdit) > 0 |
158
|
|
|
|| count($this->userGroupsView) > 0 |
159
|
|
|
|| count($this->userGroupsEdit) > 0 |
160
|
|
|
|| $this->mainUsergroupId !== 0; |
161
|
|
|
} |
162
|
|
|
} |