2022-01-21 23:53:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2023-08-02 20:04:03 +00:00
|
|
|
* ownCloud - Epubreader App.
|
2022-01-21 23:53:03 +00:00
|
|
|
*
|
|
|
|
* @author Frank de Lange
|
|
|
|
* @copyright 2014,2018 Frank de Lange
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Epubreader\Controller;
|
2023-06-16 14:58:23 +00:00
|
|
|
|
2023-06-16 22:07:40 +00:00
|
|
|
use OCA\Epubreader\AppInfo\Application;
|
2023-06-16 14:58:23 +00:00
|
|
|
use OCP\AppFramework\Controller;
|
2022-01-22 00:55:57 +00:00
|
|
|
use OCP\AppFramework\Http\JSONResponse;
|
2023-06-16 22:07:40 +00:00
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\IL10N;
|
|
|
|
use OCP\IRequest;
|
2022-01-21 23:53:03 +00:00
|
|
|
|
2023-08-02 20:04:03 +00:00
|
|
|
class SettingsController extends Controller
|
|
|
|
{
|
2023-06-16 22:07:40 +00:00
|
|
|
private string $userId;
|
|
|
|
private IL10N $l10n;
|
|
|
|
private IConfig $configManager;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
string $appName,
|
|
|
|
IRequest $request,
|
|
|
|
string $userId,
|
|
|
|
IL10N $l10n,
|
|
|
|
IConfig $configManager
|
|
|
|
) {
|
|
|
|
parent::__construct($appName, $request);
|
|
|
|
$this->userId = $userId;
|
|
|
|
$this->l10n = $l10n;
|
|
|
|
$this->configManager = $configManager;
|
|
|
|
}
|
|
|
|
|
2022-01-21 23:53:03 +00:00
|
|
|
/**
|
2023-06-16 14:58:23 +00:00
|
|
|
* @brief set preference for file type association
|
|
|
|
*
|
|
|
|
* @NoAdminRequired
|
2022-01-21 23:53:03 +00:00
|
|
|
*/
|
2023-08-02 20:04:03 +00:00
|
|
|
public function setPreference(string $EpubEnable, string $PdfEnable, string $CbxEnable): JSONResponse
|
|
|
|
{
|
2023-06-16 22:07:40 +00:00
|
|
|
$this->configManager->setUserValue($this->userId, Application::APP_ID, 'epub_enable', $EpubEnable);
|
|
|
|
$this->configManager->setUserValue($this->userId, Application::APP_ID, 'pdf_enable', $PdfEnable);
|
|
|
|
$this->configManager->setUserValue($this->userId, Application::APP_ID, 'cbx_enable', $CbxEnable);
|
2022-01-21 23:53:03 +00:00
|
|
|
|
2023-06-16 19:31:46 +00:00
|
|
|
$response = [
|
2023-06-16 22:07:40 +00:00
|
|
|
'data' => ['message' => $this->l10n->t('Settings updated successfully.')],
|
2023-08-02 20:04:03 +00:00
|
|
|
'status' => 'success',
|
2023-06-16 19:31:46 +00:00
|
|
|
];
|
2022-01-22 00:55:57 +00:00
|
|
|
|
|
|
|
return new JSONResponse($response);
|
2022-01-21 23:53:03 +00:00
|
|
|
}
|
2023-06-16 14:58:23 +00:00
|
|
|
}
|