Skip to content

Commit

Permalink
Fixed issue #16958: User with roles can not have more rights (#1835)
Browse files Browse the repository at this point in the history
Added a warning message to the assignment of permissions. Modified the controller so that it effectively cleans up the roles when you assign individual permissions.
  • Loading branch information
gabrieljenik committed Apr 7, 2021
1 parent 76f707d commit 83668ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions application/controllers/UserManagementController.php
Expand Up @@ -416,6 +416,9 @@ public function actionSaveUserPermissions()
}
$userId = Yii::app()->request->getPost('userid');
$aPermissions = Yii::app()->request->getPost('Permission', []);

Permissiontemplates::model()->clearUser($userId);

$results = $this->applyPermissionFromArray($userId, $aPermissions);

$oUser = User::model()->findByPk($userId);
Expand Down
7 changes: 7 additions & 0 deletions application/views/userManagement/partial/editpermissions.php
Expand Up @@ -66,6 +66,13 @@
<?php endforeach; ?>

</table>
<div class="row ls-space margin top-25">
<?php if (safecount(Permission::model()->getUserRole($oUser->uid)) > 0 ): ?>
<div class="col-xs-12 alert alert-warning">
<?= gT("Warning: The user has at least one role assigned. Setting individual user permissions will remove all roles from this user!") ?>
</div>
<?php endif; ?>
</div>
<div class="row ls-space margin top-25">
<button class="btn btn-success col-sm-3 col-xs-5 col-xs-offset-1 selector--submitForm" id="permission-modal-submitForm"><?=gT('Save')?></button>
<button class="btn btn-error col-sm-3 col-xs-5 col-xs-offset-1 selector--exitForm" id="permission-modal-exitForm"><?=gT('Cancel')?></button>
Expand Down

0 comments on commit 83668ed

Please sign in to comment.