summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-05-19 17:34:57 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-06-23 12:37:41 +0200
commit28fd18de43ee4371c614782a2a4b9cf0eb497faa (patch)
tree4c93b484da2c6cfbc87142438e78725936b71fee /lib
parentf87318296578178ceed8ba18c0a3f99e4aa11334 (diff)
downloadnextcloud-server-28fd18de43ee4371c614782a2a4b9cf0eb497faa.tar.gz
nextcloud-server-28fd18de43ee4371c614782a2a4b9cf0eb497faa.zip
add missing pieces to Settings Manager and fix and extend its unit tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Settings/Manager.php30
-rw-r--r--lib/private/Settings/Mapper.php32
2 files changed, 60 insertions, 2 deletions
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
index 62a74b706f6..7da8bfe65df 100644
--- a/lib/private/Settings/Manager.php
+++ b/lib/private/Settings/Manager.php
@@ -464,6 +464,22 @@ class Manager implements IManager {
15 => [new Section('sync-clients', $this->l->t('Sync clients'), 0, $this->url->imagePath('settings', 'change.svg'))],
98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
];
+
+ $rows = $this->mapper->getPersonalSectionsFromDB();
+
+ foreach ($rows as $row) {
+ if (!isset($sections[$row['priority']])) {
+ $sections[$row['priority']] = [];
+ }
+ try {
+ $sections[$row['priority']][] = $this->query($row['class']);
+ } catch (QueryException $e) {
+ // skip
+ }
+ }
+
+ ksort($sections);
+
return $sections;
}
@@ -472,6 +488,20 @@ class Manager implements IManager {
*/
public function getPersonalSettings($section) {
$settings = $this->getBuiltInPersonalSettings($section);
+ $dbRows = $this->mapper->getPersonalSettingsFromDB($section);
+
+ foreach ($dbRows as $row) {
+ if (!isset($settings[$row['priority']])) {
+ $settings[$row['priority']] = [];
+ }
+ try {
+ $settings[$row['priority']][] = $this->query($row['class']);
+ } catch (QueryException $e) {
+ // skip
+ }
+ }
+
+ ksort($settings);
return $settings;
}
}
diff --git a/lib/private/Settings/Mapper.php b/lib/private/Settings/Mapper.php
index 44ba7dd9cbe..999efb0d872 100644
--- a/lib/private/Settings/Mapper.php
+++ b/lib/private/Settings/Mapper.php
@@ -85,11 +85,39 @@ class Mapper {
* @return array[] [['class' => string, 'priority' => int], ...]
*/
public function getAdminSectionsFromDB() {
+ return $this->getSectionsFromDB('admin');
+ }
+
+ /**
+ * Get the configured admin sections from the database
+ *
+ * @return array[] [['class' => string, 'priority' => int], ...]
+ */
+ public function getPersonalSectionsFromDB() {
+ return $this->getSectionsFromDB('personal');
+ }
+
+ /**
+ * Get the configured sections from the database by table
+ *
+ * @param string $type either 'personal' or 'admin'
+ * @return array[] [['class' => string, 'priority' => int], ...]
+ */
+ public function getSectionsFromDB($type) {
+ if($type === 'personal') {
+ $sectionsTable = self::TABLE_ADMIN_SECTIONS;
+ $settingsTable = self::TABLE_ADMIN_SETTINGS;
+ } else if($type === 'admin') {
+ $sectionsTable = self::TABLE_PERSONAL_SECTIONS;
+ $settingsTable = self::TABLE_PERSONAL_SETTINGS;
+ } else {
+ throw new \InvalidArgumentException('"admin" or "personal" expected');
+ }
$query = $this->dbc->getQueryBuilder();
$query->selectDistinct('s.class')
->addSelect('s.priority')
- ->from(self::TABLE_ADMIN_SECTIONS, 's')
- ->from(self::TABLE_ADMIN_SETTINGS, 'f')
+ ->from($sectionsTable, 's')
+ ->from($settingsTable, 'f')
->where($query->expr()->eq('s.id', 'f.section'));
$result = $query->execute();
return array_map(function ($row) {