diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-12-10 13:57:17 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-12-10 13:57:17 +0100 |
commit | 049f7f9af10dd2dc4f24f499c7468dcc22fcf13b (patch) | |
tree | 979f8df332086dd77e99bb93804a07adc9ba794f /apps/files_sharing | |
parent | a96cf5d01c0f88aa3f5baa595e04f0c9d87c4236 (diff) | |
parent | 0dae2b8296af7f4e6d174dd64b8c80b97a3fa0dc (diff) | |
download | nextcloud-server-049f7f9af10dd2dc4f24f499c7468dcc22fcf13b.tar.gz nextcloud-server-049f7f9af10dd2dc4f24f499c7468dcc22fcf13b.zip |
Merge pull request #21101 from owncloud/stable8.2_20989
[Stable 8.2] Update parent when moving share into recieved share
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/updater.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index d70ed23b941..218d0f292b8 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(); + } } /** |