Beispiel #1
0
 public function render()
 {
     $template = $this->getTemplate();
     $template->setFile(__DIR__ . '/roleDefinition.latte');
     $resultSet = $this->userFacade->fetchAccessDefinitions(new AccessDefinitionQuery());
     $template->accessDefinitions = $this->sortAccessDefinitions($resultSet->toArray());
     $permissionsResultSet = $this->userFacade->fetchPermissions((new PermissionQuery())->byRole($this->role->getId()));
     $template->permissions = $this->sortRolePermissions($permissionsResultSet->toArray());
     $template->role = $this->role->getName();
     $template->render();
 }
Beispiel #2
0
 public function removeRole(SubmitButton $button)
 {
     if (!$this->authorizator->isAllowed($this->user, 'user_role', 'remove')) {
         $this->flashMessage('authorization.noPermission', FlashMessage::WARNING);
         $this->redirect('this');
     }
     try {
         $this->userFacade->removeRole($this->role);
         $this->onSuccessRoleRemoval($this->role);
     } catch (ForeignKeyConstraintViolationException $e) {
         $this->flashMessage('users.roleRemoval.messages.roleInUse', FlashMessage::WARNING, ['roleName' => $this->role->getName()]);
         $this->redirect('this');
     }
 }
Beispiel #3
0
 public function onSuccessRolePermissionsEditing(Role $role)
 {
     $this->appEventLogger->saveLog(sprintf('User [%s#%s] <b>has EDITED</b> permissions of Role [%s#%s]', $this->user->getId(), $this->user->getUsername(), $role->getId(), $role->getName()), 'user_role_editing', $this->user->getId());
 }
Beispiel #4
0
 /**
  * @return string
  */
 public function getRoleName()
 {
     return $this->role->getName();
 }
Beispiel #5
0
 public function onSuccessRoleRemoval(Role $role)
 {
     $this->flashMessage('users.roleRemoval.messages.success', FlashMessage::SUCCESS, ['roleName' => $role->getName()]);
     $this->redirect('Users:roles');
 }