gunnar: server/kolab-webadmin/kolab-webadmin/php/admin/include form.class.php, 1.31, 1.32
cvs at kolab.org
cvs at kolab.org
Thu Jul 12 18:28:26 CEST 2007
Author: gunnar
Update of /kolabrepository/server/kolab-webadmin/kolab-webadmin/php/admin/include
In directory doto:/tmp/cvs-serv1206/kolab-webadmin/php/admin/include
Modified Files:
form.class.php
Log Message:
Remove code duplications.
Index: form.class.php
===================================================================
RCS file: /kolabrepository/server/kolab-webadmin/kolab-webadmin/php/admin/include/form.class.php,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- form.class.php 24 May 2007 10:17:24 -0000 1.31
+++ form.class.php 12 Jul 2007 16:28:23 -0000 1.32
@@ -20,6 +20,42 @@
require_once('mysmarty.php');
+function checkuniquealias( $form, $key, $value ) {
+ global $ldap;
+ global $action;
+ global $dn;
+ $excludedn = false;
+ if( $action == 'save' ) $excludedn = trim($dn);
+ $lst = array_unique( array_filter( array_map( 'trim', preg_split( '/\n/', $value ) ), 'strlen') );
+ $str = '';
+ foreach( $lst as $alias ) {
+ debug( "looking at $alias, exluding $dn" );
+ if( $ldap->countMail( $_SESSION['base_dn'], $alias, $excludedn ) > 0 ) {
+ $str .= _('Email address ').MySmarty::htmlentities($alias)._(' collides with an address already used for another user, a vCard or a distribution list.<br />');
+ }
+ }
+ return $str;
+}
+
+// Due to a cyrus imapd bug we can't currently
+// support quotas over 4095 MB, see issue1262
+function checkquota( $form, $key, $value )
+{
+ if( empty($value) ) return ''; // OK
+ else if( $value >= 4096 ) return _('Quota must be smaller than 4096');
+ else if( $value < 0 ) return _('Quota can not be negative');
+ else if( !is_numeric($value) ) return _('Quota must be a number');
+ else if( (int) $value != $value ) return _('Quota must be an integer');
+ else return '';
+}
+
+function checkphone( $form, $key, $value )
+{
+ if( empty($value) ) return ''; // OK
+ else if( !preg_match('/^[a-zA-Z0-9()-+\/.=?:]*$/',$value) ) return _('Phone entries may only contain a-z, numbers and the characters ()-+/.=?:');
+ else return '';
+}
+
class KolabForm {
/*
* $entries should be an array of the form:
More information about the commits
mailing list