SF.net SVN: postfixadmin:[898] branches/postfixadmin-2.3
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2010-12-25 14:11:23
|
Revision: 898 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=898&view=rev Author: christian_boltz Date: 2010-12-25 14:11:16 +0000 (Sat, 25 Dec 2010) Log Message: ----------- create-alias: support multiple alias targets - support multiple alias targets, patch by anexius@SF, http://sourceforge.net/projects/postfixadmin/forums/forum/676076/topic/4004442 The patch fixes https://sourceforge.net/tracker/?func=detail&aid=2706290&group_id=191583&atid=937964 additional small fixes: - replace spaces only at the start and end of a line, not in the middle of an (BTW: invalid) mail address - allow multiple error messages (separated by <br /> - prevent input data loss on validation errors (I'll port this to trunk.) Modified Paths: -------------- branches/postfixadmin-2.3/create-alias.php branches/postfixadmin-2.3/templates/create-alias.php Modified: branches/postfixadmin-2.3/create-alias.php =================================================================== --- branches/postfixadmin-2.3/create-alias.php 2010-12-23 01:12:56 UTC (rev 897) +++ branches/postfixadmin-2.3/create-alias.php 2010-12-25 14:11:16 UTC (rev 898) @@ -75,9 +75,10 @@ $fDomain = escape_string ($_POST['fDomain']); } - if(!preg_match ('/@/',$fGoto)) { - $fGoto = $fGoto . "@" . escape_string ($_POST['fDomain']); - } +# TODO: Doesn't work with multiple aliases - fix or discard... +# if(!preg_match ('/@/',$fGoto)) { +# $fGoto = $fGoto . "@" . escape_string ($_POST['fDomain']); +# } if(!(authentication_has_role('global-admin') || check_owner ($SESSID_USERNAME, $fDomain) )) @@ -105,7 +106,42 @@ $pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error1']; } - if (empty($fGoto) || !check_email ($fGoto)) { + // Begin check alias email + $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); + $goto = preg_replace ('/\r\n/', ',', $goto); + $goto = preg_replace ('/,[\s]+/i', ',', $goto); + $goto = preg_replace ('/[\s]+,/i', ',', $goto); + $goto = preg_replace ('/,*$|^,*/', '', $goto); + $goto = preg_replace ('/,,*/', ',', $goto); + + if (empty ($goto) && !authentication_has_role('global-admin')) { + $error = 1; + $tGoto = $_POST['fGoto']; + $tMessage = $PALANG['pEdit_alias_goto_text_error1']; + } + + $new_aliases = array(); + if ($error != 1) { + $new_aliases = explode(',', $goto); + } + $new_aliases = array_unique($new_aliases); + + foreach($new_aliases as $address) { + if (in_array($address, $CONF['default_aliases'])) continue; + if (empty($address)) continue; # TODO: should never happen - remove after 2.2 release + if (!check_email($address)) { + $error = 1; + $tGoto = $goto; + if (!empty($tMessage)) $tMessage .= "<br />"; + $tMessage .= $PALANG['pEdit_alias_goto_text_error2'] . "$address</span>"; + } + } + + $goto = implode(',', $new_aliases); + $fGoto = escape_string($goto); + // End check alias mail + + if (empty($fGoto)) { $error = 1; $tAddress = escape_string ($_POST['fAddress']); $tGoto = $fGoto; @@ -150,6 +186,11 @@ $tDomain = $fDomain; $tMessage = $PALANG['pCreate_alias_result_success'] . "<br />($fAddress -> $fGoto)<br />\n"; } + } else { # on error + $tAddress = htmlentities($_POST['fAddress']); + $tGoto = htmlentities($_POST['fGoto']); + $tDomain = htmlentities($_POST['fDomain']); + } } Modified: branches/postfixadmin-2.3/templates/create-alias.php =================================================================== --- branches/postfixadmin-2.3/templates/create-alias.php 2010-12-23 01:12:56 UTC (rev 897) +++ branches/postfixadmin-2.3/templates/create-alias.php 2010-12-25 14:11:16 UTC (rev 898) @@ -30,8 +30,7 @@ </tr> <tr> <td><?php print $PALANG['pCreate_alias_goto'] . ":"; ?></td> - <td><input class="flat" type="text" name="fGoto" value="<?php print $tGoto; ?>" /></td> - <td><?php print $pCreate_alias_goto_text; ?></td> + <td colspan="2"><textarea class="flat" rows="10" cols="60" name="fGoto"><?php print $tGoto; ?></textarea></td> </tr> <tr> <td><?php print $PALANG['pCreate_alias_active'] . ":"; ?></td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |