diff options
Diffstat (limited to 'lib/private/Settings')
-rw-r--r-- | lib/private/Settings/Admin/Encryption.php | 78 | ||||
-rw-r--r-- | lib/private/Settings/Admin/Logging.php | 87 | ||||
-rw-r--r-- | lib/private/Settings/Admin/Server.php | 114 | ||||
-rw-r--r-- | lib/private/Settings/Admin/Sharing.php | 79 | ||||
-rw-r--r-- | lib/private/Settings/Admin/TipsTricks.php | 72 | ||||
-rw-r--r-- | lib/private/Settings/Manager.php | 297 | ||||
-rw-r--r-- | lib/private/Settings/Section.php | 77 |
7 files changed, 804 insertions, 0 deletions
diff --git a/lib/private/Settings/Admin/Encryption.php b/lib/private/Settings/Admin/Encryption.php new file mode 100644 index 00000000000..38197f71143 --- /dev/null +++ b/lib/private/Settings/Admin/Encryption.php @@ -0,0 +1,78 @@ +<?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 OC\Settings\Admin; + +use OC\Encryption\Manager; +use OCP\IUserManager; +use OCP\Settings\IAdmin; +use OCP\Template; + +class Encryption implements IAdmin { + /** @var Manager */ + private $manager; + + /** @var IUserManager */ + private $userManager; + + public function __construct(Manager $manager, IUserManager $userManager) { + $this->manager = $manager; + $this->userManager = $userManager; + } + + /** + * @return Template all parameters are supposed to be assigned + */ + public function render() { + $parameters = [ + // Encryption API + 'encryptionEnabled' => $this->manager->isEnabled(), + 'encryptionReady' => $this->manager->isReady(), + 'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1, + ]; + + $form = new Template('settings', 'admin/encryption'); + foreach ($parameters as $key => $value) { + $form->assign($key, $value); + } + return $form; + } + + /** + * @return string the section ID, e.g. 'sharing' + */ + public function getSection() { + return 'encryption'; + } + + /** + * @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 0; + } +} diff --git a/lib/private/Settings/Admin/Logging.php b/lib/private/Settings/Admin/Logging.php new file mode 100644 index 00000000000..ead55810ec1 --- /dev/null +++ b/lib/private/Settings/Admin/Logging.php @@ -0,0 +1,87 @@ +<?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 OC\Settings\Admin; + +use OC\Log\File as LogFile; +use OCP\IConfig; +use OCP\Settings\IAdmin; +use OCP\Template; + +class Logging implements IAdmin { + /** @var IConfig */ + private $config; + + public function __construct(IConfig $config) { + $this->config = $config; + } + + /** + * @return Template all parameters are supposed to be assigned + */ + public function render() { + $logType = $this->config->getSystemValue('log_type', 'file'); + $showLog = ($logType === 'file' || $logType === 'owncloud'); + + $numEntriesToLoad = 5; + $entries = LogFile::getEntries($numEntriesToLoad + 1); + $entriesRemaining = count($entries) > $numEntriesToLoad; + $entries = array_slice($entries, 0, $numEntriesToLoad); + + $logFileExists = file_exists(LogFile::getLogFilePath()) ; + $logFileSize = $logFileExists ? filesize(LogFile::getLogFilePath()) : 0; + + $parameters = [ + 'loglevel' => $this->config->getSystemValue('loglevel', 2), + 'entries' => $entries, + 'entriesremain' => $entriesRemaining, + 'doesLogFileExist' => $logFileExists, + 'logFileSize' => $logFileSize, + 'showLog' => $showLog, + ]; + + $form = new Template('settings', 'admin/logging'); + foreach ($parameters as $key => $value) { + $form->assign($key, $value); + } + return $form; + } + + /** + * @return string the section ID, e.g. 'sharing' + */ + public function getSection() { + return 'logging'; + } + + /** + * @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 0; + } +} diff --git a/lib/private/Settings/Admin/Server.php b/lib/private/Settings/Admin/Server.php new file mode 100644 index 00000000000..c0f3584c0af --- /dev/null +++ b/lib/private/Settings/Admin/Server.php @@ -0,0 +1,114 @@ +<?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 OC\Settings\Admin; + +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Platforms\SqlitePlatform; +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\Settings\IAdmin; +use OCP\Template; + +class Server implements IAdmin { + + /** @var IDBConnection|Connection */ + private $db; + + /** @var IConfig */ + private $config; + + public function __construct(IDBConnection $db, IConfig $config) { + $this->db = $db; + $this->config = $config; + } + + /** + * @return Template all parameters are supposed to be assigned + */ + public function render() { + try { + if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { + $invalidTransactionIsolationLevel = false; + } else { + $invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED; + } + } catch (DBALException $e) { + // ignore + $invalidTransactionIsolationLevel = false; + } + + $parameters = [ + // Diagnosis + 'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(), + 'isLocaleWorking' => \OC_Util::isSetLocaleWorking(), + 'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(), + 'checkForWorkingWellKnownSetup', $this->config->getSystemValue('check_for_working_wellknown_setup'), + 'has_fileinfo' => \OC_Util::fileInfoLoaded(), + 'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel, + + // Background jobs + 'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'), + 'cron_log' => $this->config->getSystemValue('cron_log', true), + 'lastcron' => $this->config->getAppValue('core', 'lastcron', false), + + // Mail + 'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'), + 'mail_domain' => $this->config->getSystemValue('mail_domain', ''), + 'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''), + 'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''), + 'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''), + 'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''), + 'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''), + 'mail_smtpauthtype' => $this->config->getSystemValue('mail_smtpauthtype', ''), + 'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false), + 'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''), + 'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''), + ]; + + $form = new Template('settings', 'admin/server'); + foreach ($parameters as $key => $value) { + $form->assign($key, $value); + } + return $form; + } + + /** + * @return string the section ID, e.g. 'sharing' + */ + public function getSection() { + return 'server'; + } + + /** + * @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 0; + } +} diff --git a/lib/private/Settings/Admin/Sharing.php b/lib/private/Settings/Admin/Sharing.php new file mode 100644 index 00000000000..7fefa4008a0 --- /dev/null +++ b/lib/private/Settings/Admin/Sharing.php @@ -0,0 +1,79 @@ +<?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 OC\Settings\Admin; + +use OCP\IConfig; +use OCP\Settings\IAdmin; +use OCP\Template; + +class Sharing implements IAdmin { + /** @var IConfig */ + private $config; + + public function __construct(IConfig $config) { + $this->config = $config; + } + + /** + * @return Template all parameters are supposed to be assigned + */ + public function render() { + $excludeGroupsList = !is_null(json_decode($this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''))) + ? implode('|', $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '')) : ''; + + $parameters = [ + // Built-In Sharing + 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'), + 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'), + 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'), + 'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'), + 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false, + 'shareExcludedGroupsList' => $excludeGroupsList, + ]; + + $form = new Template('settings', 'admin/sharing'); + foreach ($parameters as $key => $value) { + $form->assign($key, $value); + } + return $form; + } + + /** + * @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 0; + } +} diff --git a/lib/private/Settings/Admin/TipsTricks.php b/lib/private/Settings/Admin/TipsTricks.php new file mode 100644 index 00000000000..a0465f5e3ca --- /dev/null +++ b/lib/private/Settings/Admin/TipsTricks.php @@ -0,0 +1,72 @@ +<?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 OC\Settings\Admin; + +use OCP\IConfig; +use OCP\Settings\IAdmin; +use OCP\Template; + +class TipsTricks implements IAdmin { + /** @var IConfig */ + private $config; + + public function __construct(IConfig $config) { + $this->config = $config; + } + + /** + * @return Template all parameters are supposed to be assigned + */ + public function render() { + $databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false); + + $parameters = [ + 'databaseOverload' => $databaseOverload, + ]; + + $form = new Template('settings', 'admin/tipstricks'); + foreach ($parameters as $key => $value) { + $form->assign($key, $value); + } + return $form; + } + + /** + * @return string the section ID, e.g. 'sharing' + */ + public function getSection() { + return 'tips-tricks'; + } + + /** + * @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 0; + } +} diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php new file mode 100644 index 00000000000..b7d02ddd340 --- /dev/null +++ b/lib/private/Settings/Manager.php @@ -0,0 +1,297 @@ +<?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 OC\Settings; + +use OCP\AppFramework\QueryException; +use OCP\Encryption\IManager as EncryptionManager; +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\IL10N; +use OCP\ILogger; +use OCP\IUserManager; +use OCP\Settings\IAdmin; +use OCP\Settings\IManager; +use OCP\Settings\ISection; + +class Manager implements IManager { + const TABLE_ADMIN_SETTINGS = 'admin_settings'; + const TABLE_ADMIN_SECTIONS = 'admin_sections'; + + /** @var ILogger */ + /** @var ILogger */ + private $log; + + /** @var IDBConnection */ + private $dbc; + + /** @var IL10N */ + private $l; + + /** @var IConfig */ + private $config; + + /** @var EncryptionManager */ + private $encryptionManager; + + /** @var IUserManager */ + private $userManager; + + public function __construct( + ILogger $log, + IDBConnection $dbc, + IL10N $l, + IConfig $config, + EncryptionManager $encryptionManager, + IUserManager $userManager + ) { + $this->log = $log; + $this->dbc = $dbc; + $this->l = $l; + $this->config = $config; + $this->encryptionManager = $encryptionManager; + $this->userManager = $userManager; + } + + /** + * @inheritdoc + */ + public function setupSettings(array $settings) { + if(isset($settings[IManager::KEY_ADMIN_SECTION])) { + $this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]); + } + if(isset($settings[IManager::KEY_ADMIN_SETTINGS])) { + $this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]); + } + } + + private function setupAdminSection($sectionClassName) { + if(!class_exists($sectionClassName)) { + $this->log->debug('Could not find admin section class ' . $sectionClassName); + return; + } + try { + $section = $this->query($sectionClassName); + } catch (QueryException $e) { + // cancel + return; + } + + if(!$section instanceof ISection) { + $this->log->error( + 'Admin section instance must implement \OCP\ISection. Invalid class: {class}', + ['class' => $sectionClassName] + ); + return; + } + if(!$this->hasAdminSection($section)) { + $this->addAdminSection($section); + } + } + + private function addAdminSection(ISection $section) { + $this->add(self::TABLE_ADMIN_SECTIONS, [ + 'id' => $section->getID(), + 'class' => get_class($section), + 'priority' => $section->getPriority(), + ]); + } + + private function addAdminSettings(IAdmin $settings) { + $this->add(self::TABLE_ADMIN_SETTINGS, [ + 'class' => get_class($settings), + 'section' => $settings->getSection(), + 'priority' => $settings->getPriority(), + ]); + } + + private function add($table, $values) { + $query = $this->dbc->getQueryBuilder(); + $values = array_map(function($value) use ($query) { + return $query->createNamedParameter($value); + }, $values); + $query->insert($table)->values($values); + $query->execute(); + } + + private function hasAdminSection(ISection $section) { + return $this->has(self::TABLE_ADMIN_SECTIONS, 'id', $section->getID()); + } + + private function hasAdminSettings($pageClass) { + return $this->has(self::TABLE_ADMIN_SETTINGS, 'class', $pageClass); + } + + + private function has($table, $idCol, $id) { + $query = $this->dbc->getQueryBuilder(); + $query->select($idCol) + ->from($table) + ->where($query->expr()->eq($idCol, $query->createNamedParameter($id))) + ->setMaxResults(1); + + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + return (bool) $row; + } + + private function setupAdminSettings($settingsClassName) { + if(!class_exists($settingsClassName)) { + $this->log->debug('Could not find admin section class ' . $settingsClassName); + return; + } + + try { + $settings = $this->query($settingsClassName); + } catch (QueryException $e) { + // cancel + return; + } + + if(!$settings instanceof IAdmin) { + $this->log->error( + 'Admin section instance must implement \OCP\ISection. Invalid class: {class}', + ['class' => $settingsClassName] + ); + return; + } + if(!$this->hasAdminSettings($settings)) { + $this->addAdminSettings($settings); + } + } + + private function query($className) { + try { + return \OC::$server->query($className); + } catch (QueryException $e) { + $this->log->logException($e); + throw $e; + } + } + + /** + * returns a list of the admin sections + * + * @return ISection[] + */ + public function getAdminSections() { + $query = $this->dbc->getQueryBuilder(); + $query->select(['class', 'priority']) + ->from(self::TABLE_ADMIN_SECTIONS); + + // built-in sections + $sections = [ + 0 => [new Section('server', $this->l->t('Server Settings'), 0)], + 5 => [new Section('sharing', $this->l->t('Sharing'), 0)], + //15 => [new Section('collaboration', $this->l->t('Collaboration'), 0)], + //30 => [new Section('theming', $this->l->t('Theming'), 0)], + 45 => [new Section('encryption', $this->l->t('Encryption'), 0)], + 90 => [new Section('logging', $this->l->t('Logging'), 0)], + 98 => [new Section('additional', $this->l->t('Additional Settings'), 0)], + 99 => [new Section('tips-tricks', $this->l->t('Tips & Tricks'), 0)], + ]; + + $result = $query->execute(); + while($row = $result->fetch()) { + if(!isset($sections[$row['priority']])) { + $sections[$row['priority']] = []; + } + try { + $sections[$row['priority']][] = $this->query($row['class']); + } catch (QueryException $e) { + // skip + } + } + $result->closeCursor(); + + ksort($sections); + return $sections; + } + + private function getBuiltInAdminSettings($section) { + $forms = []; + try { + if($section === 'server') { + /** @var IAdmin $form */ + $form = new Admin\Server($this->dbc, $this->config); + $forms[$form->getPriority()] = [$form]; + } + if($section === 'encryption') { + /** @var IAdmin $form */ + $form = new Admin\Encryption($this->encryptionManager, $this->userManager); + $forms[$form->getPriority()] = [$form]; + } + if($section === 'sharing') { + /** @var IAdmin $form */ + $form = new Admin\Sharing($this->config); + $forms[$form->getPriority()] = [$form]; + } + if($section === 'logging') { + /** @var IAdmin $form */ + $form = new Admin\Logging($this->config); + $forms[$form->getPriority()] = [$form]; + } + if($section === 'tips-tricks') { + /** @var IAdmin $form */ + $form = new Admin\TipsTricks($this->config); + $forms[$form->getPriority()] = [$form]; + } + } catch (QueryException $e) { + // skip + } + return $forms; + } + + private function getAdminSettingsFromDB($section, &$settings) { + $query = $this->dbc->getQueryBuilder(); + $query->select(['class', 'priority']) + ->from(self::TABLE_ADMIN_SETTINGS) + ->where($query->expr()->eq('section', $this->dbc->getQueryBuilder()->createParameter('section'))) + ->setParameter('section', $section); + + $result = $query->execute(); + while($row = $result->fetch()) { + if(!isset($settings[$row['priority']])) { + $settings[$row['priority']] = []; + } + try { + $settings[$row['priority']][] = $this->query($row['class']); + } catch (QueryException $e) { + // skip + } + } + $result->closeCursor(); + + ksort($settings); + } + + public function getAdminSettings($section) { + $settings = $this->getBuiltInAdminSettings($section); + $this->getAdminSettingsFromDB($section, $settings); + return $settings; + } + + +} diff --git a/lib/private/Settings/Section.php b/lib/private/Settings/Section.php new file mode 100644 index 00000000000..2ea614b365e --- /dev/null +++ b/lib/private/Settings/Section.php @@ -0,0 +1,77 @@ +<?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 OC\Settings; + + +use OCP\Settings\ISection; + +class Section implements ISection { + + /** @var string */ + private $id; + + /** @var string */ + private $name; + + /** @var int */ + private $priority; + + public function __construct($id, $name, $priority) { + $this->id = $id; + $this->name = $name; + $this->priority = $priority; + } + + /** + * returns the ID of the section. It is supposed to be a lower case string, + * e.g. 'ldap' + * + * @returns string + */ + public function getID() { + return $this->id; + } + + /** + * 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->name; + } + + /** + * @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 $this->priority; + } +} |