public function giveRole($id) { $message = 'You are not allowed to change the roles!'; if ($this->shouldLockIfNoPermission('members.edit', 'members/view/' . $id, $message)) { return; } if ($this->request->is('post')) { $accountService = new Account($this->db); $username = $accountService->getUsernameOfId($id); $roleService = new Role($this->db); if ($roleService->giveRoleToAccount($username, $_POST['role'])) { $this->flash->success('Added role successfully!'); } else { $this->flash->addMany($roleService->getAllMessages(), 'warning'); } } return $this->redirect('/members/view/' . $id); }