steffen: server/kolab-webadmin/kolab-webadmin/www/admin/addressbook index.php, 1.3, 1.4

cvs at intevation.de cvs at intevation.de
Sat Jan 8 00:04:25 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/addressbook
In directory doto:/tmp/cvs-serv13212/kolab-webadmin/www/admin/addressbook

Modified Files:
	index.php 
Log Message:
Fix for Issue603 (addressbook list)

Index: index.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/addressbook/index.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- index.php	17 Dec 2004 02:04:16 -0000	1.3
+++ index.php	7 Jan 2005 23:04:23 -0000	1.4
@@ -1,6 +1,6 @@
 <?php
 /*
- (c) 2004 Klarälvdalens Datakonsult AB
+ (c) 2004 Klar䬶dalens Datakonsult AB
  (c) 2003 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
  (c) 2003 Martin Konold <martin.konold at erfrakon.de>
  This program is Free Software under the GNU General Public License (>=v2).
@@ -37,17 +37,38 @@
 if( !$errors ) {
   if (isset($_SESSION['base_dn'])) $base_dn = $_SESSION['base_dn'];
   else $base_dn = 'k=kolab';
-  $filter = "(&(cn=*)(objectclass=inetOrgPerson)(!(uid=*))(sn=*))";
+  $userfilter = "cn=*";
+  $filterattr = $_REQUEST['filterattr'];
+  $filtertype = $_REQUEST['filtertype'];
+  $filtervalue = $_REQUEST['filtervalue'];
+  if( !in_array( $filterattr, array( 'cn', 'mail' ) ) ) $filterattr = 'cn';
+  if( isset( $filtervalue ) && !empty( $filtervalue ) ) {
+	switch( $filtertype ) {
+	case 'contains': // contains
+	  $userfilter = "$filterattr=*".$ldap->escape($filtervalue).'*';
+	  break;
+	case 'is': // is
+	  $userfilter = "$filterattr=".$ldap->escape($filtervalue);
+	  break;
+	case 'begins': // begins with
+	  $userfilter = "$filterattr=".$ldap->escape($filtervalue).'*';
+	  break;
+	case 'ends': // ends with
+	  $userfilter = "$filterattr=*".$ldap->escape($filtervalue);
+	  break;
+	}
+  }
+  $filter = "(&($userfilter)(objectclass=inetOrgPerson)(!(uid=*))(sn=*))";
   $result = ldap_search($ldap->connection, $base_dn, $filter);
   if( $result ) {
 	$count = ldap_count_entries($ldap->connection, $result);
 	$title = "Manage Address Book ($count Addresses)";
 	// if there are more than 2000 entries, split in 26 categories for every letter,
 	// or if more than 50, put in groups, or else just show all.
-	if ($count > 2000) {
+	if ( false && $count > 2000) {
 	  // ... TODO
 	  $template = 'addrlistalpha.tpl';
-	} else if( $count > 50 ) {
+	} else if( false && $count > 50 ) {
 	  // ... TODO
 	  $template = 'addrlistgroup.tpl';
 	}  else {
@@ -80,6 +101,17 @@
 $smarty->assign( 'uid', $auth->uid() );
 $smarty->assign( 'group', $auth->group() );
 $smarty->assign( 'page_title', $menuitems[$sidx]['title'] );
+
+$smarty->assign( 'filterattrs', array( 'cn'   => _('Name'),
+									   'mail' => _('Email') ) );
+$smarty->assign( 'filtertypes', array( 'contains'   => _('contains'),
+									   'is' => _('is'),
+									   'begins'  => _('begins with'),
+									   'ends'  => _('ends with') ) );
+$smarty->assign( 'filterattr', $filterattr );
+$smarty->assign( 'filtertype', $filtertype );
+$smarty->assign( 'filtervalue', $filtervalue );
+
 $smarty->assign( 'entries', $entries );
 $smarty->assign( 'menuitems', $menuitems );
 $smarty->assign( 'submenuitems', 





More information about the commits mailing list