[Pkg-owncloud-commits] [owncloud] 80/134: LDAP: Read email and quota when mapping user, fixes #7785

David Prévot taffit at moszumanska.debian.org
Fri Apr 18 21:44:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 7dd34b12126483a24ef6370b23ec9e87cc988c8c
Author: Arthur Schiwon <blizzz at owncloud.com>
Date:   Fri Mar 28 12:18:24 2014 +0100

    LDAP: Read email and quota when mapping user, fixes #7785
---
 apps/user_ldap/lib/access.php | 46 +++++++++++++++++++++++++++++++++++++++++++
 apps/user_ldap/user_ldap.php  | 35 ++------------------------------
 2 files changed, 48 insertions(+), 33 deletions(-)

diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index bab8129..aaf3994 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -105,6 +105,47 @@ class Access extends LDAPUtility {
 		return false;
 	}
 
+	public function updateQuota($dn, $ocname = null) {
+		$quota = null;
+		$quotaDefault = $this->connection->ldapQuotaDefault;
+		$quotaAttribute = $this->connection->ldapQuotaAttribute;
+		if(!empty($quotaDefault)) {
+			$quota = $quotaDefault;
+		}
+		if(!empty($quotaAttribute)) {
+			$aQuota = $this->readAttribute($dn, $quotaAttribute);
+
+			if($aQuota && (count($aQuota) > 0)) {
+				$quota = $aQuota[0];
+			}
+		}
+		if(!is_null($quota)) {
+			if(is_null($ocname)) {
+				$ocname = $this->dn2username($dn);
+			}
+			\OCP\Config::setUserValue($ocname, 'files', 'quota',
+				\OCP\Util::computerFileSize($quota));
+		}
+	}
+
+	public function updateEmail($dn, $ocname = null) {
+		$email = null;
+		$emailAttribute = $this->connection->ldapEmailAttribute;
+		if(!empty($emailAttribute)) {
+			$aEmail = $this->readAttribute($dn, $emailAttribute);
+			if($aEmail && (count($aEmail) > 0)) {
+				$email = $aEmail[0];
+			}
+			if(!is_null($email)) {
+				if(is_null($ocname)) {
+					$ocname = $this->dn2username($dn);
+				}
+				\OCP\Config::setUserValue($ocname, 'settings', 'email', $email);
+			}
+		}
+	}
+
+
 	/**
 	 * @brief checks wether the given attribute`s valua is probably a DN
 	 * @param $attr the attribute in question
@@ -598,6 +639,11 @@ class Access extends LDAPUtility {
 			return false;
 		}
 
+		if($isUser) {
+			$this->updateEmail($dn, $ocname);
+			$this->updateQuota($dn, $ocname);
+		}
+
 		return true;
 	}
 
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index c993a1d..f2353df 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -31,42 +31,11 @@ use OCA\user_ldap\lib\BackendUtility;
 class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
 
 	private function updateQuota($dn) {
-		$quota = null;
-		$quotaDefault = $this->access->connection->ldapQuotaDefault;
-		$quotaAttribute = $this->access->connection->ldapQuotaAttribute;
-		if(!empty($quotaDefault)) {
-			$quota = $quotaDefault;
-		}
-		if(!empty($quotaAttribute)) {
-			$aQuota = $this->access->readAttribute($dn, $quotaAttribute);
-
-			if($aQuota && (count($aQuota) > 0)) {
-				$quota = $aQuota[0];
-			}
-		}
-		if(!is_null($quota)) {
-			\OCP\Config::setUserValue(	$this->access->dn2username($dn),
-										'files',
-										'quota',
-										\OCP\Util::computerFileSize($quota));
-		}
+		$this->access->updateQuota($dn);
 	}
 
 	private function updateEmail($dn) {
-		$email = null;
-		$emailAttribute = $this->access->connection->ldapEmailAttribute;
-		if(!empty($emailAttribute)) {
-			$aEmail = $this->access->readAttribute($dn, $emailAttribute);
-			if($aEmail && (count($aEmail) > 0)) {
-				$email = $aEmail[0];
-			}
-			if(!is_null($email)) {
-				\OCP\Config::setUserValue(	$this->access->dn2username($dn),
-											'settings',
-											'email',
-											$email);
-			}
-		}
+		$this->access->updateEmail($dn);
 	}
 
 	/**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list