summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-01-25 13:09:25 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-01-26 13:59:58 +0100
commite508bcb7a79232cc051b40949537f385faa020f2 (patch)
tree34eacda511ff75887ff61298ea2e94a0eead0cd0 /lib
parent59c2aae54fad07f2ad12f17e37b498355222ced5 (diff)
downloadnextcloud-server-e508bcb7a79232cc051b40949537f385faa020f2.tar.gz
nextcloud-server-e508bcb7a79232cc051b40949537f385faa020f2.zip
[Share 2.0] Fire off hook
Diffstat (limited to 'lib')
-rw-r--r--lib/private/share20/manager.php26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/private/share20/manager.php b/lib/private/share20/manager.php
index 249103018b0..62f312c5c6b 100644
--- a/lib/private/share20/manager.php
+++ b/lib/private/share20/manager.php
@@ -532,6 +532,8 @@ class Manager {
* @return IShare The share object
*/
public function updateShare(IShare $share) {
+ $expirationDateUpdated = false;
+
if (!$this->canShare($share)) {
throw new \Exception('The Share API is disabled');
}
@@ -540,13 +542,13 @@ class Manager {
// We can't change the share type!
if ($share->getShareType() !== $originalShare->getShareType()) {
- //Throw exception
+ throw new \Exception('Can\'t change share type');
}
// We can only change the recipient on user shares
if ($share->getSharedWith() !== $originalShare->getSharedWith() &&
$share->getShareType() !== \OCP\Share::SHARE_TYPE_USER) {
- // Throw exception
+ throw new \Exception('Can only update recipient on user shares');
}
// Cannot share with the owner
@@ -574,15 +576,29 @@ class Manager {
}
}
- //Verify the expiration date
- $share->setExpirationDate($this->validateExpiredate($share->getExpirationDate()));
+ if ($share->getExpirationDate() !== $originalShare->getExpirationDate()) {
+ //Verify the expiration date
+ $share->setExpirationDate($this->validateExpiredate($share->getExpirationDate()));
+ $expirationDateUpdated = true;
+ }
}
$this->pathCreateChecks($share->getPath());
// Now update the share!
$provider = $this->factory->getProviderForType($share->getShareType());
- return $provider->update($share);
+ $share = $provider->update($share);
+
+ if ($expirationDateUpdated === true) {
+ \OC_Hook::emit('OCP\Share', 'post_set_expiration_date', [
+ 'itemType' => $share->getPath() instanceof \OCP\Files\File ? 'file' : 'folder',
+ 'itemSource' => $share->getPath()->getId(),
+ 'date' => $share->getExpirationDate(),
+ 'uidOwner' => $share->getSharedBy()->getUID(),
+ ]);
+ }
+
+ return $share;
}
/**