summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-11 01:41:18 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-11 01:41:18 +0200
commitf3b15a9ab97ce4498bafc731dc24350e98a7cb51 (patch)
tree138f9aa4ea52bcd7c098d8454c1bca1fd6e1dcba /lib
parent0fc34c99f4e1dbe26e5074102f48f75d70fe97d0 (diff)
downloadnextcloud-server-f3b15a9ab97ce4498bafc731dc24350e98a7cb51.tar.gz
nextcloud-server-f3b15a9ab97ce4498bafc731dc24350e98a7cb51.zip
fixes, improvements, and another app:
* setupSettings now also triggered on enable * fixes detection of present admin section or settings in the DB * add update routine in such cases * encryption app migrated
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Settings/Manager.php67
-rw-r--r--lib/private/legacy/app.php6
2 files changed, 64 insertions, 9 deletions
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
index b7d02ddd340..fa762003c1d 100644
--- a/lib/private/Settings/Manager.php
+++ b/lib/private/Settings/Manager.php
@@ -104,8 +104,10 @@ class Manager implements IManager {
);
return;
}
- if(!$this->hasAdminSection($section)) {
+ if(!$this->hasAdminSection(get_class($section))) {
$this->addAdminSection($section);
+ } else {
+ $this->updateAdminSection($section);
}
}
@@ -134,20 +136,64 @@ class Manager implements IManager {
$query->execute();
}
- private function hasAdminSection(ISection $section) {
- return $this->has(self::TABLE_ADMIN_SECTIONS, 'id', $section->getID());
+ private function updateAdminSettings(IAdmin $settings) {
+ $this->update(
+ self::TABLE_ADMIN_SETTINGS,
+ 'class',
+ get_class($settings),
+ [
+ 'section' => $settings->getSection(),
+ 'priority' => $settings->getPriority(),
+ ]
+ );
}
- private function hasAdminSettings($pageClass) {
- return $this->has(self::TABLE_ADMIN_SETTINGS, 'class', $pageClass);
+ private function updateAdminSection(ISection $section) {
+ $this->update(
+ self::TABLE_ADMIN_SECTIONS,
+ 'class',
+ get_class($section),
+ [
+ 'id' => $section->getID(),
+ 'priority' => $section->getPriority(),
+ ]
+ );
+ }
+
+ private function update($table, $idCol, $id, $values) {
+ $query = $this->dbc->getQueryBuilder();
+ $query->update($table);
+ foreach($values as $key => $value) {
+ $query->set($key, $query->createNamedParameter($value));
+ }
+ $query
+ ->where($query->expr()->eq($idCol, $query->createParameter($idCol)))
+ ->setParameter($idCol, $id)
+ ->execute();
+ }
+
+ /**
+ * @param string $className
+ * @return bool
+ */
+ private function hasAdminSection($className) {
+ return $this->has(self::TABLE_ADMIN_SECTIONS, $className);
+ }
+
+ /**
+ * @param string $className
+ * @return bool
+ */
+ private function hasAdminSettings($className) {
+ return $this->has(self::TABLE_ADMIN_SETTINGS, $className);
}
- private function has($table, $idCol, $id) {
+ private function has($table, $className) {
$query = $this->dbc->getQueryBuilder();
- $query->select($idCol)
+ $query->select('class')
->from($table)
- ->where($query->expr()->eq($idCol, $query->createNamedParameter($id)))
+ ->where($query->expr()->eq('class', $query->createNamedParameter($className)))
->setMaxResults(1);
$result = $query->execute();
@@ -164,6 +210,7 @@ class Manager implements IManager {
}
try {
+ /** @var IAdmin $settings */
$settings = $this->query($settingsClassName);
} catch (QueryException $e) {
// cancel
@@ -177,8 +224,10 @@ class Manager implements IManager {
);
return;
}
- if(!$this->hasAdminSettings($settings)) {
+ if(!$this->hasAdminSettings(get_class($settings))) {
$this->addAdminSettings($settings);
+ } else {
+ $this->updateAdminSettings($settings);
}
}
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 802c4b908b4..4144f3f6cf5 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -345,6 +345,12 @@ class OC_App {
} else {
$appManager->enableApp($app);
}
+
+ $info = self::getAppInfo($app);
+ if(isset($info['settings']) && is_array($info['settings'])) {
+ self::loadApp($app, false);
+ \OC::$server->getSettingsManager()->setupSettings($info['settings']);
+ }
}
/**