diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-12-10 13:44:05 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-12-10 13:44:05 +0100 |
commit | 29ae188c71b6fecb13fec52307c43fb3517c10c5 (patch) | |
tree | 65b1b35993771d4ddf79794d7f90ff8d94131aea /apps/files_sharing | |
parent | fccfa3cf0b5559de77b9218f978a5fb29d773b5e (diff) | |
parent | 643778b028bef2ef4005236084b84a2d8a6d834e (diff) | |
download | nextcloud-server-29ae188c71b6fecb13fec52307c43fb3517c10c5.tar.gz nextcloud-server-29ae188c71b6fecb13fec52307c43fb3517c10c5.zip |
Merge pull request #21102 from owncloud/stable8.1_20989
[Stable8.1] Update parent when moving share into recieved share
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/lib/updater.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php index 5a0326c4288..a581355e4ba 100644 --- a/apps/files_sharing/lib/updater.php +++ b/apps/files_sharing/lib/updater.php @@ -56,6 +56,44 @@ 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\Files\Filesystem::getMountManager(); + $dstMount = $mountManager->find($src->getPath()); + if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) { + return; + } + + $parenShare = $dstMount->getShare(); + + foreach ($shares as $share) { + $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `parent` = ? WHERE `id` = ?'); + $query->execute([$parenShare['id'], $share['id']]); + } } /** |