summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Konold <martin.konold@erfrakon.de>2007-07-02 22:33:47 (GMT)
committerMartin Konold <martin.konold@erfrakon.de>2007-07-02 22:33:47 (GMT)
commitebc749970732524ad86389f8342bb059e6c97edc (patch)
tree17677d1fc092de93ebdc64eca4907c9bc69234a1
parent6898dab295d4a7ff94c8c5bb6d6c380d89123180 (diff)
downloadkolab-webadmin-ebc749970732524ad86389f8342bb059e6c97edc.tar.gz
Martin Konold: unfinished support for kolabAllowSMTPRecipient (I am tired now)
-rw-r--r--www/admin/user/user.php.in52
1 files changed, 52 insertions, 0 deletions
diff --git a/www/admin/user/user.php.in b/www/admin/user/user.php.in
index 3790798..ac96dd4 100644
--- a/www/admin/user/user.php.in
+++ b/www/admin/user/user.php.in
@@ -165,6 +165,49 @@ function checkdelegate( $form, $key, $value ) {
return '';
}
+function checksmtprecipient ( $form, $key, $value ) {
+ $lst = array_unique( array_filter( array_map( 'trim', preg_split( '/\n/', $value ) ), 'strlen') );
+ $str = '';
+ foreach( $lst as $SMTPRecipient ) {
+ $trimmed = ltrim($SMTPRecipient, "-."); // potentially every entry is negated with a '-'
+ // $SMTPRecipient is either an
+ // - email address
+ // - local part of an email address with an @ suffix
+ // - a domain part
+
+ if (! ( valid_email_address($SMTPRecipient)
+ | valid_domain($SMTPRecipient)
+ | valid_local_part($SMTPRecipient))
+ return sprintf(_("Syntax for Recipient %s is invalid"), $SMTPRecipient);
+ }
+ }
+ return '';
+}
+
+
+function valid_email_address($address) {
+// the following addresses are invalid
+// email1..@kolab.org
+// email1.-@kolab.org
+// email1._@kolab.org
+// email1@2sub.kolab.org
+// email1@sub.sub.2sub.kolab.org
+ return preg_match("/^[a-z]+[a-z0-9]*[\.|\-|_]?[a-z0-9]+@([a-z]+[a-z0-9]*[\.|\-]?[a-z]+[a-z0-9]*[a-z0-9]+){1,4}\.[a-z]{2,4}$/i", $address));
+}
+
+function valid_domain($domain) {
+// the following subdomains are invalid
+// 2sub.kolab.org
+// sub.sub.2sub.kolab.org
+ return preg_match("/^[a-z]+[a-z0-9]*[\.|\-]?[a-z]+[a-z0-9]*[a-z0-9]+){1,4}\.[a-z]{2,4}$/i", $domain));
+}
+
+function valid_local_part($local_part) {
+ // the local part always has an @ appended
+ return preg_match("/^[a-z]+[a-z0-9]*[\.|\-|_]?[a-z0-9]+@/i", $local_part));
+}
+
+
// Check uid/gid used in invitation policy
// We're pretty relaxed about what is entered
// here and only check some basic syntax
@@ -443,15 +486,24 @@ $entries = array( 'givenname' => array( 'name' => _('First Name'),
'comment' => _('For automatic invitation handling') . '<br/>' .
_("NOTE: For regular accounts to use this feature, give the 'calendar' user access to the Calendar folder") ),
'title_0' => array( 'name' => _('Title') ) );
+
$entries['alias'] = array( 'name' => _('Email Aliases'),
'type' => 'textarea',
'validation' => 'checkuniquealias',
'comment' => _('One address per line') );
+
$entries['kolabdelegate'] =array( 'name' => _('Email-Delegates'),
'type' => 'textarea',
'validation' => 'checkdelegate',
'comment' => _('Others allowed to send emails with a "from" address of this account.') . '<br/>' .
_('One email address per line.') );
+
+$entries['kolabAllowSMTPRecipient'] =array( 'name' => _('Allowed Recipients'),
+ 'type' => 'textarea',
+ 'validation' => 'checksmtprecipient',
+ 'comment' => _('restrict allowed recipients of SMTP messages') . '<br/>' .
+ _('One entry per line.') );
+
$entries['o_0'] = array( 'name' => _('Organisation') );
$entries['ou_0'] = array( 'name' => _('Organisational Unit') );
$entries['roomNumber_0'] = array( 'name' => _('Room Number') );