]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove group restrictions when those are not allowed anymore 2930/head
authorJoas Schilling <coding@schilljs.com>
Wed, 4 Jan 2017 09:40:14 +0000 (10:40 +0100)
committerJoas Schilling <coding@schilljs.com>
Wed, 4 Jan 2017 09:40:14 +0000 (10:40 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/App/AppManager.php
lib/private/legacy/app.php
lib/public/App/IAppManager.php

index fca5c9b87ac202245f3d9c196567aac7d0edf815..6b819ef7ac14ac5d4b506c16509b7bd62a8e3f29 100644 (file)
@@ -220,6 +220,21 @@ class AppManager implements IAppManager {
                $this->clearAppsCache();
        }
 
+       /**
+        * Whether a list of types contains a protected app type
+        *
+        * @param string[] $types
+        * @return bool
+        */
+       public function hasProtectedAppType($types) {
+               if (empty($types)) {
+                       return false;
+               }
+
+               $protectedTypes = array_intersect($this->protectedAppTypes, $types);
+               return !empty($protectedTypes);
+       }
+
        /**
         * Enable an app only for specific groups
         *
index adf29601ac6d142b5ccbbd20085e82264f3d07f3..8ef7e08c733a14b196094fd7341279488feba5e9 100644 (file)
@@ -273,9 +273,17 @@ class OC_App {
                        $appTypes = implode(',', $appData['types']);
                } else {
                        $appTypes = '';
+                       $appData['types'] = [];
                }
 
                \OC::$server->getAppConfig()->setValue($app, 'types', $appTypes);
+
+               if (\OC::$server->getAppManager()->hasProtectedAppType($appData['types'])) {
+                       $enabled = \OC::$server->getAppConfig()->getValue($app, 'enabled', 'yes');
+                       if ($enabled !== 'yes' && $enabled !== 'no') {
+                               \OC::$server->getAppConfig()->setValue($app, 'enabled', 'yes');
+                       }
+               }
        }
 
        /**
index 057a964ce0a66fb2aac59db913f8a30f2661f103..72c99777124a945ec15606c661d9d416d288f47d 100644 (file)
@@ -61,6 +61,15 @@ interface IAppManager {
         */
        public function enableApp($appId);
 
+       /**
+        * Whether a list of types contains a protected app type
+        *
+        * @param string[] $types
+        * @return bool
+        * @since 12.0.0
+        */
+       public function hasProtectedAppType($types);
+
        /**
         * Enable an app only for specific groups
         *