summaryrefslogtreecommitdiffstats
path: root/lib/private/Settings/Manager.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-15 20:03:19 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-16 00:56:17 +0200
commit9edca39b49f6b7fcfc4e43b61b88204222ad5e91 (patch)
tree71dbdb71ecb3eaa7659ad2be9b89f6db13e3a8b0 /lib/private/Settings/Manager.php
parent6c6338b81072ba58b662d2f03cab6cfdbfdf4a18 (diff)
downloadnextcloud-server-9edca39b49f6b7fcfc4e43b61b88204222ad5e91.tar.gz
nextcloud-server-9edca39b49f6b7fcfc4e43b61b88204222ad5e91.zip
attempt to remove section and settings entries when an app got disabled
Diffstat (limited to 'lib/private/Settings/Manager.php')
-rw-r--r--lib/private/Settings/Manager.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
index 1304a60949e..8fdc7fefbb3 100644
--- a/lib/private/Settings/Manager.php
+++ b/lib/private/Settings/Manager.php
@@ -94,6 +94,25 @@ class Manager implements IManager {
}
/**
+ * attempts to remove an apps section and/or settings entry. A listener is
+ * added centrally making sure that this method is called ones an app was
+ * disabled.
+ *
+ * @param string $appId
+ * @since 9.1.0
+ */
+ public function onAppDisabled($appId) {
+ $appInfo = \OC_App::getAppInfo($appId); // hello static legacy
+
+ if(isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) {
+ $this->remove(self::TABLE_ADMIN_SECTIONS, $appInfo['settings'][IManager::KEY_ADMIN_SECTION]);
+ }
+ if(isset($settings['settings'][IManager::KEY_ADMIN_SETTINGS])) {
+ $this->remove(self::TABLE_ADMIN_SETTINGS, $appInfo['settings'][IManager::KEY_ADMIN_SETTINGS]);
+ }
+ }
+
+ /**
* @param string $sectionClassName
*/
private function setupAdminSection($sectionClassName) {
@@ -222,6 +241,20 @@ class Manager implements IManager {
return (bool) $row;
}
+ /**
+ * deletes an settings or admin entry from the given table
+ *
+ * @param $table
+ * @param $className
+ */
+ private function remove($table, $className) {
+ $query = $this->dbc->getQueryBuilder();
+ $query->delete($table)
+ ->where($query->expr()->eq('class', $query->createNamedParameter($className)));
+
+ $query->execute();
+ }
+
private function setupAdminSettings($settingsClassName) {
if(!class_exists($settingsClassName)) {
$this->log->debug('Could not find admin section class ' . $settingsClassName);