summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-01-29 22:42:59 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-01-30 15:40:31 +0100
commit1efe877d000dbaee321b37bd75dfe9cae93c801a (patch)
tree572be12df43f11015253dcd5e4c0abff00ac31c4 /lib
parentc14464875fbee6349f7a730c3c901dfb00ddbf88 (diff)
downloadnextcloud-server-1efe877d000dbaee321b37bd75dfe9cae93c801a.tar.gz
nextcloud-server-1efe877d000dbaee321b37bd75dfe9cae93c801a.zip
Emit hook for expirationDate verification
Diffstat (limited to 'lib')
-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 d6245f4beac..0f658d83fa6 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -216,7 +216,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
@@ -243,18 +245,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;
}
@@ -435,7 +449,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());
@@ -572,7 +586,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;
}
}