Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 671d728

Browse files
committed
Store masks in roles.
1 parent 5ee3a12 commit 671d728

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

core/src/core/classes/class.AJXP_Role.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class AJXP_Role implements AjxpGroupPathProvider
5858
* @var array Automatically applies to a given list of profiles
5959
*/
6060
protected $autoApplies = array();
61+
/**
62+
* @var AJXP_PermissionMask[]
63+
*/
64+
protected $masks = array();
6165

6266
static $cypheredPassPrefix = '$pydio_password$';
6367

@@ -162,6 +166,46 @@ public function clearAcls()
162166
$this->acls = array();
163167
}
164168

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+
165209
/**
166210
* Send all role informations as an associative array
167211
* @param bool $blurPasswords
@@ -171,6 +215,7 @@ public function getDataArray($blurPasswords = false)
171215
{
172216
$roleData = array();
173217
$roleData["ACL"] = $this->listAcls();
218+
$roleData["MASKS"] = $this->listMasks();
174219
$roleData["ACTIONS"] = $this->listActionsStates();
175220
$roleData["PARAMETERS"] = $this->listParameters(false, $blurPasswords);
176221
$roleData["APPLIES"] = $this->listAutoApplies();
@@ -188,6 +233,9 @@ public function bunchUpdate($roleData)
188233
$this->actions = $roleData["ACTIONS"];
189234
$this->parameters = $roleData["PARAMETERS"];
190235
$this->autoApplies = $roleData["APPLIES"];
236+
if(isSet($roleData["MASKS"])){
237+
$this->masks = $roleData["MASKS"];
238+
}
191239

192240
}
193241

@@ -372,6 +420,18 @@ public function override(AJXP_Role $role)
372420
}
373421
}
374422

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+
375435
return $newRole;
376436
}
377437

0 commit comments

Comments
 (0)