diff options
author | Robin Appelman <robin@icewind.nl> | 2020-09-17 15:06:50 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-09-17 16:32:48 +0200 |
commit | 674db6da88eee4d9eba71c9b0270e9ca3a262318 (patch) | |
tree | 61ffe631befca2ac93d1f99b542fa4a06302b957 /lib/private/User | |
parent | ec07ca2abbc88f395b8eeedc4b2e5b679018a673 (diff) | |
download | nextcloud-server-674db6da88eee4d9eba71c9b0270e9ca3a262318.tar.gz nextcloud-server-674db6da88eee4d9eba71c9b0270e9ca3a262318.zip |
add event to allow apps to overwrite user quota
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/User')
-rw-r--r-- | lib/private/User/User.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 2d27b204d09..365b8ae33a1 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -50,6 +50,7 @@ use OCP\IImage; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserBackend; +use OCP\User\GetQuotaEvent; use OCP\UserInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -406,7 +407,15 @@ class User implements IUser { * @since 9.0.0 */ public function getQuota() { - $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default'); + // allow apps to modify the user quota by hooking into the event + $event = new GetQuotaEvent($this); + $this->dispatcher->dispatchTyped($event); + $overwriteQuota = $event->getQuota(); + if ($overwriteQuota) { + $quota = $overwriteQuota; + } else { + $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default'); + } if ($quota === 'default') { $quota = $this->config->getAppValue('files', 'default_quota', 'none'); } |