steffen: server/kolab-webadmin/kolab-webadmin/www/admin/addressbook addr.php, 1.8, 1.9

cvs at intevation.de cvs at intevation.de
Sat May 28 22:56:07 CEST 2005


Author: steffen

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

Modified Files:
	addr.php 
Log Message:
Missing validation on addressbook email entry (Issue769)

Index: addr.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/www/admin/addressbook/addr.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- addr.php	11 Mar 2005 09:11:15 -0000	1.8
+++ addr.php	28 May 2005 20:56:05 -0000	1.9
@@ -54,6 +54,17 @@
   $form->entries['action']['value'] = 'save';
 }
 
+function checkuniquemail( $form, $key, $value ) {
+  global $ldap;
+  $value = trim($value);
+  if( $value == '' ) return ''; // OK
+
+  if( $ldap->countMail( $_SESSION['base_dn'], $value ) > 0 ) {	
+	return _('User, vCard or distribution list with this email address already exists');
+  } else {
+	return '';
+  }
+}
 
 /**** Submenu for current page ***/
 $menuitems[$sidx]['selected'] = 'selected';
@@ -82,7 +93,8 @@
 									   'validation' => 'notempty',
 									   'comment' => _('Required') ),
 				  'title' => array( 'name' => _('Title') ),
-				  'mail'  => array( 'name' => _('Primary E-Mail Address') ),
+				  'mail'  => array( 'name' => _('Primary E-Mail Address'),
+									'validation' => 'checkuniquemail' ),
 				  'alias' => array( 'name' => _('E-Mail Aliases'),
 									'type' => 'textarea',
 									'comment' => _('One address per line')),
@@ -253,7 +265,7 @@
 
 /**** Insert into template and output ***/
 $smarty =& new MySmarty();
-$smarty->assign( 'errors', $errors );
+$smarty->assign( 'errors', array_merge($errors,$form->errors) );
 $smarty->assign( 'messages', $messages );
 $smarty->assign( 'heading', $heading );
 $smarty->assign( 'uid', $auth->uid() );





More information about the commits mailing list