summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/server.php4
-rw-r--r--lib/private/user/user.php39
-rw-r--r--lib/private/util.php6
3 files changed, 38 insertions, 11 deletions
diff --git a/lib/private/server.php b/lib/private/server.php
index 0d1bed4e7d2..9dfae860090 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -244,9 +244,9 @@ class Server extends ServerContainer implements IServerContainer {
$userSession->listen('\OC\User', 'logout', function () {
\OC_Hook::emit('OC_User', 'logout', array());
});
- $userSession->listen('\OC\User', 'changeUser', function ($user) {
+ $userSession->listen('\OC\User', 'changeUser', function ($user, $feature) {
/** @var $user \OC\User\User */
- \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user));
+ \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature));
});
return $userSession;
});
diff --git a/lib/private/user/user.php b/lib/private/user/user.php
index 516c1d443c6..0f230d468fd 100644
--- a/lib/private/user/user.php
+++ b/lib/private/user/user.php
@@ -30,6 +30,7 @@
namespace OC\User;
use OC\Hooks\Emitter;
+use OC_Helper;
use OCP\IAvatarManager;
use OCP\IImage;
use OCP\IURLGenerator;
@@ -140,7 +141,7 @@ class User implements IUser {
$result = $this->backend->setDisplayName($this->uid, $displayName);
if ($result) {
$this->displayName = $displayName;
- $this->triggerChange();
+ $this->triggerChange('displayName');
}
return $result !== false;
} else {
@@ -161,7 +162,7 @@ class User implements IUser {
} else {
$this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
}
- $this->triggerChange();
+ $this->triggerChange('eMailAddress');
}
/**
@@ -339,6 +340,36 @@ class User implements IUser {
}
/**
+ * get the users' quota
+ *
+ * @return string
+ * @since 9.0.0
+ */
+ public function getQuota() {
+ $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default');
+ if($quota === 'default') {
+ $quota = $this->config->getAppValue('files', 'default_quota', 'none');
+ }
+ return $quota;
+ }
+
+ /**
+ * set the users' quota
+ *
+ * @param string $quota
+ * @return void
+ * @since 9.0.0
+ */
+ public function setQuota($quota) {
+ if($quota !== 'none' and $quota !== 'default') {
+ $quota= OC_Helper::computerFileSize($quota);
+ $quota=OC_Helper::humanFileSize($quota);
+ }
+ $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
+ $this->triggerChange('quota');
+ }
+
+ /**
* get the avatar image if it exists
*
* @param int $size
@@ -386,9 +417,9 @@ class User implements IUser {
return $url;
}
- public function triggerChange() {
+ public function triggerChange($feature) {
if ($this->emitter) {
- $this->emitter->emit('\OC\User', 'changeUser', array($this));
+ $this->emitter->emit('\OC\User', 'changeUser', array($this, $feature));
}
}
diff --git a/lib/private/util.php b/lib/private/util.php
index 28541eff773..6e15d742bed 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -285,11 +285,7 @@ class OC_Util {
* @return int Quota bytes
*/
public static function getUserQuota($user) {
- $config = \OC::$server->getConfig();
- $userQuota = $config->getUserValue($user, 'files', 'quota', 'default');
- if ($userQuota === 'default') {
- $userQuota = $config->getAppValue('files', 'default_quota', 'none');
- }
+ $userQuota = \OC::$server->getUserManager()->get($user)->getQuota();
if($userQuota === 'none') {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}else{