OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
72
app/Domain/Calendar/Controllers/ConnectCalendar.php
Normal file
72
app/Domain/Calendar/Controllers/ConnectCalendar.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Calendar\Controllers;
|
||||
|
||||
use Leantime\Core\Auth\Permissions\RequiresPermission;
|
||||
use Leantime\Core\Controller\Controller;
|
||||
use Leantime\Core\Controller\Frontcontroller as FrontcontrollerCore;
|
||||
use Leantime\Domain\Calendar\Permissions\CalendarPermissions;
|
||||
use Leantime\Domain\Calendar\Services\Calendar as CalendarService;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* ConnectCalendar Controller - Displays extensible modal for connecting external calendars.
|
||||
*
|
||||
* Plugins can register additional calendar providers via the filter:
|
||||
* 'leantime.domain.calendar.controllers.connectcalendar.get.connectOptions.providers'
|
||||
*
|
||||
* Provider array structure:
|
||||
* - id: string (unique identifier)
|
||||
* - icon: string (FontAwesome class or SVG markup)
|
||||
* - iconType: string ('fontawesome'|'svg', default 'fontawesome')
|
||||
* - title: string (display name)
|
||||
* - description: string (short description)
|
||||
* - actionUrl: string (URL to connect)
|
||||
* - actionLabel: string (button text)
|
||||
* - actionType: string ('link'|'modal', default 'link')
|
||||
*/
|
||||
class ConnectCalendar extends Controller
|
||||
{
|
||||
private CalendarService $calendarService;
|
||||
|
||||
/**
|
||||
* Initialize the controller with dependencies.
|
||||
*/
|
||||
public function init(CalendarService $calendarService): void
|
||||
{
|
||||
$this->calendarService = $calendarService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the Connect Calendar modal with available providers.
|
||||
*/
|
||||
#[RequiresPermission(CalendarPermissions::CREATE)]
|
||||
public function get(array $params): Response
|
||||
{
|
||||
$providers = self::dispatchFilter('connectOptions.providers', []);
|
||||
|
||||
$this->tpl->assign('providers', $providers);
|
||||
|
||||
return $this->tpl->displayPartial('calendar.connectCalendar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle iCal calendar import submission.
|
||||
*/
|
||||
#[RequiresPermission(CalendarPermissions::CREATE)]
|
||||
public function post(array $params): Response
|
||||
{
|
||||
if (isset($params['name']) || isset($params['url'])) {
|
||||
$values = [
|
||||
'url' => $params['url'] ?? '',
|
||||
'name' => $params['name'] ?? 'My Calendar',
|
||||
'colorClass' => $params['colorClass'] ?? '#082236',
|
||||
];
|
||||
|
||||
$this->calendarService->addExternalCalendarUrl($values);
|
||||
$this->tpl->setNotification('notification.gcal_imported_successfully', 'success', 'externalcalendar_created');
|
||||
}
|
||||
|
||||
return FrontcontrollerCore::redirect(BASE_URL.'/calendar/showMyCalendar');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user