User: Move `$user:local_name$` handling to class `AdmissionLoader`

This way it also adjusts the roles directly, and not just their
copies for the user object
This commit is contained in:
Johannes Meyer 2021-02-01 15:19:17 +01:00
parent bdd0f204f0
commit 6eb0139446
2 changed files with 5 additions and 5 deletions

View File

@ -155,9 +155,13 @@ class AdmissionLoader
array_diff($role->getPermissions(), $permissions)
);
foreach ($role->getRestrictions() as $name => $restriction) {
$roleRestrictions = $role->getRestrictions();
foreach ($roleRestrictions as $name => & $restriction) {
$restriction = str_replace('$user:local_name$', $user->getLocalUsername(), $restriction);
$restrictions[$name][] = $restriction;
}
$role->setRestrictions($roleRestrictions);
}
}
}

View File

@ -252,10 +252,6 @@ class User
*/
public function setRestrictions(array $restrictions)
{
foreach ($restrictions as $name => $restriction) {
$restrictions[$name] = str_replace('$user:local_name$', $this->getLocalUsername(), $restriction);
}
$this->restrictions = $restrictions;
return $this;
}