diff --git a/apps/federation/appinfo/app.php b/apps/federation/appinfo/app.php index 92b64b9c05..6c53810dd2 100644 --- a/apps/federation/appinfo/app.php +++ b/apps/federation/appinfo/app.php @@ -23,5 +23,4 @@ namespace OCA\Federation\AppInfo; $app = new Application(); -$app->registerSettings(); $app->registerHooks(); diff --git a/apps/federation/appinfo/info.xml b/apps/federation/appinfo/info.xml index c6d1debd10..e702c9363c 100644 --- a/apps/federation/appinfo/info.xml +++ b/apps/federation/appinfo/info.xml @@ -5,7 +5,7 @@ Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing. AGPL Bjoern Schiessle - 1.0.0 + 1.0.1 Federation other @@ -19,4 +19,8 @@ OCA\Federation\SyncJob + + + OCA\Federation\Settings\Admin + diff --git a/apps/federation/lib/AppInfo/Application.php b/apps/federation/lib/AppInfo/Application.php index 5d8da05c8e..cdc6145dfb 100644 --- a/apps/federation/lib/AppInfo/Application.php +++ b/apps/federation/lib/AppInfo/Application.php @@ -51,13 +51,6 @@ class Application extends \OCP\AppFramework\App { $this->registerMiddleware(); } - /** - * register setting scripts - */ - public function registerSettings() { - App::registerAdmin('federation', 'settings/settings-admin'); - } - private function registerService() { $container = $this->getContainer(); diff --git a/apps/federation/lib/Settings/Admin.php b/apps/federation/lib/Settings/Admin.php new file mode 100644 index 0000000000..eccb3237f7 --- /dev/null +++ b/apps/federation/lib/Settings/Admin.php @@ -0,0 +1,69 @@ + + * + * @author Arthur Schiwon + * + * @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\Federation\Settings; + +use OCA\Federation\TrustedServers; +use OCP\AppFramework\Http\TemplateResponse; +use OCP\Settings\ISettings; + +class Admin implements ISettings { + + /** @var TrustedServers */ + private $trustedServers; + + public function __construct(TrustedServers $trustedServers) { + $this->trustedServers = $trustedServers; + } + + /** + * @return TemplateResponse + */ + public function getForm() { + $parameters = [ + 'trustedServers' => $this->trustedServers->getServers(), + 'autoAddServers' => $this->trustedServers->getAutoAddServers(), + ]; + + return new TemplateResponse('federation', 'settings-admin', $parameters, ''); + } + + /** + * @return string the section ID, e.g. 'sharing' + */ + public function getSection() { + return 'sharing'; + } + + /** + * @return int whether the form should be rather on the top or bottom of + * the admin section. The forms are arranged in ascending order of the + * priority values. It is required to return a value between 0 and 100. + * + * E.g.: 70 + */ + public function getPriority() { + return 30; + } + +} diff --git a/apps/federation/settings/settings-admin.php b/apps/federation/settings/settings-admin.php deleted file mode 100644 index aa21a1e992..0000000000 --- a/apps/federation/settings/settings-admin.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see - * - */ - -$template = new OCP\Template('federation', 'settings-admin'); - -$dbHandler = new \OCA\Federation\DbHandler( - \OC::$server->getDatabaseConnection(), - \OC::$server->getL10N('federation') -); - -$trustedServers = new \OCA\Federation\TrustedServers( - $dbHandler, - \OC::$server->getHTTPClientService(), - \OC::$server->getLogger(), - \OC::$server->getJobList(), - \OC::$server->getSecureRandom(), - \OC::$server->getConfig(), - \OC::$server->getEventDispatcher() -); - -$template->assign('trustedServers', $trustedServers->getServers()); -$template->assign('autoAddServers', $trustedServers->getAutoAddServers()); - -return $template->fetchPage();