summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@pardus.de>2007-07-12 16:28:23 (GMT)
committerGunnar Wrobel <wrobel@pardus.de>2007-07-12 16:28:23 (GMT)
commit553fe9ad5d868902b1bfd5090f892707fc26ee56 (patch)
treeb614b811803643ee5956aafe4a22206f638218b8
parent7ed377d16c2de5abdcc948ffc5debdfc1db8568a (diff)
downloadkolab-webadmin-553fe9ad5d868902b1bfd5090f892707fc26ee56.tar.gz
Remove code duplications.
-rw-r--r--ChangeLog2
-rw-r--r--php/admin/include/form.class.php36
-rw-r--r--www/admin/addressbook/addr.php.in24
-rw-r--r--www/admin/sharedfolder/sf.php.in12
-rw-r--r--www/admin/user/user.php.in36
5 files changed, 38 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index c00c17b..ef622d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@
fixed kolab/issue932 (Illegal values in webadmin cause LDAP errors)
https://intevation.de/roundup/kolab/issue932
+ Removed code duplications.
+
2007-07-11 Gunnar Wrobel <p@rdus.de>
* www/admin/sharedfolder/sf.php.in:
diff --git a/php/admin/include/form.class.php b/php/admin/include/form.class.php
index bfd76f1..3c154d4 100644
--- a/php/admin/include/form.class.php
+++ b/php/admin/include/form.class.php
@@ -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:
diff --git a/www/admin/addressbook/addr.php.in b/www/admin/addressbook/addr.php.in
index 934f9ad..5d816be 100644
--- a/www/admin/addressbook/addr.php.in
+++ b/www/admin/addressbook/addr.php.in
@@ -74,30 +74,6 @@ function checkuniquemail( $form, $key, $value ) {
}
}
-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;
-}
-
-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 '';
-}
-
/**** Submenu for current page ***/
$menuitems[$sidx]['selected'] = 'selected';
$heading = '';
diff --git a/www/admin/sharedfolder/sf.php.in b/www/admin/sharedfolder/sf.php.in
index b36fccc..018726b 100644
--- a/www/admin/sharedfolder/sf.php.in
+++ b/www/admin/sharedfolder/sf.php.in
@@ -25,18 +25,6 @@ if( $group != 'maintainer' && $group != 'admin' && $group != 'domain-maintainer'
array_push($errors, _("Error: You don't have Permissions to access this Menu"));
}
-// 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 '';
-}
-
require_once('@kolab_php_module_prefix@admin/include/menu.php');
function fill_form_for_modify( &$form, &$ldap_object ) {
diff --git a/www/admin/user/user.php.in b/www/admin/user/user.php.in
index ef125ea..e478b5a 100644
--- a/www/admin/user/user.php.in
+++ b/www/admin/user/user.php.in
@@ -117,23 +117,6 @@ function checkuniquemail( $form, $key, $value ) {
}
}
-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;
-}
-
function checkuid( $form, $key, $value ) {
global $ldap;
global $action;
@@ -221,18 +204,6 @@ function checkpolicy( $form, $key, $value ) {
return '';
}
-// 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 checkfreebusyfuture( $form, $key, $value )
{
if( empty($value) ) return ''; // OK
@@ -242,13 +213,6 @@ function checkfreebusyfuture( $form, $key, $value )
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 '';
-}
-
function policy2number( $pol, $default = 3 )
{
// Translate policy to number