OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)

This commit is contained in:
wangruiguo
2026-09-03 18:49:20 +08:00
commit d647428529
3501 changed files with 1988906 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
<?php
namespace Leantime\Domain\Projects\Controllers;
use Leantime\Core\Controller\Controller;
use Leantime\Core\Controller\Frontcontroller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Auth\Services\Auth;
use Leantime\Domain\Projects\Services\Projects as ProjectService;
use Symfony\Component\HttpFoundation\Response;
class DelProject extends Controller
{
private ProjectService $projectService;
/**
* Initializes dependencies.
*/
public function init(ProjectService $projectService): void
{
$this->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');
}
}