From 33e0dfeecbcfba7c3caa6765f156cd06d7dfdb13 Mon Sep 17 00:00:00 2001
From: Florin Peter <github@florin-peter.de>
Date: Sat, 11 May 2013 00:25:32 +0200
Subject: [PATCH] sharing with group should work now

---
 apps/files_encryption/hooks/hooks.php | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index e8cd4ade71..619a4d1bfe 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -292,10 +292,16 @@ class Hooks {
 			foreach ( $allFiles as $path ) {
 			
 				$usersSharing = $util->getSharingUsersArray( $sharingEnabled, $path );
-				
-				// Because this is a pre_share hook, the user 
-				// being shared to is not yet included; add them
-				$usersSharing[] = $params['shareWith'];
+
+                // check if we share to a group
+                if($params['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) {
+                    $usersSharing[] = reset(\OC_Group::usersInGroup($params['shareWith']));
+                } else {
+                    // Because this is a pre_share hook, the user
+                    // being shared to is not yet included; add them
+                    $usersSharing[] = $params['shareWith'];
+                }
+
 
 				// Attempt to set shareKey
  				if ( ! $util->setSharedFileKeyfiles( $session, $usersSharing, $path ) ) {
@@ -310,8 +316,7 @@ class Hooks {
 				// Set flag var 'run' to notify emitting 
 				// script that hook execution failed
 				$params['run']->run = false;
-				
-				// TODO: Make sure files_sharing provides user 
+                // TODO: Make sure files_sharing provides user
 				// feedback on failed share
 				
 			}
-- 
GitLab