This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/lib/Controller/SettingsController.php

70 lines
1.6 KiB
PHP
Raw Normal View History

<?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
use OCA\Epubreader\Config;
2023-06-16 14:58:23 +00:00
use OCA\Epubreader\Service\PreferenceService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
2023-06-16 14:58:23 +00:00
use OCP\IRequest;
use OCP\IURLGenerator;
class SettingsController extends Controller {
2023-06-16 14:58:23 +00:00
private $urlGenerator;
2023-06-16 14:58:23 +00:00
private $preferenceService;
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) {
parent::__construct($AppName, $request);
2023-06-16 14:58:23 +00:00
$this->urlGenerator = $urlGenerator;
$this->preferenceService = $preferenceService;
}
/**
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
*
* @return array|\OCP\AppFramework\Http\JSONResponse
*/
2023-06-16 14:58:23 +00:00
public function setPreference(int $EpubEnable, int $PdfEnable, int $CbxEnable) {
$l = \OC::$server->getL10N('epubreader');
Config::set('epub_enable', $EpubEnable);
Config::set('pdf_enable', $PdfEnable);
Config::set('cbx_enable', $CbxEnable);
$response = array(
2023-06-16 14:58:23 +00:00
'data' => array('message' => $l->t('Settings updated successfully.')),
'status' => 'success'
);
return new JSONResponse($response);
}
2023-06-16 14:58:23 +00:00
}