From d8843befabed2a1ffe2907155d6660f56ab63811 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Tue, 15 Nov 2016 08:59:32 +0100 Subject: [PATCH] Move personal settings template generation to controller. Signed-off-by: Joachim Bauch --- lib/AppInfo/Application.php | 36 +++++++++++++++++++ lib/Controller/PersonalSettingsController.php | 15 ++++++++ personal.php | 32 ++++++++++++----- 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 lib/AppInfo/Application.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php new file mode 100644 index 0000000000..cb5ccf48a6 --- /dev/null +++ b/lib/AppInfo/Application.php @@ -0,0 +1,36 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Spreed\AppInfo; + +use OCP\AppFramework\App; +use OCA\Spreed\Controller\PersonalSettingsController; + +class Application extends App { + + public function __construct () { + parent::__construct('spreed'); + $container = $this->getContainer(); + + $container->registerAlias('PersonalSettingsController', PersonalSettingsController::class); + } + +} diff --git a/lib/Controller/PersonalSettingsController.php b/lib/Controller/PersonalSettingsController.php index c7e5efc4d9..4287953886 100644 --- a/lib/Controller/PersonalSettingsController.php +++ b/lib/Controller/PersonalSettingsController.php @@ -21,7 +21,10 @@ namespace OCA\Spreed\Controller; +use OCA\Spreed\Util; + use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IL10N; use OCP\IRequest; @@ -56,6 +59,18 @@ class PersonalSettingsController extends Controller { $this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser() : false; } + /** + * @NoAdminRequired + * + * @return TemplateResponse + */ + public function displayPanel() { + $settings = Util::getTurnSettings($this->config, $this->user->getUID()); + return new TemplateResponse('spreed', 'settings-personal', [ + 'turnSettings' => $settings, + ], ''); + } + /** * Configure the personal settings of the Spreed app. The TURN server must * be passed in the form "turnserver:port", e.g. "turn.domain.invalid:1234". diff --git a/personal.php b/personal.php index e8ef75de41..7207f5df45 100644 --- a/personal.php +++ b/personal.php @@ -1,11 +1,25 @@ + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ -use OCA\Spreed\Util; - -$tmpl = new OCP\Template('spreed', 'settings-personal'); -$config = \OC::$server->getConfig(); -$uid = \OC::$server->getUserSession()->getUser()->getUID(); - -$settings = Util::getTurnSettings($config, $uid); -$tmpl->assign('turnSettings', $settings); -return $tmpl->fetchPage(); +$app = new \OCA\Spreed\AppInfo\Application(); +/** @var OCA\Spreed\Controller\PersonalSettingsController */ +$controller = $app->getContainer()->query('PersonalSettingsController'); +return $controller->displayPanel()->render();