[Svn] r4868 - in trunk/roundcubemail: config program/include

trac at roundcube.net trac at roundcube.net
Sat Jun 18 21:45:27 CEST 2011


Author: thomasb
Date: 2011-06-18 14:45:26 -0500 (Sat, 18 Jun 2011)
New Revision: 4868

Modified:
   trunk/roundcubemail/config/main.inc.php.dist
   trunk/roundcubemail/program/include/rcube_ldap.php
Log:
Use numSubOrdindates inconjuction with VLV to count total

Modified: trunk/roundcubemail/config/main.inc.php.dist
===================================================================
--- trunk/roundcubemail/config/main.inc.php.dist	2011-06-18 11:28:43 UTC (rev 4867)
+++ trunk/roundcubemail/config/main.inc.php.dist	2011-06-18 19:45:26 UTC (rev 4868)
@@ -536,6 +536,7 @@
   'filter'        => '(objectClass=inetOrgPerson)',      // used for basic listing (if not empty) and will be &'d with search queries. example: status=act
   'fuzzy_search'  => true,    // server allows wildcard search
   'vlv'           => false,   // Enable Virtual List View to mor efficiently fetch paginated data (if server supports it)
+  'numsub_filter' => '(objectClass=organizationalUnit)',   // with VLV, we also use numSubOrdinates to query the total number of records. Set this filter to get all numSubOrdinates attributes for counting
   'sizelimit'     => '0',     // Enables you to limit the count of entries fetched. Setting this to 0 means no limit.
   'timelimit'     => '0',     // Sets the number of seconds how long is spend on the search. Setting this to 0 means no limit.
 

Modified: trunk/roundcubemail/program/include/rcube_ldap.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_ldap.php	2011-06-18 11:28:43 UTC (rev 4867)
+++ trunk/roundcubemail/program/include/rcube_ldap.php	2011-06-18 19:45:26 UTC (rev 4868)
@@ -884,10 +884,18 @@
 
             $this->_debug("C: Search [".$filter."]");
 
-            // when using VLV, we need to issue listing command first in order to get the full count
+            // when using VLV, we get the total count by...
             if (!$count && $function != 'ldap_read' && $this->prop['vlv']) {
-                if ($this->_exec_search(true))
-                    $this->vlv_count = ldap_count_entries($this->conn, $this->ldap_result);
+                // ...either reading numSubOrdinates attribute
+                if ($this->prop['numsub_filter'] && ($result_count = @$function($this->conn, $this->base_dn, $this->prop['numsub_filter'], array('numSubOrdinates'), 0, 0, 0))) {
+                    $counts = ldap_get_entries($this->conn, $result_count);
+                    for ($this->vlv_count = $j = 0; $j < $counts['count']; $j++)
+                        $this->vlv_count += $counts[$j]['numsubordinates'][0];
+                    $this->_debug("D: total numsubordinates = " . $this->vlv_count);
+                }
+                else  // ...or by fetching all records dn and count them
+                    $this->vlv_count = $this->_exec_search(true);
+                
                 $this->vlv_active = $this->_vlv_set_controls();
             }
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list