aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller/ShareAPIController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareAPIController.php')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php43
1 files changed, 28 insertions, 15 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index a935189491e..61fad5d2b14 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -160,6 +160,7 @@ class ShareAPIController extends OCSController {
'token' => null,
'uid_file_owner' => $share->getShareOwner(),
'note' => $share->getNote(),
+ 'label' => $share->getLabel(),
'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(),
];
@@ -354,15 +355,17 @@ class ShareAPIController extends OCSController {
* @param string $shareWith
* @param string $publicUpload
* @param string $password
- * @param bool $sendPasswordByTalk
+ * @param string $sendPasswordByTalk
* @param string $expireDate
+ * @param string $label
*
* @return DataResponse
- * @throws OCSNotFoundException
- * @throws OCSForbiddenException
+ * @throws NotFoundException
* @throws OCSBadRequestException
* @throws OCSException
- *
+ * @throws OCSForbiddenException
+ * @throws OCSNotFoundException
+ * @throws \OCP\Files\InvalidPathException
* @suppress PhanUndeclaredClassMethod
*/
public function createShare(
@@ -373,7 +376,8 @@ class ShareAPIController extends OCSController {
string $publicUpload = 'false',
string $password = '',
string $sendPasswordByTalk = null,
- string $expireDate = ''
+ string $expireDate = '',
+ string $label = ''
): DataResponse {
$share = $this->shareManager->newShare();
@@ -447,15 +451,6 @@ class ShareAPIController extends OCSController {
throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator'));
}
- /*
- * For now we only allow 1 link share.
- * Return the existing link share if this is a duplicate
- */
- $existingShares = $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_LINK, $path, false, 1, 0);
- if (!empty($existingShares)) {
- return new DataResponse($this->formatShare($existingShares[0]));
- }
-
if ($publicUpload === 'true') {
// Check if public upload is allowed
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) {
@@ -482,6 +477,10 @@ class ShareAPIController extends OCSController {
$share->setPassword($password);
}
+ if (!empty($label)) {
+ $share->setLabel($label);
+ }
+
//Expire date
if ($expireDate !== '') {
try {
@@ -746,6 +745,7 @@ class ShareAPIController extends OCSController {
* @param string $publicUpload
* @param string $expireDate
* @param string $note
+ * @param string $label
* @param string $hideDownload
* @return DataResponse
* @throws LockedException
@@ -762,6 +762,7 @@ class ShareAPIController extends OCSController {
string $publicUpload = null,
string $expireDate = null,
string $note = null,
+ string $label = null,
string $hideDownload = null
): DataResponse {
try {
@@ -776,7 +777,15 @@ class ShareAPIController extends OCSController {
throw new OCSNotFoundException($this->l->t('Wrong share ID, share doesn\'t exist'));
}
- if ($permissions === null && $password === null && $sendPasswordByTalk === null && $publicUpload === null && $expireDate === null && $note === null && $hideDownload === null) {
+ if ($permissions === null &&
+ $password === null &&
+ $sendPasswordByTalk === null &&
+ $publicUpload === null &&
+ $expireDate === null &&
+ $note === null &&
+ $label === null &&
+ $hideDownload === null
+ ) {
throw new OCSBadRequestException($this->l->t('Wrong or no update parameter given'));
}
@@ -860,6 +869,10 @@ class ShareAPIController extends OCSController {
$share->setPassword($password);
}
+ if ($label !== null) {
+ $share->setLabel($label);
+ }
+
} else {
if ($permissions !== null) {
$permissions = (int)$permissions;