gunnar: server/php-kolab/Kolab_Webadmin/Webadmin ldap.class.php, 1.6, 1.7

cvs at kolab.org cvs at kolab.org
Wed Aug 22 09:15:27 CEST 2007


Author: gunnar

Update of /kolabrepository/server/php-kolab/Kolab_Webadmin/Webadmin
In directory doto:/tmp/cvs-serv2243/Kolab_Webadmin/Webadmin

Modified Files:
	ldap.class.php 
Log Message:
Whitespace and some minor fixes.

Index: ldap.class.php
===================================================================
RCS file: /kolabrepository/server/php-kolab/Kolab_Webadmin/Webadmin/ldap.class.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ldap.class.php	22 Aug 2007 06:33:55 -0000	1.6
+++ ldap.class.php	22 Aug 2007 07:15:25 -0000	1.7
@@ -133,7 +133,7 @@
         // Always connect to master server
         $this->_ldap = ldap_connect($uri);
 
-        if (!ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3)) {
+        if (!ldap_set_option($this->_ldap, LDAP_OPT_PROTOCOL_VERSION, 3)) {
             return PEAR::raiseError(_("Error setting LDAP protocol to v3. Please contact your system administrator"));
         }
     }
@@ -272,57 +272,57 @@
      *
      * @param int    $result The result ID
      * @param string $attr   The attribute used as sort criterium
-	 */
-	function sort($result, $attr) 
-	{
-		ldap_sort($this->_ldap, $result, $attr);
-	}
+     */
+    function sort($result, $attr) 
+    {
+        ldap_sort($this->_ldap, $result, $attr);
+    }
 
     /**
      * Retrieve results.
      *
      * @param int  $result The result ID
-	 *
+     *
      * @return array The result entries
-	 */
-	function getEntries($result) 
-	{
-		return ldap_get_entries($this->_ldap, $result);
-	}
+     */
+    function getEntries($result) 
+    {
+        return ldap_get_entries($this->_ldap, $result);
+    }
 
     /**
      * Retrieve a certain section of the results.
      *
      * @param int  $result  The result ID
      * @param int  $from    Get the results starting here, 
-	 *                      including this entry
+     *                      including this entry
      * @param int  $to      Get the results ending here,
-	 *                      excluding this entry
-	 *
+     *                      excluding this entry
+     *
      * @return array The result entries
-	 */
-	function getEntrySection($result, $from, $to)
-	{
+     */
+    function getEntrySection($result, $from, $to)
+    {
         $entries = array();
-		if ($to <= $from) {
-			return $entries;
-		}
-		
-		$entry = ldap_first_entry($this->_ldap, $result);
-		$current = 0;
-		
-		while( $entry ) {
-			if ($current >= $to) {
-				break;
-			}
-			if ($current >= $from) {
-				$entries[] = ldap_get_attributes($this->_ldap, $entry);
-			}
-			$entry = ldap_next_entry($this->_ldap, $entry);
-			$current++;
-		}
-		return $entries;
-	}
+        if ($to <= $from) {
+            return $entries;
+        }
+        
+        $entry = ldap_first_entry($this->_ldap, $result);
+        $current = 0;
+        
+        while( $entry ) {
+            if ($current >= $to) {
+                break;
+            }
+            if ($current >= $from) {
+                $entries[] = ldap_get_attributes($this->_ldap, $entry);
+            }
+            $entry = ldap_next_entry($this->_ldap, $entry);
+            $current++;
+        }
+        return $entries;
+    }
 
     /**
      * Retrieve a certain section of the results.
@@ -333,25 +333,25 @@
      * @param string $sort       Sort criterium
      * @param int    $perpage    Maximal entries per page
      * @param int    $page       Start with this page
-	 *
+     *
      * @return array The result entries
-	 */
-	function getPagedResult($base_dn, $filter, $attributes, 
-							$sort, $perpage, $page)
-	{
+     */
+    function getPagedResult($base_dn, $filter, $attributes, 
+                            $sort, $perpage, $page)
+    {
         $result = $ldap->search($base_dn, $filter, $attributes);
 
         if( $result ) {
 
             $this->_ldap->sort($result, $sort);
 
-			$from = ($page - 1) * $perpage;
-			$to   = $page * $perpage;
+            $from = ($page - 1) * $perpage;
+            $to   = $page * $perpage;
 
-			return getEntrySection($result, $from, $to);
-		}
-		return array();
-	}
+            return getEntrySection($result, $from, $to);
+        }
+        return array();
+    }
 
     /**
      * Read object data.
@@ -475,8 +475,7 @@
     function dnFromResult($result) {
         $entry = @ldap_first_entry($result);
         if (!$entry) {
-            return PEAR::raiseError(sprintf(_("No result for %s=%s"), 
-                                            $attr, $value));
+            return PEAR::raiseError(_('Search result contained no entries'));
         }
         return ldap_get_dn($entry);
     }
@@ -490,10 +489,10 @@
      */
     function dnForFilter($filter) {
         $result = $this->search($this->base_dn, $filter, array());
-		if (is_a($result, 'PEAR_Error')) {
-			return $result;
-		}
-        return dnFromResult($result);
+        if (is_a($result, 'PEAR_Error')) {
+            return $result;
+        }
+        return $this->dnFromResult($result);
     }
 
     /**
@@ -506,13 +505,13 @@
      * @return mixed The DN or a PEAR error
      */
     function dnForAttr($attr, $value) {
-		$filter = '(&(objectclass=kolabInetOrgPerson)(' . $attr . 
-			'=' . $this->escape($value) . '))';
+        $filter = '(&(objectclass=kolabInetOrgPerson)(' . $attr . 
+            '=' . $this->escape($value) . '))';
         $result = $this->search($this->base_dn, $filter, array());
-		if (is_a($result, 'PEAR_Error')) {
-			return $result;
-		}
-        return dnFromResult($result);
+        if (is_a($result, 'PEAR_Error')) {
+            return $result;
+        }
+        return $this->dnFromResult($result);
     }
     
     /**
@@ -586,9 +585,9 @@
             '))(uid=' . $this->escape($mail) . '))';
 
         $result = $this->search($base, $filter, array());
-		if (is_a($result, 'PEAR_Error')) {
-			return $result;
-		}
+        if (is_a($result, 'PEAR_Error')) {
+            return $result;
+        }
         $entries = $this->getEntries($result);
         $count = $entries['count'];
 
@@ -608,9 +607,9 @@
         $filter = '(&(objectClass=kolabGroupOfNames)(cn=' . 
             $this->escape($cn) . '))';
         $result = $this->search($base, $filter, array());
-		if (is_a($result, 'PEAR_Error')) {
-			return $result;
-		}
+        if (is_a($result, 'PEAR_Error')) {
+            return $result;
+        }
         $entries = $this->getEntries($result);
 
         for ($i = 0; $i < count($entries); $i++) {
@@ -662,13 +661,13 @@
      *
      * @param string  $sn The last name
      * @param string  $cn The common name
-	 *
+     *
      * @return string The extracted first name
-	 */
-	function getFirstName($sn, $cn) 
-	{
-		return substr($cn, 0, strlen($cn) - strlen($sn));
-	}
+     */
+    function getFirstName($sn, $cn) 
+    {
+        return substr($cn, 0, strlen($cn) - strlen($sn));
+    }
 };
 
 /*





More information about the commits mailing list