summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2012-05-09 13:51:24 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2012-05-09 13:51:52 -0400
commit14b240a3f447d9b815183894acbcbe6f90ff4635 (patch)
tree3c82c633b3f1d70bb6228ee95740cfb60a1c8fd8 /apps/files_sharing
parenta589a700e1d938a535c724d9ceb27bc51891d967 (diff)
downloadnextcloud-server-14b240a3f447d9b815183894acbcbe6f90ff4635.tar.gz
nextcloud-server-14b240a3f447d9b815183894acbcbe6f90ff4635.zip
Still trying to fix some sharing use cases
Diffstat (limited to 'apps/files_sharing')
-rwxr-xr-xapps/files_sharing/lib_share.php30
-rwxr-xr-xapps/files_sharing/sharedstorage.php3
2 files changed, 23 insertions, 10 deletions
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index b6346b97cf8..b9542fb659e 100755
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -76,7 +76,7 @@ class OC_Share {
throw new Exception("This item is already shared with ".$uid);
}
// Check if the target already exists for the user, if it does append a number to the name
- $sharedFolder = "/".$uid."/files/Shared";
+ $sharedFolder = '/'.$uid.'/files/Shared';
$target = $sharedFolder."/".basename($source);
if (self::getSource($target)) {
if ($pos = strrpos($target, ".")) {
@@ -98,8 +98,14 @@ class OC_Share {
$uid = $uid."@".$gid;
}
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
- // Update mtime of shared folder to invoke a file cache rescan
- OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder);
+ // Emit post_write hook to invoke a file cache rescan
+ $storage = OC_Filesystem::getStorage($sharedFolder);
+ if (!$storage->is_dir($sharedFolder)) {
+ $storage->mkdir($sharedFolder);
+ OCP\Util::emitHook('OC_Filesystem', 'post_write', array('path' => $sharedFolder));
+ } else {
+ OCP\Util::emitHook('OC_Filesystem', 'post_write', array('path' => $target));
+ }
}
}
}
@@ -374,12 +380,22 @@ class OC_Share {
*/
public static function unshare($source, $uid_shared_with) {
$source = self::cleanPath($source);
+ $uid_owner = OCP\USER::getUser();
$query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
- $query->execute(array(strlen($source), $source, OCP\USER::getUser()));
- // Update mtime of shared folder to invoke a file cache rescan
+ $query->execute(array(strlen($source), $source, $uid_owner));
if ($uid_shared_with != self::PUBLICLINK) {
- $sharedFolder = '/'.$uid_shared_with.'/files/Shared';
- OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder);
+ if (OC_Group::groupExists($uid_shared_with)) {
+ $uid_shared_with = OC_Group::usersInGroup($uid_shared_with);
+ // Remove the owner from the list of users in the group
+ $uid_shared_with = array_diff($uid_shared_with, array($uid_owner));
+ } else {
+ $uid_shared_with = array($uid_shared_with);
+ }
+ foreach ($uid_shared_with as $uid) {
+ $sharedFolder = '/'.$uid.'/files/'.'Shared';
+ // Emit post_write hook to invoke a file cache rescan
+ OCP\Util::emitHook('OC_Filesystem', 'post_write', array('path' => $sharedFolder));
+ }
}
}
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index c7c2131f872..f9923dcfe90 100755
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -22,9 +22,6 @@
require_once( 'lib_share.php' );
-if (OC_Filesystem::$loaded and !OC_Filesystem::is_dir('/Shared')) {
- OC_Filesystem::mkdir('/Shared');
-}
OC_Filesystem::mount('OC_Filestorage_Shared',array('datadir'=>'/'.OCP\USER::getUser().'/files/Shared'),'/'.OCP\USER::getUser().'/files/Shared/');
/**