public function render() { $template = $this->getTemplate(); $template->setFile(__DIR__ . '/usersRolesOverview.latte'); $resultSet = $this->userFacade->fetchRoles($this->roleQuery); $template->roles = $resultSet->toArray(); $template->render(); }
private function prepareRolesForSelect() { $roles = $this->userFacade->fetchRoles(new RoleQuery()); $result = []; /** @var Role $role */ foreach ($roles as $role) { $result[$role->getId()] = $role->getName(); } return $result; }
public function processNewRole(Form $form, $values) { if (!$this->authorizator->isAllowed($this->user, 'user_role', 'create')) { $this->flashMessage('authorization.noPermission', FlashMessage::WARNING); } try { $role = $this->userFacade->createRole((array) $values); $this->onSuccessRoleCreation($this, $role); } catch (RoleMissingException $rm) { $this->flashMessage('users.newRole.form.messages.missingRole', FlashMessage::WARNING, ['roleName' => $values['name']]); } catch (RoleAlreadyExistsException $re) { $this->flashMessage('users.newRole.form.messages.roleAlreadyExists', FlashMessage::WARNING, ['roleName' => $values['name']]); } }
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'); } }
public function removeRole(SubmitButton $button) { if (!$this->authorizator->isAllowed($this->user, 'user', 'remove')) { $this->flashMessage('authorization.noPermission', FlashMessage::WARNING); $this->redirect('this'); } try { $this->userFacade->removeUser($this->pickedUser); $this->onSuccessUserRemoval($this->pickedUser); } catch (ForeignKeyConstraintViolationException $e) { $this->flashMessage('users.userRemoval.messages.cantBeRemoved', FlashMessage::WARNING, ['username' => $this->pickedUser->getUsername()]); $this->redirect('this'); } }
public function processUser(Form $form, $values) { if (!$this->authorizator->isAllowed($this->user, 'user', 'edit')) { $this->flashMessage('authorization.noPermission', FlashMessage::WARNING); } $validationObject = $this->userFacade->saveUser((array) $values, $this->pickedUser); if ($validationObject->isValid()) { $this->flashMessage('users.user.form.messages.success', FlashMessage::SUCCESS); $this->redirect('this'); } /** @var ValidationError $error */ foreach ($validationObject->getErrors() as $error) { $this->flashMessage($error->getMessage(), $error->getType()); } }
public function processPrivileges(Form $form) { if (!$this->authorizator->isAllowed($this->user, 'user_role', 'edit')) { $this->flashMessage('authorization.noPermission', FlashMessage::WARNING); } $values = $form->getHttpData(); unset($values['save'], $values['do'], $values[Form::PROTECTOR_ID]); try { $this->userFacade->savePermissionDefinitions($this->role, $values); $this->flashMessage('users.roleDefinition.messages.success', FlashMessage::SUCCESS); $this->redirect('this'); } catch (DBALException $e) { $this->flashMessage('users.roleDefinition.messages.success', FlashMessage::WARNING); } }
private function getRole($id) { $role = $this->userFacade->fetchRole((new RoleQuery())->withParent()->byId($id)); if ($role === null) { $this->flashMessage('users.messages.roleNotFound', FlashMessage::WARNING); $this->redirect('Users:roles'); } return $role; }