Files

41 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\NuqloudMasterCalendar\Settings;
use OCA\NuqloudMasterCalendar\AppInfo\Application;
use OCA\NuqloudMasterCalendar\Calendar\SourceCalendarService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUserSession;
use OCP\Settings\ISettings;
use OCP\Util;
class PersonalSettings implements ISettings {
public function __construct(private IConfig $config, private IUserSession $userSession, private IL10N $l) {
}
public function getForm(): TemplateResponse {
$user = $this->userSession->getUser();
$mode = $user === null ? SourceCalendarService::MODE_ALL : $this->config->getUserValue(
$user->getUID(), Application::APP_ID, 'source_mode', SourceCalendarService::MODE_ALL,
);
Util::addScript(Application::APP_ID, 'settings');
return new TemplateResponse(Application::APP_ID, 'personal', [
'mode' => $mode === SourceCalendarService::MODE_EDITABLE ? $mode : SourceCalendarService::MODE_ALL,
'text' => [
'title' => $this->l->t('NuQloud Master Calendar'),
'intro' => $this->l->t('This read-only CalDAV calendar combines your enabled calendar sources. It is hidden by default in the Calendar app to avoid duplicate events.'),
'all' => $this->l->t('All accessible calendars'),
'editable' => $this->l->t('Editable calendars only'),
'save' => $this->l->t('Save'),
],
], '');
}
public function getSection(): string { return Application::APP_ID; }
public function getPriority(): int { return 50; }
}