Skip to content

Commit

Permalink
allow to update lables for public link shares
Browse files Browse the repository at this point in the history
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
  • Loading branch information
schiessle committed Oct 18, 2018
1 parent 818ca4d commit 18e720d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ public function getShares(
* @param string $publicUpload
* @param string $expireDate
* @param string $note
* @param string $label
* @return DataResponse
* @throws LockedException
* @throws NotFoundException
Expand All @@ -758,7 +759,8 @@ public function updateShare(
string $sendPasswordByTalk = null,
string $publicUpload = null,
string $expireDate = null,
string $note = null
string $note = null,
string $label = null
): DataResponse {
try {
$share = $this->getShareById($id);
Expand All @@ -772,7 +774,14 @@ public function updateShare(
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) {
if ($permissions === null &&
$password === null &&
$sendPasswordByTalk === null &&
$publicUpload === null &&
$expireDate === null &&
$note === null &&
$label === null
) {
throw new OCSBadRequestException($this->l->t('Wrong or no update parameter given'));
}

Expand Down Expand Up @@ -849,6 +858,10 @@ public function updateShare(
$share->setPassword($password);
}

if ($label !== null) {
$share->setLabel($label);
}

} else {
if ($permissions !== null) {
$permissions = (int)$permissions;
Expand Down
1 change: 1 addition & 0 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ public function update(\OCP\Share\IShare $share) {
->set('token', $qb->createNamedParameter($share->getToken()))
->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE))
->set('note', $qb->createNamedParameter($share->getNote()))
->set('label', $qb->createNamedParameter($share->getLabel()))
->execute();
}

Expand Down

0 comments on commit 18e720d

Please sign in to comment.