summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-11 11:55:09 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-02-11 13:29:23 +0100
commit4533cb9c59501e9871513c10a0baceee8785d76c (patch)
treec49a7395d825511069e1a8643cc1083e5613c3e0
parent73e37377771ecd24ca44bc3176e491977df0da10 (diff)
downloadnextcloud-server-4533cb9c59501e9871513c10a0baceee8785d76c.tar.gz
nextcloud-server-4533cb9c59501e9871513c10a0baceee8785d76c.zip
Add parent for invisible link shares
-rw-r--r--lib/private/share20/defaultshareprovider.php4
-rw-r--r--lib/private/share20/manager.php23
-rw-r--r--tests/lib/share20/managertest.php4
3 files changed, 31 insertions, 0 deletions
diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php
index 0ab0dc81fa7..e18e306d7f6 100644
--- a/lib/private/share20/defaultshareprovider.php
+++ b/lib/private/share20/defaultshareprovider.php
@@ -118,6 +118,10 @@ class DefaultShareProvider implements IShareProvider {
if ($share->getExpirationDate() !== null) {
$qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime'));
}
+
+ if (method_exists($share, 'getParent')) {
+ $qb->setValue('parent', $qb->createNamedParameter($share->getParent()));
+ }
} else {
throw new \Exception('invalid share type!');
}
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 4345784d2e7..12893c26964 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -415,6 +415,28 @@ class Manager implements IManager {
}
/**
+ * To make sure we don't get invisible link shares we set the parent
+ * of a link if it is a reshare. This is a quick word around
+ * until we can properly display multiple link shares in the UI
+ *
+ * See: https://github.com/owncloud/core/issues/22295
+ *
+ * FIXME: Remove once multiple link shares can be properly displayed
+ *
+ * @param \OCP\Share\IShare $share
+ */
+ protected function setLinkParent(\OCP\Share\IShare $share) {
+
+ // No sense in checking if the method is not there.
+ if (method_exists($share, 'setParent')) {
+ $storage = $share->getNode()->getStorage();
+ if ($storage->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
+ $share->setParent($storage->getShareId());
+ }
+ };
+ }
+
+ /**
* @param File|Folder $path
*/
protected function pathCreateChecks($path) {
@@ -470,6 +492,7 @@ class Manager implements IManager {
$this->groupCreateChecks($share);
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$this->linkCreateChecks($share);
+ $this->setLinkParent($share);
/*
* For now ignore a set token.
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php
index 73a1b0a6530..1230c191b6b 100644
--- a/tests/lib/share20/managertest.php
+++ b/tests/lib/share20/managertest.php
@@ -1549,6 +1549,7 @@ class ManagerTest extends \Test\TestCase {
'pathCreateChecks',
'validateExpirationDate',
'verifyPassword',
+ 'setLinkParent',
])
->getMock();
@@ -1589,6 +1590,9 @@ class ManagerTest extends \Test\TestCase {
$manager->expects($this->once())
->method('verifyPassword')
->with('password');
+ $manager->expects($this->once())
+ ->method('setLinkParent')
+ ->with($share);
$this->hasher->expects($this->once())
->method('hash')