summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-12-09 13:07:57 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-12-09 13:07:57 +0100
commit54dbe5b8d5faf415510c490927ac737441afb43b (patch)
tree8e45db33b8c8fed97bf7bed4363ef7809c7f524b /apps/files_sharing/lib
parentbffd7a1d935b7e22d8ac8fed9650d3d918766d68 (diff)
parentd38949f4232d6bbbba8ce42cb22784e5c2c63472 (diff)
downloadnextcloud-server-54dbe5b8d5faf415510c490927ac737441afb43b.tar.gz
nextcloud-server-54dbe5b8d5faf415510c490927ac737441afb43b.zip
Merge pull request #20989 from owncloud/fix_20769
Update parent when moving share into recieved share
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/updater.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php
index 26044cc1c8e..2d165a5df04 100644
--- a/apps/files_sharing/lib/updater.php
+++ b/apps/files_sharing/lib/updater.php
@@ -58,6 +58,47 @@ class Shared_Updater {
*/
static public function renameHook($params) {
self::renameChildren($params['oldpath'], $params['newpath']);
+ self::moveShareToShare($params['newpath']);
+ }
+
+ /**
+ * Fix for https://github.com/owncloud/core/issues/20769
+ *
+ * The owner is allowed to move their files (if they are shared) into a receiving folder
+ * In this case we need to update the parent of the moved share. Since they are
+ * effectively handing over ownership of the file the rest of the code needs to know
+ * they need to build up the reshare tree.
+ *
+ * @param string $path
+ */
+ static private function moveShareToShare($path) {
+ $userFolder = \OC::$server->getUserFolder();
+ $src = $userFolder->get($path);
+
+ $type = $src instanceof \OCP\Files\File ? 'file' : 'folder';
+ $shares = \OCP\Share::getItemShared($type, $src->getId());
+
+ // If the path we move is not a share we don't care
+ if (empty($shares)) {
+ return;
+ }
+
+ // Check if the destination is inside a share
+ $mountManager = \OC::$server->getMountManager();
+ $dstMount = $mountManager->find($src->getPath());
+ if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) {
+ return;
+ }
+
+ $parenShare = $dstMount->getShare();
+
+ foreach ($shares as $share) {
+ $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $qb->update('share')
+ ->set('parent', $qb->createNamedParameter($parenShare['id']))
+ ->where($qb->expr()->eq('id', $qb->createNamedParameter($share['id'])))
+ ->execute();
+ }
}
/**