Browse Source

Move personal settings template generation to controller.

Signed-off-by: Joachim Bauch <bauch@struktur.de>
pull/84/head
Joachim Bauch 9 years ago
committed by Morris Jobke
parent
commit
d8843befab
No known key found for this signature in database GPG Key ID: 9CE5ED29E7FCD38A
  1. 36
      lib/AppInfo/Application.php
  2. 15
      lib/Controller/PersonalSettingsController.php
  3. 32
      personal.php

36
lib/AppInfo/Application.php

@ -0,0 +1,36 @@
<?php
/**
* @author Joachim Bauch <mail@joachim-bauch.de>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/
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);
}
}

15
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".

32
personal.php

@ -1,11 +1,25 @@
<?php
/**
* @author Joachim Bauch <mail@joachim-bauch.de>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/
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();
Loading…
Cancel
Save