2022-01-21 23:53:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ownCloud - Epubreader App
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
2022-01-21 23:53:03 +00:00
|
|
|
use OCA\Epubreader\Config;
|
2023-06-16 14:58:23 +00:00
|
|
|
use OCA\Epubreader\Service\PreferenceService;
|
|
|
|
use OCP\AppFramework\Controller;
|
2022-01-22 00:55:57 +00:00
|
|
|
use OCP\AppFramework\Http\JSONResponse;
|
2023-06-16 14:58:23 +00:00
|
|
|
use OCP\IRequest;
|
|
|
|
use OCP\IURLGenerator;
|
2022-01-21 23:53:03 +00:00
|
|
|
|
|
|
|
class SettingsController extends Controller {
|
2023-06-16 14:58:23 +00:00
|
|
|
|
2022-01-21 23:53:03 +00:00
|
|
|
private $urlGenerator;
|
2023-06-16 14:58:23 +00:00
|
|
|
private $preferenceService;
|
2022-01-21 23:53:03 +00:00
|
|
|
|
2023-06-16 14:58:23 +00:00
|
|
|
/**
|
|
|
|
* @param string $AppName
|
|
|
|
* @param IRequest $request
|
|
|
|
* @param IURLGenerator $urlGenerator
|
|
|
|
* @param PreferenceService $preferenceService
|
|
|
|
*/
|
|
|
|
public function __construct($AppName,
|
|
|
|
IRequest $request,
|
|
|
|
IURLGenerator $urlGenerator,
|
|
|
|
PreferenceService $preferenceService) {
|
2022-01-21 23:53:03 +00:00
|
|
|
|
|
|
|
parent::__construct($AppName, $request);
|
2023-06-16 14:58:23 +00:00
|
|
|
$this->urlGenerator = $urlGenerator;
|
|
|
|
$this->preferenceService = $preferenceService;
|
|
|
|
}
|
|
|
|
|
2022-01-21 23:53:03 +00:00
|
|
|
/**
|
2023-06-16 14:58:23 +00:00
|
|
|
* @brief set preference for file type association
|
|
|
|
*
|
|
|
|
* @NoAdminRequired
|
|
|
|
*
|
|
|
|
* @param int $EpubEnable
|
|
|
|
* @param int $PdfEnable
|
|
|
|
* @param int $CbxEnable
|
|
|
|
*
|
2022-01-21 23:53:03 +00:00
|
|
|
* @return array|\OCP\AppFramework\Http\JSONResponse
|
|
|
|
*/
|
2023-06-16 14:58:23 +00:00
|
|
|
public function setPreference(int $EpubEnable, int $PdfEnable, int $CbxEnable) {
|
2022-01-21 23:53:03 +00:00
|
|
|
|
|
|
|
$l = \OC::$server->getL10N('epubreader');
|
|
|
|
|
|
|
|
Config::set('epub_enable', $EpubEnable);
|
|
|
|
Config::set('pdf_enable', $PdfEnable);
|
|
|
|
Config::set('cbx_enable', $CbxEnable);
|
|
|
|
|
2022-01-22 00:55:57 +00:00
|
|
|
$response = array(
|
2023-06-16 14:58:23 +00:00
|
|
|
'data' => array('message' => $l->t('Settings updated successfully.')),
|
|
|
|
'status' => 'success'
|
|
|
|
);
|
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
|
|
|
}
|