improved handling for getSharingUsersArray

This commit is contained in:
Florin Peter 2013-04-22 12:25:55 +02:00
parent 8790ceba25
commit f6ac34afea
3 changed files with 11 additions and 10 deletions

View 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 );

View 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

View 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 );