aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-03-29 16:50:23 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2017-04-03 10:29:32 +0200
commitb84fd7c3615c9d7b1830b6d51f6ad5b943d06b9f (patch)
tree2db691145f7ca15449a67d0b026a770f277561aa /apps/files_sharing
parent3cc0d15f92175f01744cef0840e32d9b5657db3b (diff)
downloadnextcloud-server-b84fd7c3615c9d7b1830b6d51f6ad5b943d06b9f.tar.gz
nextcloud-server-b84fd7c3615c9d7b1830b6d51f6ad5b943d06b9f.zip
set expire date for all share types
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php38
1 files changed, 18 insertions, 20 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index bd3535536e4..b810a515082 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -163,6 +163,11 @@ class ShareAPIController extends OCSController {
$result['file_parent'] = $node->getParent()->getId();
$result['file_target'] = $share->getTarget();
+ $expiration = $share->getExpirationDate();
+ if ($expiration !== null) {
+ $result['expiration'] = $expiration->format('Y-m-d 00:00:00');
+ }
+
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$sharedWith = $this->userManager->get($share->getSharedWith());
$result['share_with'] = $share->getSharedWith();
@@ -179,11 +184,6 @@ class ShareAPIController extends OCSController {
$result['token'] = $share->getToken();
$result['url'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share->getToken()]);
- $expiration = $share->getExpirationDate();
- if ($expiration !== null) {
- $result['expiration'] = $expiration->format('Y-m-d 00:00:00');
- }
-
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'CLOUD');
@@ -741,32 +741,30 @@ class ShareAPIController extends OCSController {
}
} else {
- // For other shares only permissions is valid.
- if ($share->getShareType() !== \OCP\Share::SHARE_TYPE_EMAIL && $permissions === null) {
- throw new OCSBadRequestException($this->l->t('Wrong or no update parameter given'));
- } elseif ($permissions !== null) {
+ if ($permissions !== null) {
$permissions = (int)$permissions;
$share->setPermissions($permissions);
}
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
- if ($expireDate === '') {
- $share->setExpirationDate(null);
- } else if ($expireDate !== null) {
- try {
- $expireDate = $this->parseDate($expireDate);
- } catch (\Exception $e) {
- throw new OCSBadRequestException($e->getMessage());
- }
- $share->setExpirationDate($expireDate);
- }
-
if ($password === '') {
$share->setPassword(null);
} else if ($password !== null) {
$share->setPassword($password);
}
}
+
+ if ($expireDate === '') {
+ $share->setExpirationDate(null);
+ } else if ($expireDate !== null) {
+ try {
+ $expireDate = $this->parseDate($expireDate);
+ } catch (\Exception $e) {
+ throw new OCSBadRequestException($e->getMessage());
+ }
+ $share->setExpirationDate($expireDate);
+ }
+
}
if ($permissions !== null && $share->getShareOwner() !== $this->currentUser) {