55 lines
1.8 KiB
PHP
55 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\CustomPwa\Settings;
|
|
|
|
use OCA\CustomPwa\AppInfo\Application;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\IL10N;
|
|
use OCP\IConfig;
|
|
use OCP\IURLGenerator;
|
|
use OCP\Settings\ISettings;
|
|
|
|
class AdminSettings implements ISettings {
|
|
public function __construct(
|
|
private IL10N $l,
|
|
private IURLGenerator $urlGenerator,
|
|
private IConfig $config,
|
|
) {
|
|
}
|
|
|
|
public function getForm(): TemplateResponse {
|
|
$vapidSubject = trim($this->config->getAppValue(Application::APP_ID, 'vapid_subject', ''));
|
|
$vapidPublicKey = trim($this->config->getAppValue(Application::APP_ID, 'vapid_public_key', ''));
|
|
$vapidPrivateKeyConfigured = trim($this->config->getAppValue(Application::APP_ID, 'vapid_private_key', '')) !== '';
|
|
$emailFallbackEnabled = $this->config->getAppValue(Application::APP_ID, 'email_fallback_enabled', '1') === '1';
|
|
$smsCriticalFallbackEnabled = $this->config->getAppValue(Application::APP_ID, 'sms_critical_fallback_enabled', '0') === '1';
|
|
|
|
return new TemplateResponse(
|
|
Application::APP_ID,
|
|
'admin',
|
|
[
|
|
'title' => $this->l->t('CustomPWA'),
|
|
'vapidSubject' => $vapidSubject,
|
|
'vapidPublicKey' => $vapidPublicKey,
|
|
'vapidPrivateKeyConfigured' => $vapidPrivateKeyConfigured,
|
|
'emailFallbackEnabled' => $emailFallbackEnabled,
|
|
'smsCriticalFallbackEnabled' => $smsCriticalFallbackEnabled,
|
|
'settingsGetUrl' => $this->urlGenerator->linkToRoute('custom_pwa.api.getAdminSettings'),
|
|
'settingsSaveUrl' => $this->urlGenerator->linkToRoute('custom_pwa.api.saveAdminSettings'),
|
|
'installerUrl' => $this->urlGenerator->linkToRoute('custom_pwa.page.install'),
|
|
],
|
|
''
|
|
);
|
|
}
|
|
|
|
public function getSection(): string {
|
|
return Application::APP_ID;
|
|
}
|
|
|
|
public function getPriority(): int {
|
|
return 40;
|
|
}
|
|
}
|