allow to rename group share mount points
This commit is contained in:
parent
3f6e9e0102
commit
bffcbac7a7
|
@ -317,14 +317,27 @@ class Shared extends \OC\Files\Storage\Common {
|
||||||
|
|
||||||
$relTargetPath = $this->stripUserFilesPath($targetPath);
|
$relTargetPath = $this->stripUserFilesPath($targetPath);
|
||||||
|
|
||||||
// rename mount point
|
// if the user renames a mount point from a group share we need to create a new db entry
|
||||||
$query = \OC_DB::prepare(
|
// for the unique name
|
||||||
'Update `*PREFIX*share`
|
if ($this->getShareType() === \OCP\Share::SHARE_TYPE_GROUP && $this->uniqueNameSet() === false) {
|
||||||
SET `file_target` = ?
|
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`,'
|
||||||
WHERE `id` = ?'
|
.' `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) {
|
if ($result) {
|
||||||
// update the mount manager with the new paths
|
// update the mount manager with the new paths
|
||||||
|
@ -333,6 +346,7 @@ class Shared extends \OC\Files\Storage\Common {
|
||||||
$mount->setMountPoint($targetPath . '/');
|
$mount->setMountPoint($targetPath . '/');
|
||||||
$mountManager->addMount($mount);
|
$mountManager->addMount($mount);
|
||||||
$mountManager->removeMount($sourcePath . '/');
|
$mountManager->removeMount($sourcePath . '/');
|
||||||
|
$this->setUniqueName();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
\OCP\Util::writeLog('file sharing',
|
\OCP\Util::writeLog('file sharing',
|
||||||
|
@ -486,6 +500,21 @@ class Shared extends \OC\Files\Storage\Common {
|
||||||
return $this->share['share_type'];
|
return $this->share['share_type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
* @brief get share ID
|
||||||
* @return integer unique share ID
|
* @return integer unique share ID
|
||||||
|
|
|
@ -1139,6 +1139,7 @@ class Share extends \OC\Share\Constants {
|
||||||
// Filter out duplicate group shares for users with unique targets
|
// Filter out duplicate group shares for users with unique targets
|
||||||
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
|
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
|
||||||
$row['share_type'] = self::SHARE_TYPE_GROUP;
|
$row['share_type'] = self::SHARE_TYPE_GROUP;
|
||||||
|
$row['unique_name'] = true; // remember that we use a unique name for this user
|
||||||
$row['share_with'] = $items[$row['parent']]['share_with'];
|
$row['share_with'] = $items[$row['parent']]['share_with'];
|
||||||
// Remove the parent group share
|
// Remove the parent group share
|
||||||
unset($items[$row['parent']]);
|
unset($items[$row['parent']]);
|
||||||
|
|
Loading…
Reference in New Issue