diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-04-14 12:04:12 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-04-23 12:54:25 +0200 |
commit | bffcbac7a78c8b88b581489cca9bb44795cf81eb (patch) | |
tree | 2a06d9f193f5e5f56e4cf35d64944365ac6f6fba /apps | |
parent | 3f6e9e01026031527cd80f1f608d7a98d93e7ebe (diff) | |
download | nextcloud-server-bffcbac7a78c8b88b581489cca9bb44795cf81eb.tar.gz nextcloud-server-bffcbac7a78c8b88b581489cca9bb44795cf81eb.zip |
allow to rename group share mount points
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/sharedstorage.php | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 7ce9dd58b41..25e6c0abd28 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -317,14 +317,27 @@ class Shared extends \OC\Files\Storage\Common { $relTargetPath = $this->stripUserFilesPath($targetPath); - // rename mount point - $query = \OC_DB::prepare( - 'Update `*PREFIX*share` - SET `file_target` = ? - WHERE `id` = ?' - ); + // if the user renames a mount point from a group share we need to create a new db entry + // for the unique name + if ($this->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && $this->uniqueNameSet() === false) { + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`,' + .' `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`,' + .' `file_target`, `token`, `parent`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)'); + $arguments = array($this->share['item_type'], $this->share['item_source'], $this->share['item_target'], + 2, \OCP\User::getUser(), $this->share['uid_owner'], $this->share['permissions'], $this->share['stime'], $this->share['file_source'], + $relTargetPath, $this->share['token'], $this->share['id']); - $result = $query->execute(array($relTargetPath, $this->getShareId())); + } else { + // rename mount point + $query = \OC_DB::prepare( + 'Update `*PREFIX*share` + SET `file_target` = ? + WHERE `id` = ?' + ); + $arguments = array($relTargetPath, $this->getShareId()); + } + + $result = $query->execute($arguments); if ($result) { // update the mount manager with the new paths @@ -333,6 +346,7 @@ class Shared extends \OC\Files\Storage\Common { $mount->setMountPoint($targetPath . '/'); $mountManager->addMount($mount); $mountManager->removeMount($sourcePath . '/'); + $this->setUniqueName(); } else { \OCP\Util::writeLog('file sharing', @@ -487,6 +501,21 @@ class Shared extends \OC\Files\Storage\Common { } /** + * @brief does the group share already has a user specific unique name + * @return bool + */ + private function uniqueNameSet() { + return (isset($this->share['unique_name']) && $this->share['unique_name']); + } + + /** + * @brief the share now uses a unique name of this user + */ + private function setUniqueName() { + $this->share['unique_name'] = true; + } + + /** * @brief get share ID * @return integer unique share ID */ |