Only show edit role link if user has the appropriate permission

This commit is contained in:
Philipp Dorschner 2019-09-25 15:04:54 +02:00 committed by Johannes Meyer
parent 57b64f85bf
commit 564fb8c320
2 changed files with 22 additions and 16 deletions

View File

@ -170,6 +170,7 @@ class UserController extends AuthBackendController
$admissionLoader = new AdmissionLoader();
$admissionLoader->applyRoles($userObj);
$this->view->userObj = $userObj;
$this->view->allowedToEditRoles = $this->hasPermission('config/authentication/roles/edit');
}
/**

View File

@ -43,22 +43,27 @@ use Icinga\Data\Selectable;
<tr>
<th><?= $this->translate('Role Memberships'); ?></th>
<td>
<?php $roleObj = $userObj->getRoles(); ?>
<?php if (! empty($roleObj)): ?>
<ul class="role-memberships">
<?php foreach($roleObj as $role): ?>
<li><?= $this->qlink(
$role->getName(),
'role/edit',
['role' => $role->getName()],
['title' => sprintf($this->translate('Edit role %s'), $role->getName())]
) ?>
</li>
<?php endforeach ?>
</ul>
<?php else: ?>
<p><?= $this->translate('No memberships found'); ?></p>
<?php endif ?>
<?php $roleObj = $userObj->getRoles(); ?>
<?php if (! empty($roleObj)): ?>
<ul class="role-memberships">
<?php foreach($roleObj as $role): ?>
<li>
<?php if ($this->allowedToEditRoles): ?>
<?= $this->qlink(
$role->getName(),
'role/edit',
['role' => $role->getName()],
['title' => sprintf($this->translate('Edit role %s'), $role->getName())]
) ?>
<?php else: ?>
<?= $role->getName() ?>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
<?php else: ?>
<p><?= $this->translate('No memberships found'); ?></p>
<?php endif ?>
</td>
</tr>
</table>