diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-08-08 23:31:26 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-08-09 18:05:09 +0200 |
commit | ceeb44bd04f2606bea4c94107850157719127581 (patch) | |
tree | 7ecb64a3ca929a7b3a721cfed65c65bf0c61831d /apps/user_ldap/lib | |
parent | edeb41ccaff186b116852df4caf8df144db682c8 (diff) | |
download | nextcloud-server-ceeb44bd04f2606bea4c94107850157719127581.tar.gz nextcloud-server-ceeb44bd04f2606bea4c94107850157719127581.zip |
Initial work on Apps page split:
* interfaces for the Admin settings (IAdmin) and section (ISection)
* SettingsManager service
* example setup with LDAP app
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Settings/Admin.php | 115 | ||||
-rw-r--r-- | apps/user_ldap/lib/Settings/Section.php | 67 |
2 files changed, 182 insertions, 0 deletions
diff --git a/apps/user_ldap/lib/Settings/Admin.php b/apps/user_ldap/lib/Settings/Admin.php new file mode 100644 index 00000000000..11e2627dedd --- /dev/null +++ b/apps/user_ldap/lib/Settings/Admin.php @@ -0,0 +1,115 @@ +<?php +/** + * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.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\User_LDAP\Settings; + + +use OCA\User_LDAP\Configuration; +use OCA\User_LDAP\Helper; +use OCP\IL10N; +use OCP\Settings\IAdmin; +use OCP\Template; + +class Admin implements IAdmin { + + /** @var IL10N */ + private $l; + + public function __construct(IL10N $l) { + $this->l = $l; + } + + /** + * @return Template all parameters are supposed to be assigned + */ + public function render() { + $settings = new Template('user_ldap', 'settings'); + + $helper = new Helper(); + $prefixes = $helper->getServerConfigurationPrefixes(); + $hosts = $helper->getServerConfigurationHosts(); + + $wizardHtml = ''; + $toc = []; + + $wControls = new Template('user_ldap', 'part.wizardcontrols'); + $wControls = $wControls->fetchPage(); + $sControls = new Template('user_ldap', 'part.settingcontrols'); + $sControls = $sControls->fetchPage(); + + $wizTabs = [ + ['tpl' => 'part.wizard-server', 'cap' => $this->l->t('Server')], + ['tpl' => 'part.wizard-userfilter', 'cap' => $this->l->t('Users')], + ['tpl' => 'part.wizard-loginfilter', 'cap' => $this->l->t('Login Attributes')], + ['tpl' => 'part.wizard-groupfilter', 'cap' => $this->l->t('Groups')], + ]; + $wizTabsCount = count($wizTabs); + for($i = 0; $i < $wizTabsCount; $i++) { + $tab = new Template('user_ldap', $wizTabs[$i]['tpl']); + if($i === 0) { + $tab->assign('serverConfigurationPrefixes', $prefixes); + $tab->assign('serverConfigurationHosts', $hosts); + } + $tab->assign('wizardControls', $wControls); + $wizardHtml .= $tab->fetchPage(); + $toc['#ldapWizard'.($i+1)] = $wizTabs[$i]['cap']; + } + + $settings->assign('tabs', $wizardHtml); + $settings->assign('toc', $toc); + $settings->assign('settingControls', $sControls); + + // assign default values + $config = new Configuration('', false); + $defaults = $config->getDefaults(); + foreach($defaults as $key => $default) { + $settings->assign($key.'_default', $default); + } + + return $settings; + } + + /** + * @return string the section ID, e.g. 'sharing' + */ + public function getSection() { + return 'ldap'; + } + + /** + * @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 5; + } + + private function renderControls() { + $controls = new Template('user_ldap', 'part.settingcontrols'); + return $controls->fetchPage(); + + } +} diff --git a/apps/user_ldap/lib/Settings/Section.php b/apps/user_ldap/lib/Settings/Section.php new file mode 100644 index 00000000000..a10bd7cbb93 --- /dev/null +++ b/apps/user_ldap/lib/Settings/Section.php @@ -0,0 +1,67 @@ +<?php +/** + * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.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\User_LDAP\Settings; + +use OCP\IL10N; +use OCP\Settings\ISection; + +class Section implements ISection { + /** @var IL10N */ + private $l; + + public function __construct(IL10N $l) { + $this->l = $l; + } + + /** + * returns the ID of the section. It is supposed to be a lower case string, + * e.g. 'ldap' + * + * @returns string + */ + public function getID() { + return 'ldap'; + } + + /** + * returns the translated name as it should be displayed, e.g. 'LDAP / AD + * integration'. Use the L10N service to translate it. + * + * @return string + */ + public function getName() { + return $this->l->t('LDAP / AD Integration'); + } + + /** + * @return int whether the form should be rather on the top or bottom of + * the settings navigation. The sections are arranged in ascending order of + * the priority values. It is required to return a value between 0 and 99. + * + * E.g.: 70 + */ + public function getPriority() { + return 25; + } +} |