@@ -58,6 +58,10 @@ class AJXP_Role implements AjxpGroupPathProvider
58
58
* @var array Automatically applies to a given list of profiles
59
59
*/
60
60
protected $ autoApplies = array ();
61
+ /**
62
+ * @var AJXP_PermissionMask[]
63
+ */
64
+ protected $ masks = array ();
61
65
62
66
static $ cypheredPassPrefix = '$pydio_password$ ' ;
63
67
@@ -162,6 +166,46 @@ public function clearAcls()
162
166
$ this ->acls = array ();
163
167
}
164
168
169
+ /**
170
+ * @param String $repositoryId
171
+ * @param AJXP_PermissionMask $mask
172
+ */
173
+ public function setMask ($ repositoryId , $ mask ){
174
+ $ this ->masks [$ repositoryId ] = $ mask ;
175
+ }
176
+
177
+ /**
178
+ * @param string $repositoryId
179
+ */
180
+ public function clearMask ($ repositoryId ){
181
+ if (isSet ($ this ->masks [$ repositoryId ])){
182
+ unset($ this ->masks [$ repositoryId ]);
183
+ }
184
+ }
185
+
186
+ /**
187
+ * @param string $repositoryId
188
+ * @return bool
189
+ */
190
+ public function hasMask ($ repositoryId ){
191
+ return isSet ($ this ->masks [$ repositoryId ]);
192
+ }
193
+
194
+ /**
195
+ * @param $repositoryId
196
+ * @return AJXP_PermissionMask|null
197
+ */
198
+ public function getMask ($ repositoryId ){
199
+ return (isSet ($ this ->masks [$ repositoryId ]) ? $ this ->masks [$ repositoryId ] : null );
200
+ }
201
+
202
+ /**
203
+ * @return AJXP_PermissionMask[]
204
+ */
205
+ public function listMasks (){
206
+ return $ this ->masks ;
207
+ }
208
+
165
209
/**
166
210
* Send all role informations as an associative array
167
211
* @param bool $blurPasswords
@@ -171,6 +215,7 @@ public function getDataArray($blurPasswords = false)
171
215
{
172
216
$ roleData = array ();
173
217
$ roleData ["ACL " ] = $ this ->listAcls ();
218
+ $ roleData ["MASKS " ] = $ this ->listMasks ();
174
219
$ roleData ["ACTIONS " ] = $ this ->listActionsStates ();
175
220
$ roleData ["PARAMETERS " ] = $ this ->listParameters (false , $ blurPasswords );
176
221
$ roleData ["APPLIES " ] = $ this ->listAutoApplies ();
@@ -188,6 +233,9 @@ public function bunchUpdate($roleData)
188
233
$ this ->actions = $ roleData ["ACTIONS " ];
189
234
$ this ->parameters = $ roleData ["PARAMETERS " ];
190
235
$ this ->autoApplies = $ roleData ["APPLIES " ];
236
+ if (isSet ($ roleData ["MASKS " ])){
237
+ $ this ->masks = $ roleData ["MASKS " ];
238
+ }
191
239
192
240
}
193
241
@@ -372,6 +420,18 @@ public function override(AJXP_Role $role)
372
420
}
373
421
}
374
422
423
+ $ roleMasks = $ role ->listMasks ();
424
+ $ allKeys = array_merge (array_keys ($ this ->masks ), array_keys ($ roleMasks ));
425
+ foreach ($ allKeys as $ repoId ){
426
+ if (isSet ($ roleMasks [$ repoId ]) && isSet ($ this ->masks [$ repoId ])){
427
+ $ newRole ->setMask ($ repoId , $ this ->masks [$ repoId ]->override ($ roleMasks [$ repoId ]));
428
+ }else if (isSet ($ roleMasks [$ repoId ])){
429
+ $ newRole ->setMask ($ repoId , $ roleMasks [$ repoId ]);
430
+ }else {
431
+ $ newRole ->setMask ($ repoId , $ this ->masks [$ repoId ]);
432
+ }
433
+ }
434
+
375
435
return $ newRole ;
376
436
}
377
437
0 commit comments