]> source.dussan.org Git - nextcloud-server.git/commitdiff
improved handling for getSharingUsersArray
authorFlorin Peter <github@florin-peter.de>
Mon, 22 Apr 2013 10:25:55 +0000 (12:25 +0200)
committerFlorin Peter <github@florin-peter.de>
Mon, 22 Apr 2013 10:25:55 +0000 (12:25 +0200)
apps/files_encryption/lib/proxy.php
apps/files_encryption/lib/stream.php
apps/files_encryption/lib/util.php

index 505fad440d5d2510432d2e0d98c27d3407d951f1..bc6280ff61bd10ea8bc2ef777c443ac7a9eb5784 100644 (file)
@@ -134,7 +134,7 @@ class Proxy extends \OC_FileProxy {
                                
                                $sharingEnabled = \OCP\Share::isEnabled();
                                
-                               $uniqueUserIds = $util->getSharingUsersArray( $sharingEnabled, $filePath );
+                               $uniqueUserIds = $util->getSharingUsersArray( $sharingEnabled, $filePath, $userId );
                                
                                // Fetch public keys for all users who will share the file
                                $publicKeys = Keymanager::getPublicKeys( $rootView, $uniqueUserIds );
index c12fab783b331077f4e78389f3a20d85a8cf0f2c..6fb95934c32be68e337386fbee3cfff4990001c3 100644 (file)
@@ -335,14 +335,10 @@ class Stream {
                
                $util = new Util( $this->rootView, $this->userId );
                
-               // Get all users sharing the file
-               $uniqueUserIds = $util->getSharingUsersArray( $sharingEnabled, $this->relPath );
+               // Get all users sharing the file includes current user
+               $uniqueUserIds = $util->getSharingUsersArray( $sharingEnabled, $this->relPath, $this->userId);
 
-        // allways add current user
-        $uniqueUserIds[] = $this->userId;
-        array_unique( $uniqueUserIds );
-
-               // Fetch public keys for all sharing users
+        // Fetch public keys for all sharing users
                $publicKeys = Keymanager::getPublicKeys( $this->rootView, $uniqueUserIds );
 
         // Encrypt enc key for all sharing users
index b3df7f0db03882872c71af8d3eeacd2f4b604f4b..e69314e099a5be2d59f38b2c92361ff1f2a0c4e0 100644 (file)
@@ -848,7 +848,7 @@ class Util {
         * @brief Find, sanitise and format users sharing a file
         * @note This wraps other methods into a portable bundle
         */
-       public function getSharingUsersArray( $sharingEnabled, $filePath ) {
+       public function getSharingUsersArray( $sharingEnabled, $filePath, $currentUserId = false ) {
 
                // Check if key recovery is enabled
                $recoveryEnabled = $this->recoveryEnabled();
@@ -878,7 +878,12 @@ class Util {
                        $userIds[] = $adminUid;
                        
                }
-               
+
+        // add current user if given
+        if($currentUserId != false) {
+            $userIds[] = $currentUserId;
+        }
+
                // Remove duplicate UIDs
                $uniqueUserIds = array_unique ( $userIds );