Menu

Multi-line text Input patch for create alias

2010-12-07
2013-01-23
  • Konstantin Sapronov

    Hello,
    This patch, which will replace the input text field to multi-line text input field.
    postfixadmin v2.3.2

    for create-alias.php

    --- create-alias.php    2009-05-08 06:23:21.000000000 +0700
    +++ create-alias.php.new    2010-12-07 14:01:26.000000000 +0600
    @@ -75,10 +75,6 @@
             $fDomain = escape_string ($_POST['fDomain']);
         }
    
    -    if(!preg_match ('/@/',$fGoto)) {
    -        $fGoto = $fGoto . "@" . escape_string ($_POST['fDomain']);
    -    }
    -
         if(!(authentication_has_role('global-admin') || 
             check_owner ($SESSID_USERNAME, $fDomain) ))
         {
    @@ -104,8 +100,41 @@
             $tDomain = $fDomain;
             $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 ('/,*$|^,*/', '', $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; 
    +       $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;
    

    for templates/create-alias.php

    --- create-alias.php    2009-07-19 19:25:47.000000000 +0700
    +++ create-alias.php.new    2010-12-07 13:15:37.000000000 +0600
    @@ -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="30" name="fGoto" value="<?php print $tGoto; ?>"></textarea></td>
        </tr>
        <tr>
           <td><?php print $PALANG['pCreate_alias_active'] . ":"; ?></td>
    
     
  • Anonymous

    Anonymous - 2010-12-24

    A very big thanks for this patch: I was about to ask postfixadmin author to include this feature in a next release but hopefully, you already did the job!

    Thanks again, and good year-end celebration!

    Regards

     
  • Christian Boltz

    Christian Boltz - 2010-12-25

    Thanks for the patch!

    I just commited it to SVN r898 (2.3 branch, will be in 2.3.3) and r900 (trunk).

     

Log in to post a comment.