]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix addUserToGroup hook of the share code
authorMorris Jobke <hey@morrisjobke.de>
Fri, 22 Jan 2016 13:17:37 +0000 (14:17 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Fri, 22 Jan 2016 13:17:37 +0000 (14:17 +0100)
* sets up the filesystem of the user that is added to a group
  to properly accept shares
* fixes #18499

lib/private/share/hooks.php

index 1fa233916d1b2e45c312caafba2985cc6aeff56a..0caa1a3aa8ad58b88b37d8cb4d8c7b508c1a32f1 100644 (file)
@@ -55,6 +55,15 @@ class Hooks extends \OC\Share\Constants {
         * @param array $arguments
         */
        public static function pre_addToGroup($arguments) {
+               $currentUser = \OC::$server->getUserSession()->getUser();
+               $currentUserID = is_null($currentUser) ? '' : $currentUser->getUID();
+
+               // setup filesystem for added user if it isn't the current user
+               if($currentUserID !== $arguments['uid']) {
+                       \OC_Util::tearDownFS();
+                       \OC_Util::setupFS($arguments['uid']);
+               }
+
                /** @var \OC\DB\Connection $db */
                $db = \OC::$server->getDatabaseConnection();
 
@@ -120,6 +129,14 @@ class Hooks extends \OC\Share\Constants {
                                ];
                        }
                }
+
+               // re-setup old filesystem state
+               if($currentUserID !== $arguments['uid']) {
+                       \OC_Util::tearDownFS();
+                       if($currentUserID !== '') {
+                               \OC_Util::setupFS($currentUserID);
+                       }
+               }
        }
 
        /**