public function revokeRole($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); $role = $_POST['role']; if (strlen($role) > 0) { $roleService = new Role($this->db); $username = $accountService->getUsernameOfId($id); if ($roleService->revokeRoleFromAccount($username, $role)) { $this->flash->success('Deleted role successfully!'); } else { $this->flash->addMany($roleService->getAllMessages(), 'warning'); } } else { $this->flash->warning('You must type in a role!'); } } return $this->redirect('/members/view/' . $id); }