diff options
author | Greta Doci <gretadoci@gmail.com> | 2019-06-25 15:20:06 +0200 |
---|---|---|
committer | Greta Doci <gretadoci@gmail.com> | 2019-06-27 20:17:50 +0200 |
commit | 5898e87e0f69ed4a3be73cd044c19d7c4872b639 (patch) | |
tree | 5b5c2914f5d8523db948487b814b95262a10ab09 /lib/base.php | |
parent | dc9e73a6df24136ea18bf630ae07cb333817a8ef (diff) | |
download | nextcloud-server-5898e87e0f69ed4a3be73cd044c19d7c4872b639.tar.gz nextcloud-server-5898e87e0f69ed4a3be73cd044c19d7c4872b639.zip |
Remove deleted groups from app restrictions fixes #15823
Signed-off-by: Greta Doci <gretadoci@gmail.com>
Diffstat (limited to 'lib/base.php')
-rw-r--r-- | lib/base.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/base.php b/lib/base.php index 30d57153de9..7812922c168 100644 --- a/lib/base.php +++ b/lib/base.php @@ -717,6 +717,7 @@ class OC { self::registerEncryptionHooks(); self::registerAccountHooks(); self::registerResourceCollectionHooks(); + self::registerAppRestrictionsHooks(); // Make sure that the application class is not loaded before the database is setup if ($systemConfig->getValue("installed", false)) { @@ -848,6 +849,30 @@ class OC { \OCP\Util::connectHook('OC_User', 'changeUser', $hookHandler, 'changeUserHook'); } + private static function registerAppRestrictionsHooks() { + $groupManager = self::$server->query(\OCP\IGroupManager::class); + $groupManager->listen ('\OC\Group', 'postDelete', function (\OCP\IGroup $group) { + $appManager = self::$server->getAppManager(); + $apps = $appManager->getEnabledAppsForGroup($group); + foreach ($apps as $appId) { + $restrictions = $appManager->getAppRestriction($appId); + if (empty($restrictions)) { + continue; + } + $key = array_search($group->getGID(), $restrictions); + unset($restrictions[$key]); + $restrictions = array_values($restrictions); + if (empty($restrictions)) { + $appManager->disableApp($appId); + } + else{ + $appManager->enableAppForGroups($appId, $restrictions); + } + + } + }); + } + private static function registerResourceCollectionHooks() { \OC\Collaboration\Resources\Listener::register(\OC::$server->getEventDispatcher()); } |