diff options
Diffstat (limited to 'apps/user_ldap/lib/User/User.php')
-rw-r--r-- | apps/user_ldap/lib/User/User.php | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index bfba3a92bee..9010d68bc6e 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -36,8 +36,8 @@ use OCA\User_LDAP\LogWrapper; use OCP\IAvatarManager; use OCP\IConfig; use OCP\Image; +use OCP\IUser; use OCP\IUserManager; -use OCP\Util; use OCP\Notification\IManager as INotificationManager; /** @@ -498,44 +498,39 @@ class User { return; } + $quotaAttribute = $this->connection->ldapQuotaAttribute; + $defaultQuota = $this->connection->ldapQuotaDefault; + if($quotaAttribute === '' && $defaultQuota === '') { + return; + } + $quota = false; - if(is_null($valueFromLDAP)) { - $quotaAttribute = $this->connection->ldapQuotaAttribute; - if ($quotaAttribute !== '') { - $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); - if($aQuota && (count($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); - } - } + if(is_null($valueFromLDAP) && $quotaAttribute !== '') { + $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); + if($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) { + $quota = $aQuota[0]; + } else if(is_array($aQuota) && isset($aQuota[0])) { + $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', \OCP\Util::DEBUG); } + } else if ($this->verifyQuotaValue($valueFromLDAP)) { + $quota = $valueFromLDAP; } else { - if ($this->verifyQuotaValue($valueFromLDAP)) { - $quota = $valueFromLDAP; - } else { - $this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', \OCP\Util::WARN); - } + $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', \OCP\Util::DEBUG); } - if ($quota === false) { + if ($quota === false && $this->verifyQuotaValue($defaultQuota)) { // quota not found using the LDAP attribute (or not parseable). Try the default quota - $defaultQuota = $this->connection->ldapQuotaDefault; - if ($this->verifyQuotaValue($defaultQuota)) { - $quota = $defaultQuota; - } + $quota = $defaultQuota; + } else if($quota === false) { + $this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG); + return; } $targetUser = $this->userManager->get($this->uid); - if ($targetUser) { - if($quota !== false) { - $targetUser->setQuota($quota); - } else { - $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN); - } + if ($targetUser instanceof IUser) { + $targetUser->setQuota($quota); } else { - $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::ERROR); + $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::INFO); } } |