summaryrefslogtreecommitdiffstats
path: root/lib/private/share20
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-01 14:13:54 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-01 14:13:54 +0100
commit84d9704121cb9579504ce2f511c1e5b3fb0e9d30 (patch)
tree0e9eeb001a4981a9538950bf2377fbcae9a85722 /lib/private/share20
parent1232943aaa1474faa20cfe2912fe2f097dcbd5f2 (diff)
parentd3e79f3bb60de2c05e994aca032a35a0f5a47228 (diff)
downloadnextcloud-server-84d9704121cb9579504ce2f511c1e5b3fb0e9d30.tar.gz
nextcloud-server-84d9704121cb9579504ce2f511c1e5b3fb0e9d30.zip
Merge pull request #22028 from owncloud/share_hook_expirationdate
Share hook expirationdate
Diffstat (limited to 'lib/private/share20')
-rw-r--r--lib/private/share20/manager.php32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index ad5fed93904..e45fa4b40f9 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -217,7 +217,9 @@ class Manager implements IManager {
* @return \DateTime|null The expiration date or null if $expireDate was null and it is not required
* @throws \OC\HintException
*/
- protected function validateExpirationDate($expirationDate) {
+ protected function validateExpirationDate(\OCP\Share\IShare $share) {
+
+ $expirationDate = $share->getExpirationDate();
if ($expirationDate !== null) {
//Make sure the expiration date is a date
@@ -244,18 +246,30 @@ class Manager implements IManager {
$message = $this->l->t('Cannot set expiration date more than %s days in the future', [$this->shareApiLinkDefaultExpireDays()]);
throw new \OC\HintException($message, $message, 404);
}
-
- return $expirationDate;
}
// If expiredate is empty set a default one if there is a default
if ($expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
- $date = new \DateTime();
- $date->setTime(0,0,0);
- $date->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
- return $date;
+ $expirationDate = new \DateTime();
+ $expirationDate->setTime(0,0,0);
+ $expirationDate->add(new \DateInterval('P'.$this->shareApiLinkDefaultExpireDays().'D'));
+ }
+
+ $accepted = true;
+ $message = '';
+ \OCP\Util::emitHook('\OC\Share', 'verifyExpirationDate', [
+ 'expirationDate' => &$expirationDate,
+ 'accepted' => &$accepted,
+ 'message' => &$message,
+ 'passwordSet' => $share->getPassword() === null,
+ ]);
+
+ if (!$accepted) {
+ throw new \Exception($message);
}
+ $share->setExpirationDate($expirationDate);
+
return $expirationDate;
}
@@ -436,7 +450,7 @@ class Manager implements IManager {
);
//Verify the expiration date
- $share->setExpirationDate($this->validateExpirationDate($share->getExpirationDate()));
+ $this->validateExpirationDate($share);
//Verify the password
$this->verifyPassword($share->getPassword());
@@ -573,7 +587,7 @@ class Manager implements IManager {
if ($share->getExpirationDate() !== $originalShare->getExpirationDate()) {
//Verify the expiration date
- $share->setExpirationDate($this->validateExpirationDate($share->getExpirationDate()));
+ $this->validateExpirationDate($share);
$expirationDateUpdated = true;
}
}