summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorJuan Pablo Villafáñez <jvillafanez@solidgear.es>2017-03-14 14:07:33 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-03-29 13:32:11 +0200
commit3345a72e7e4a5d11b1140d17b46567b65055f2e9 (patch)
treef2d6cfe426b338b1ef907ea935df0d2e913ee728 /apps/user_ldap
parent626d03e3d47994364500bd6cd5dd9a029b862fb7 (diff)
downloadnextcloud-server-3345a72e7e4a5d11b1140d17b46567b65055f2e9.tar.gz
nextcloud-server-3345a72e7e4a5d11b1140d17b46567b65055f2e9.zip
Correctly apply quota
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/User/User.php39
1 files changed, 33 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index e29b10616ca..7a840de87f6 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -169,6 +169,10 @@ class User {
$attr = strtolower($this->connection->ldapQuotaAttribute);
if(isset($ldapEntry[$attr])) {
$this->updateQuota($ldapEntry[$attr][0]);
+ } else {
+ if ($this->connection->ldapQuotaDefault !== '') {
+ $this->updateQuota();
+ }
}
unset($attr);
@@ -464,25 +468,48 @@ class User {
if($this->wasRefreshed('quota')) {
return;
}
- //can be null
- $quotaDefault = $this->connection->ldapQuotaDefault;
- $quota = $quotaDefault !== '' ? $quotaDefault : null;
- $quota = !is_null($valueFromLDAP) ? $valueFromLDAP : $quota;
+ $quota = false;
if(is_null($valueFromLDAP)) {
$quotaAttribute = $this->connection->ldapQuotaAttribute;
if ($quotaAttribute !== '') {
$aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
if($aQuota && (count($aQuota) > 0)) {
- $quota = $aQuota[0];
+ if ($this->verifyQuotaValue($aQuota[0])) {
+ $quota = $aQuota[0];
+ } else {
+ $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', \OCP\Util::WARN);
+ }
}
}
+ } else {
+ if ($this->verifyQuotaValue($valueFromLDAP)) {
+ $quota = $valueFromLDAP;
+ } else {
+ $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', \OCP\Util::WARN);
+ }
+ }
+
+ if ($quota === false) {
+ // quota not found using the LDAP attribute (or not parseable). Try the default quota
+ $defaultQuota = $this->connection->ldapQuotaDefault;
+ if ($this->verifyQuotaValue($defaultQuota)) {
+ $quota = $defaultQuota;
+ }
}
- if(!is_null($quota)) {
+
+ if($quota !== false) {
$this->userManager->get($this->uid)->setQuota($quota);
+ } else {
+ $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN);
+ $this->userManager->get($this->uid)->setQuota('default');
}
}
+ private function verifyQuotaValue($quotaValue) {
+ return $quotaValue === 'none' || $quotaValue === 'default' || \OC_Helper::computerFileSize($quotaValue) !== false;
+ }
+
/**
* called by a post_login hook to save the avatar picture
*