Exemplo n.º 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();
 }
Exemplo n.º 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');
     }
 }
Exemplo n.º 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());
 }
Exemplo n.º 4
0
 /**
  * @return string
  */
 public function getRoleName()
 {
     return $this->role->getName();
 }
Exemplo n.º 5
0
 public function onSuccessRoleRemoval(Role $role)
 {
     $this->flashMessage('users.roleRemoval.messages.success', FlashMessage::SUCCESS, ['roleName' => $role->getName()]);
     $this->redirect('Users:roles');
 }