projectService = $projectService; } /** * Displays the delete project confirmation page. * * @param array $params Request parameters */ public function get(array $params): Response { Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager], true); if (! Auth::userIsAtLeast(Roles::$manager)) { return $this->tpl->display('errors.error403', responseCode: 403); } if (! isset($params['id'])) { return $this->tpl->display('errors.error403', responseCode: 403); } $id = (int) $params['id']; $project = $this->projectService->getProject($id); if ($project === false) { return Frontcontroller::redirect(BASE_URL.'/errors/error404'); } if ($this->projectService->hasTickets($id)) { $this->tpl->setNotification($this->language->__('notification.project_has_tasks'), 'info'); } $this->tpl->assign('project', $project); return $this->tpl->display('projects.delProject'); } /** * Handles project deletion. * * @param array $params Request parameters */ public function post(array $params): Response { Auth::authOrRedirect([Roles::$owner, Roles::$admin, Roles::$manager], true); if (! Auth::userIsAtLeast(Roles::$manager)) { return $this->tpl->display('errors.error403', responseCode: 403); } if (! isset($params['id'])) { return $this->tpl->display('errors.error403', responseCode: 403); } $id = (int) $params['id']; $result = $this->projectService->deleteProject($id); if ($result === false) { $this->tpl->setNotification($this->language->__('notification.no_permission'), 'error'); return Frontcontroller::redirect(BASE_URL.'/projects/showAll'); } $this->projectService->resetCurrentProject(); $this->projectService->setCurrentProject(); $this->tpl->setNotification($this->language->__('notification.project_deleted'), 'success'); return Frontcontroller::redirect(BASE_URL.'/projects/showAll'); } }