diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-06-24 17:04:27 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-06-25 12:11:56 +0200 |
commit | a0b85fc5e4a56ff553f224083cbdf87cd05ec55a (patch) | |
tree | b44fc4364013d26f2f477ab822ebfb5fd6c7891f /apps/files_sharing/lib/updater.php | |
parent | 89f26915152e5aaf357b2aa633d5bea954e4bcc2 (diff) | |
download | nextcloud-server-a0b85fc5e4a56ff553f224083cbdf87cd05ec55a.tar.gz nextcloud-server-a0b85fc5e4a56ff553f224083cbdf87cd05ec55a.zip |
make sure that during share and unshare the etags get propagated correctly
Diffstat (limited to 'apps/files_sharing/lib/updater.php')
-rw-r--r-- | apps/files_sharing/lib/updater.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index 5cb2b638e5a..e114c3ba0ac 100644 --- a/apps/files_sharing/lib/updater.php +++ b/apps/files_sharing/lib/updater.php @@ -133,6 +133,68 @@ class Shared_Updater { } /** + * update etags if a file was shared + * @param array $params + */ + static public function postShareHook($params) { + + if ($params['itemType'] === 'folder' || $params['itemType'] === 'file') { + + $shareWith = $params['shareWith']; + $shareType = $params['shareType']; + + if ($shareType === \OCP\Share::SHARE_TYPE_USER) { + self::correctUsersFolder($shareWith, '/'); + } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { + foreach (\OC_Group::usersInGroup($shareWith) as $user) { + self::correctUsersFolder($user, '/'); + } + } + } + } + + /** + * update etags if a file was unshared + * + * @param array $params + */ + static public function postUnshareHook($params) { + + if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') { + + $deletedShares = isset($params['deletedShares']) ? $params['deletedShares'] : array(); + + foreach ($deletedShares as $share) { + if ($share['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) { + foreach (\OC_Group::usersInGroup($share['shareWith']) as $user) { + self::correctUsersFolder($user, dirname($share['fileTarget'])); + } + } else { + self::correctUsersFolder($share['shareWith'], dirname($share['fileTarget'])); + } + } + } + } + + /** + * update etags if file was unshared from self + * @param array $params + */ + static public function postUnshareFromSelfHook($params) { + if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') { + foreach ($params['unsharedItems'] as $item) { + if ($item['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) { + foreach (\OC_Group::usersInGroup($item['shareWith']) as $user) { + self::correctUsersFolder($user, dirname($item['fileTarget'])); + } + } else { + self::correctUsersFolder($item['shareWith'], dirname($item['fileTarget'])); + } + } + } + } + + /** * clean up oc_share table from files which are no longer exists * * This fixes issues from updates from files_sharing < 0.3.5.6 (ownCloud 4.5) |