files_reader/lib/Controller/SettingsController.php
Frank de Lange b190e180ef - Migrated from https://github.com/Yetangitu/owncloud-apps
- substantial bit rot accrued in 4 years of non-maintenance which made Reader unusable
 - Reader now works reliably on public pages - or at least it _Works For Me™_

 - Refactored a substantial part of the code to comply to the "current" (ha ha) Nextcloud API
 - Dropped Owncloud compatibility for lack of a testing installation
 - Dropped IE (<11) support
 - Dropped compatibility with older (<20) Nextcloud versions
 - Dropped app-specific ajax code, now handled by SettingsController
 - Updated dependencies where applicable
2022-09-24 00:00:03 +00:00

60 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
/**
* @author Frank de Lange
* @copyright 2022 Frank de Lange
*
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Files_Reader\Controller;
use OCA\Files_Reader\AppInfo\Application;
use OCP\IL10N;
use OCP\IConfig;
use OCP\IRequest;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
class SettingsController extends Controller {
protected IConfig $config;
protected Il10n $l10n;
protected string $userId;
public function __construct(
IRequest $request,
IConfig $config,
string $userId,
IL10N $l10n) {
parent::__construct(Application::APP_ID, $request);
$this->config = $config;
$this->userId = $userId;
$this->l10n = $l10n;
}
public function personal(string $epub_enable, string $pdf_enable, string $cbx_enable) {
$this->config->setUserValue(
$this->userId, Application::APP_ID, 'epub_enable', $epub_enable
);
$this->config->setUserValue(
$this->userId, Application::APP_ID, 'pdf_enable', $pdf_enable
);
$this->config->setUserValue(
$this->userId, Application::APP_ID, 'cbx_enable', $cbx_enable
);
return new DataResponse([
'data' => [
'message' => $this->l10n->t('Your settings have been updated.'),
],
]);
}
}