Ticket #1196: client.patch

File client.patch, 26.9 kB (added by JCD, 7 months ago)

Diff of gui/client directory

  • gui/client/add_mail_acc.php

    old new  
    22/** 
    33 * ispCP ω (OMEGA) a Virtual Hosting Control System 
    44 * 
    5  * @copyright         2001-2006 by moleSoftware GmbH 
    6  * @copyright         2006-2008 by ispCP | http://isp-control.net 
    7  * @version   SVN: $ID$ 
    8  * @link              http://isp-control.net 
    9  * @author            ispCP Team 
     5 * @copyright 2001-2006 by moleSoftware GmbH 
     6 * @copyright 2006-2008 by ispCP | http://isp-control.net 
     7 * @version   SVN: $ID$ 
     8 * @link      http://isp-control.net 
     9 * @author    ispCP Team 
    1010 * 
    1111 * @license 
    1212 *   This program is free software; you can redistribute it and/or modify it under 
     
    6565                    'MAIL_DMN_CHECKED' => ($_POST['dmn_type'] === 'dmn') ? "checked=\"checked\"" : "", 
    6666                    'MAIL_ALS_CHECKED' => ($_POST['dmn_type'] === 'als') ? "checked=\"checked\"" : "", 
    6767                    'MAIL_SUB_CHECKED' => ($_POST['dmn_type'] === 'sub') ? "checked=\"checked\"" : "", 
    68                     'NORMAL_MAIL_CHECKED' => ($_POST['mail_type'] === 'normal') ? "checked=\"checked\"" : "", 
    69                     'FORWARD_MAIL_CHECKED' => ($_POST['mail_type'] === 'forward') ? "checked=\"checked\"" : "", 
     68                    'NORMAL_MAIL_CHECKED' => ($_POST['mail_type_normal']) ? "checked=\"checked\"" : "", 
     69                    'FORWARD_MAIL_CHECKED' => ($_POST['mail_type_forward']) ? "checked=\"checked\"" : "", 
    7070                    'FORWARD_LIST' => $f_list)); 
    7171    } 
    7272} 
     
    219219    } else { 
    220220        $mail_acc = $mail_acc_tmp; 
    221221    } 
    222     $mail_auto_respond = '_no_'; 
     222 
     223    $mail_auto_respond = false; 
     224    $mail_auto_respond_text = ''; 
    223225    $mail_addr = ''; 
    224226 
    225     if ($_POST['mail_type'] === 'normal') { 
    226         if ($_POST['dmn_type'] === 'dmn') { 
    227             $mail_pass = $_POST['pass']; 
    228             $mail_forward = '_no_'; 
    229             $mail_type = 'normal_mail'; 
    230             $sub_id = '0'; 
    231             $mail_addr = $mail_acc.'@'.$dmn_name; // the complete address 
    232         } 
    233         else if ($_POST['dmn_type'] === 'sub') { 
    234             $mail_pass = $_POST['pass']; 
    235             $mail_forward = '_no_'; 
    236             $mail_type = 'subdom_mail'; 
    237             $sub_id = $_POST['sub_id']; 
    238             // search the complete address 
    239             $query = <<<SQL_QUERY 
    240                 SELECT 
    241                     `subdomain_name` 
    242                 FROM 
    243                     `subdomain` 
    244                 WHERE 
    245                     `subdomain_id` = ? 
    246 SQL_QUERY; 
    247             $rs = exec_query($sql, $query, array($sub_id)); 
    248             $mail_addr = $mail_acc.'@'.decode_idna($rs->fields['subdomain_name']).'.'.$dmn_name; // the complete address 
    249         } 
    250         else if ($_POST['dmn_type'] === 'als') { 
    251             $mail_pass = $_POST['pass']; 
    252             $mail_forward = '_no_'; 
    253             $mail_type = 'alias_mail'; 
    254             $sub_id = $_POST['als_id']; 
    255             // search the complete address 
    256             $query = <<<SQL_QUERY 
    257                 SELECT 
    258                     `alias_name` 
    259                 FROM 
    260                     `domain_aliasses` 
    261                 WHERE 
    262                     `alias_id` = ? 
     227    if ($_POST['mail_type_normal'] || $_POST['mail_type_forward']) { 
     228        if ($_POST['mail_type_normal']) { 
     229                if ($_POST['dmn_type'] === 'dmn') { 
     230                    $mail_pass = $_POST['pass']; 
     231                    $mail_forward = '_no_'; 
     232                    $mail_type[] = 'normal_mail'; 
     233                    $sub_id = '0'; 
     234                    $mail_addr = $mail_acc.'@'.$dmn_name; // the complete address 
     235                } 
     236                else if ($_POST['dmn_type'] === 'sub') { 
     237                    $mail_pass = $_POST['pass']; 
     238                    $mail_forward = '_no_'; 
     239                    $mail_type[] = 'subdom_mail'; 
     240                    $sub_id = $_POST['sub_id']; 
     241                            // search the complete address 
     242                            $query = <<<SQL_QUERY 
     243                                SELECT 
     244                                    `subdomain_name` 
     245                                FROM 
     246                                    `subdomain` 
     247                                WHERE 
     248                                    `subdomain_id` = ? 
    263249SQL_QUERY; 
    264             $rs = exec_query($sql, $query, array($sub_id)); 
    265             $mail_addr = $mail_acc.'@'.decode_idna($rs->fields['alias_name']); // the complete address 
    266         } else { 
    267             set_page_message(tr('Unknown domain type')); 
    268             return ; 
    269         } 
     250                            $rs = exec_query($sql, $query, array($sub_id)); 
     251                            $mail_addr = $mail_acc.'@'.decode_idna($rs->fields['subdomain_name']).'.'.$dmn_name; // the complete address 
    270252 
    271         $check_acc_query = <<<SQL_QUERY 
    272             SELECT 
    273                 COUNT(mail_id) AS cnt 
    274             FROM 
    275                 mail_users 
    276             WHERE 
    277                 mail_acc = ? 
    278               AND 
    279                 domain_id = ? 
    280               AND 
    281                 mail_type = ? 
    282               AND 
    283                 sub_id = ? 
     253                } 
     254                else if ($_POST['dmn_type'] === 'als') { 
     255                    $mail_pass = $_POST['pass']; 
     256                    $mail_forward = '_no_'; 
     257                    $mail_type[] = 'alias_mail'; 
     258                    $sub_id = $_POST['als_id']; 
     259                            // search the complete address 
     260                            $query = <<<SQL_QUERY 
     261                                SELECT 
     262                                    `alias_name` 
     263                                FROM 
     264                                    `domain_aliasses` 
     265                                WHERE 
     266                                    `alias_id` = ? 
    284267SQL_QUERY; 
    285  
    286         $rs = exec_query($sql, $check_acc_query, array($mail_acc, $domain_id, $mail_type, $sub_id)); 
    287  
    288     } else if ($_POST['mail_type'] === 'forward') { 
    289         if ($_POST['dmn_type'] === 'dmn') { 
    290             $mail_type = 'normal_forward'; 
    291             $sub_id = '0'; 
    292         } else if ($_POST['dmn_type'] === 'sub') { 
    293             $mail_type = 'subdom_forward'; 
    294             $sub_id = $_POST['sub_id']; 
    295         } else if ($_POST['dmn_type'] === 'als') { 
    296             $mail_type = 'alias_forward'; 
    297             $sub_id = $_POST['als_id']; 
    298         } else { 
    299             set_page_message(tr('Unknown domain type')); 
    300             return ; 
    301         } 
    302  
    303         $mail_pass = '_no_'; 
    304         $mail_forward = $_POST['forward_list']; 
    305         $faray = preg_split ("/[\n,]+/", $mail_forward); 
    306         $mail_accs = array(); 
    307  
    308         foreach ($faray as $value) { 
    309             $value = trim($value); 
    310             if (!chk_email($value) && $value !== '') { 
    311                 /* ERR .. strange :) not email in this line - warning */ 
    312                 set_page_message(tr("Mailformat of an address in your forward list is incorrect!")); 
    313                 return; 
    314             } 
    315             else if ($value === '') { 
    316                 set_page_message(tr("Mail forward list empty!")); 
    317                 return; 
    318             } 
    319             $mail_accs[] = $value; 
    320         } 
    321  
    322         $check_acc_query = <<<SQL_QUERY 
    323                   SELECT 
    324                       COUNT(mail_id) AS cnt 
    325                   FROM 
    326                       mail_users 
    327                   WHERE 
    328                       mail_acc = ? 
    329                     AND 
    330                       domain_id = ? 
    331                     AND 
    332                       mail_type = ? 
    333                     AND 
    334                       sub_id = ? 
     268                            $rs = exec_query($sql, $query, array($sub_id)); 
     269                        $mail_addr = $mail_acc.'@'.decode_idna($rs->fields['alias_name']); // the complete address 
     270                } else { 
     271                    set_page_message(tr('Unknown domain type')); 
     272                    return ; 
     273                } 
     274 
     275                } 
     276 
     277        if ($_POST['mail_type_forward']) { 
     278                if ($_POST['dmn_type'] === 'dmn') { 
     279                    $mail_type[] = 'normal_forward'; 
     280                    $sub_id = '0'; 
     281                } else if ($_POST['dmn_type'] === 'sub') { 
     282                    $mail_type[] = 'subdom_forward'; 
     283                    $sub_id = $_POST['sub_id']; 
     284                } else if ($_POST['dmn_type'] === 'als') { 
     285                    $mail_type[] = 'alias_forward'; 
     286                    $sub_id = $_POST['als_id']; 
     287                } else { 
     288                    set_page_message(tr('Unknown domain type')); 
     289                    return ; 
     290                } 
     291 
     292                if (!isset($_POST['mail_type_normal'])) { 
     293                        $mail_pass = '_no_'; 
     294                } 
     295 
     296                $mail_forward = $_POST['forward_list']; 
     297                $faray = preg_split ("/[\n,]+/", $mail_forward); 
     298                $mail_accs = array(); 
     299 
     300                foreach ($faray as $value) { 
     301                    $value = trim($value); 
     302                    if (!chk_email($value) && $value !== '') { 
     303                        /* ERR .. strange :) not email in this line - warning */ 
     304                        set_page_message(tr("Mailformat of an address in your forward list is incorrect!")); 
     305                        return; 
     306                    } 
     307                    else if ($value === '') { 
     308                        set_page_message(tr("Mail forward list empty!")); 
     309                        return; 
     310                    } 
     311                    $mail_accs[] = $value; 
     312                } 
     313 
     314                $mail_forward = implode(',', $mail_accs); 
     315            } 
     316 
     317            $mail_type = implode(',', $mail_type); 
     318 
     319            $check_acc_query = <<<SQL_QUERY 
     320              SELECT 
     321                  COUNT(mail_id) AS cnt 
     322              FROM 
     323                  mail_users 
     324              WHERE 
     325                  mail_acc = ? 
     326                AND 
     327                  domain_id = ? 
     328                        AND 
     329                          mail_type = ? 
     330                AND 
     331                  sub_id = ? 
    335332SQL_QUERY; 
    336333 
    337334        $rs = exec_query($sql, $check_acc_query, array($mail_acc, $domain_id, $mail_type, $sub_id)); 
    338335 
    339         $mail_forward = implode(',', $mail_accs); 
    340336    } 
    341337 
    342338    if ($rs->fields['cnt'] > 0) { 
     
    356352             sub_id, 
    357353             status, 
    358354             mail_auto_respond, 
     355             mail_auto_respond_text, 
    359356             mail_addr) 
    360357        VALUES 
    361             (?, ?, ?, ?, ?, ?, ?, ?, ?
     358            (?, ?, ?, ?, ?, ?, ?, ?, ?, ?
    362359SQL_QUERY; 
    363360 
    364361    $rs = exec_query($sql, $query, array($mail_acc, 
     
    369366            $sub_id, 
    370367            $cfg['ITEM_ADD_STATUS'], 
    371368            $mail_auto_respond, 
    372             $mail_addr)); 
     369            $mail_auto_respond_text, 
     370                $mail_addr)); 
    373371 
    374372    write_log($_SESSION['user_logged'] . ": add new mail account: " . $mail_addr); 
    375373    set_page_message(tr('Mail account scheduled for addition!')); 
  • gui/client/delete_mail_acc.php

    old new  
    6565$res = exec_query($sql, $query, array($delete_id)); 
    6666$data = $res->FetchRow(); 
    6767 
    68 if ($data['mail_type'] == MT_NORMAL_MAIL || $data['mail_type'] == MT_NORMAL_FORWARD) { 
     68if (preg_match(MT_NORMAL_MAIL, $data['mail_type']) || preg_match(MT_NORMAL_FORWARD, $data['mail_type'])) { 
    6969        /* mail to normal domain */ 
    7070        // global $domain_name; 
    7171        $mail_name = $data['mail_acc'] . '@' . $_SESSION['user_logged']; //$domain_name; 
    72 } else if ($data['mail_type'] == MT_ALIAS_MAIL || $data['mail_type'] == MT_ALIAS_FORWARD) { 
     72} else if (preg_match(MT_ALIAS_MAIL, $data['mail_type']) || preg_match(MT_ALIAS_FORWARD, $data['mail_type'])) { 
    7373        /* mail to domain alias*/ 
    7474        $res_tmp = exec_query($sql, "select alias_name from domain_aliasses where alias_id=?", array($data['sub_id'])); 
    7575        $dat_tmp = $res_tmp->FetchRow(); 
    7676        $mail_name = $data['mail_acc'] . '@' . $dat_tmp['alias_name']; 
    77 } else if ($data['mail_type'] == MT_SUBDOM_MAIL || $data['mail_type'] == MT_SUBDOM_FORWARD) { 
     77} else if (preg_match(MT_SUBDOM_MAIL, $data['mail_type']) || preg_match(MT_SUBDOM_FORWARD, $data['mail_type'])) { 
    7878        /* mail to subdomain*/ 
    7979        $res_tmp = exec_query($sql, "select subdomain_name from subdomain where subdomain_id=?", array($data['sub_id'])); 
    8080        $dat_tmp = $res_tmp->FetchRow(); 
  • gui/client/disable_mail_arsp.php

    old new  
    6666            mail_users 
    6767        set 
    6868            status = ?, 
    69             mail_auto_respond = '_no_
     69            mail_auto_respond = '0
    7070        where 
    7171            mail_id = ? 
    7272SQL_QUERY; 
  • gui/client/edit_mail_acc.php

    old new  
    6565        } else { 
    6666                $mail_acc = $rs->fields['mail_acc']; 
    6767                $domain_id = $rs->fields['domain_id']; 
    68                 $mail_type = $rs->fields['mail_type']; 
     68                $mail_type_list = $rs->fields['mail_type']; 
    6969                $mail_forward = $rs->fields['mail_forward']; 
    7070                $sub_id = $rs->fields['sub_id']; 
    71                 if ($mail_type == MT_NORMAL_MAIL) { 
    72                         $mtype = 1; 
    73                         $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
    74                         $tmp1 = $res1->FetchRow(0); 
    75                         $maildomain = $tmp1['domain_name']; 
    76                 } elseif ($mail_type == MT_NORMAL_FORWARD) { 
    77                         $mtype = 4; 
    78                         $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
    79                         $tmp1 = $res1->FetchRow(0); 
    80                         $maildomain = $tmp1['domain_name']; 
    81                 } elseif ($mail_type == MT_ALIAS_MAIL) { 
    82                         $mtype = 2; 
    83                         $res1 = exec_query($sql, "select alias_name from domain_aliasses where alias_id=?", array($sub_id)); 
    84                         $tmp1 = $res1->FetchRow(0); 
    85                         $maildomain = $tmp1['alias_name']; 
    86                 } elseif ($mail_type == MT_ALIAS_FORWARD) { 
    87                         $mtype = 5; 
    88                         $res1 = exec_query($sql, "select alias_name from domain_aliasses where alias_id=?", array($sub_id)); 
    89                         $tmp1 = $res1->FetchRow(); 
    90                         $maildomain = $tmp1['alias_name']; 
    91                 } elseif ($mail_type == MT_SUBDOM_MAIL) { 
    92                         $mtype = 3; 
    93                         $res1 = exec_query($sql, "select subdomain_name from subdomain where subdomain_id=?", array($sub_id)); 
    94                         $tmp1 = $res1->FetchRow(); 
    95                         $maildomain = $tmp1['subdomain_name']; 
    96                         $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
    97                         $tmp1 = $res1->FetchRow(0); 
    98                         $maildomain = $maildomain . "." . $tmp1['domain_name']; 
    99                 } elseif ($mail_type == MT_SUBDOM_FORWARD) { 
    100                         $mtype = 6; 
    101                         $res1 = exec_query($sql, "select subdomain_name from subdomain where subdomain_id=?", array($sub_id)); 
    102                         $tmp1 = $res1->FetchRow(); 
    103                         $maildomain = $tmp1['subdomain_name']; 
    104                         $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
    105                         $tmp1 = $res1->FetchRow(0); 
    106                         $maildomain = $maildomain . "." . $tmp1['domain_name']; 
     71                 
     72                # AR hack 
     73                foreach (explode(',', $mail_type_list) as $mail_type) { 
     74                 
     75                        if ($mail_type == MT_NORMAL_MAIL) { 
     76                                $mtype[] = 1; 
     77                                $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
     78                                $tmp1 = $res1->FetchRow(0); 
     79                                $maildomain = $tmp1['domain_name']; 
     80                        } elseif ($mail_type == MT_NORMAL_FORWARD) { 
     81                                $mtype[] = 4; 
     82                                $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
     83                                $tmp1 = $res1->FetchRow(0); 
     84                                $maildomain = $tmp1['domain_name']; 
     85                        } elseif ($mail_type == MT_ALIAS_MAIL) { 
     86                                $mtype[] = 2; 
     87                                $res1 = exec_query($sql, "select alias_name from domain_aliasses where alias_id=?", array($sub_id)); 
     88                                $tmp1 = $res1->FetchRow(0); 
     89                                $maildomain = $tmp1['alias_name']; 
     90                        } elseif ($mail_type == MT_ALIAS_FORWARD) { 
     91                                $mtype[] = 5; 
     92                                $res1 = exec_query($sql, "select alias_name from domain_aliasses where alias_id=?", array($sub_id)); 
     93                                $tmp1 = $res1->FetchRow(); 
     94                                $maildomain = $tmp1['alias_name']; 
     95                        } elseif ($mail_type == MT_SUBDOM_MAIL) { 
     96                                $mtype[] = 3; 
     97                                $res1 = exec_query($sql, "select subdomain_name from subdomain where subdomain_id=?", array($sub_id)); 
     98                                $tmp1 = $res1->FetchRow(); 
     99                                $maildomain = $tmp1['subdomain_name']; 
     100                                $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
     101                                $tmp1 = $res1->FetchRow(0); 
     102                                $maildomain = $maildomain . "." . $tmp1['domain_name']; 
     103                        } elseif ($mail_type == MT_SUBDOM_FORWARD) { 
     104                                $mtype[] = 6; 
     105                                $res1 = exec_query($sql, "select subdomain_name from subdomain where subdomain_id=?", array($sub_id)); 
     106                                $tmp1 = $res1->FetchRow(); 
     107                                $maildomain = $tmp1['subdomain_name']; 
     108                                $res1 = exec_query($sql, "select domain_name from domain where domain_id=?", array($domain_id)); 
     109                                $tmp1 = $res1->FetchRow(0); 
     110                                $maildomain = $maildomain . "." . $tmp1['domain_name']; 
     111                        } 
     112 
    107113                } 
    108114 
    109115                $mail_forward = $rs->fields['mail_forward']; 
     
    114120                $mail_acc = decode_idna($mail_acc); 
    115121                $maildomain = decode_idna($maildomain); 
    116122                $tpl->assign(array('EMAIL_ACCOUNT' => $mail_acc . "@" . $maildomain, 
    117                                 'FORWARD_LIST' => $mail_forward, 
    118                                 'MTYPE' => $mtype, 
     123                                'FORWARD_LIST' => str_replace(',', "\n", $mail_forward), 
     124                                'MTYPE' => implode(',', $mtype), 
     125                                'MAIL_TYPE' => $mail_type_list, 
    119126                                'MAIL_ID' => $mail_id)); 
    120                 if ($mail_forward === '_no_') { 
    121                         $tpl->assign(array('ACTION' => "update_pass")); 
     127 
     128            if (count($mtype) > 1) { 
     129                $tpl -> assign(array('ACTION' => 'update_pass,update_forward', 
     130                                                                  'FORWARD_MAIL_CHECKED' => 'checked="checked"')); 
    122131                        $tpl->assign('FORWARD_MAIL', ''); 
     132                $tpl -> parse('NORMAL_MAIL', '.normal_mail'); 
     133            } else if ($mail_forward === '_no_') { 
     134                        $tpl->assign(array('ACTION' => 'update_pass', 
     135                                                                'FORWARD_MAIL' => '', 
     136                                                                'FORWARD_MAIL_CHECKED' => '', 
     137                                                                'FORWARD_LIST' => '', 
     138                                                                'FORWARD_LIST_ENABLED' => 'disabled="disabled"')); 
    123139                        $tpl->parse('NORMAL_MAIL', '.normal_mail'); 
    124140                } else { 
    125                         $tpl->assign(array('ACTION' => "update_forward")); 
    126                         $tpl->assign('NORMAL_MAIL', ''); 
     141                        $tpl->assign(array('ACTION' => 'update_forward', 
     142                                                               'NORMAL_MAIL' => '')); 
    127143                        $tpl->parse('FORWARD_MAIL', '.forward_mail'); 
    128144                } 
    129145        } 
     
    133149        if (!isset($_POST['uaction'])) { 
    134150                return; 
    135151        } 
    136         if ($_POST['uaction'] != 'update_pass') { 
     152        if (preg_match('/update_pass/', $_POST['uaction']) == 0) { 
    137153                return; 
    138154        } 
     155        if (preg_match('/update_forward/', $_POST['uaction']) == 1 || isset($_POST['mail_forward'])) { 
     156                // The user only wants to update the forward list, not the password 
     157                if ($_POST['pass'] === '' || $_POST['pass_rep'] === '') { 
     158                        return; 
     159                } 
     160        } 
    139161 
    140162        $pass = escapeshellcmd($_POST['pass']); 
    141163        $pass_rep = escapeshellcmd($_POST['pass_rep']); 
     
    170192 
    171193                $rs = exec_query($sql, $query, array($pass, $status, $mail_id)); 
    172194 
    173                 send_request(); 
    174                 set_page_message(tr("Mail were updated successfully!")); 
    175195                write_log($_SESSION['user_logged'] . ": change mail account password: $mail_account"); 
    176196 
    177                 header("Location: email_accounts.php"); 
    178                 die(); 
     197                if (preg_match('/update_forward/', $_POST['uaction']) == 0 && !isset($_POST['mail_forward'])) { 
     198                        send_request(); 
     199                        set_page_message(tr("Mail were updated successfully!")); 
     200                        header("Location: email_accounts.php"); 
     201                        die(); 
     202                } 
    179203        } 
    180204} 
    181205 
     
    183207        if (!isset($_POST['uaction'])) { 
    184208                return; 
    185209        } 
    186         if ($_POST['uaction'] != 'update_forward') { 
     210        if (preg_match('/update_forward/', $_POST['uaction']) == 0 && !isset($_POST['mail_forward'])) { 
    187211                return; 
    188212        } 
    189213 
     
    192216        $forward_list = clean_input($_POST['forward_list']); 
    193217        $mail_accs = array(); 
    194218 
    195         $faray = preg_split ("/[\n,]+/", $forward_list); 
     219        if (isset($_POST['mail_forward'])) { 
     220             
     221                $faray = preg_split ("/[\n,]+/", $forward_list); 
     222         
     223                foreach ($faray as $value) { 
     224                        $value = trim($value); 
     225                        if (!chk_email($value) && $value !== '') { 
     226                                /* ERR .. strange :) not email in this line - warrning */ 
     227                                set_page_message(tr("Mail forward list error!")); 
     228                                return; 
     229                        } else if ($value === '') { 
     230                                set_page_message(tr("Mail forward list error!")); 
     231                                return; 
     232                        } 
     233                        $mail_accs[] = $value; 
     234                } 
     235                 
     236                $forward_list = implode(',', $mail_accs); 
     237                 
     238                // Check if the mail type doesn't contain xxx_forward and append it 
     239                if (preg_match('/_forward/', $_POST['mail_type']) == 0) { 
     240                    
     241                    // Get mail account type and append the corresponding xxx_forward 
     242                        if ($_POST['mail_type'] == MT_NORMAL_MAIL) { 
     243                                $mail_type = $_POST['mail_type'] . ',' . MT_NORMAL_FORWARD; 
     244                        } elseif ($_POST['mail_type'] == MT_ALIAS_MAIL) { 
     245                                $mail_type = $_POST['mail_type'] . ',' . MT_ALIAS_FORWARD; 
     246                        } elseif ($_POST['mail_type'] == MT_SUBDOM_MAIL) { 
     247                                $mail_type = $_POST['mail_type'] . ',' . MT_SUBDOM_FORWARD; 
     248                        } 
    196249 
    197         foreach ($faray as $value) { 
    198                 $value = trim($value); 
    199                 if (!chk_email($value) && $value !== '') { 
    200                         /* ERR .. strange :) not email in this line - warrning */ 
    201                         set_page_message(tr("Mail forward list error!")); 
    202                         return; 
    203                 } else if ($value === '') { 
    204                         set_page_message(tr("Mail forward list error!")); 
    205                         return; 
     250                } else { 
     251                     
     252                    // The mail type already contains xxx_forward, so we can use $_POST['mail_type']                 
     253                    $mail_type = $_POST['mail_type']; 
     254                } 
     255         
     256        } else { 
     257            $forward_list = '_no_'; 
     258             
     259                // Check if mail type was a forward type and remove it 
     260                if (preg_match('/_forward/', $_POST['mail_type']) == 1) { 
     261                    $mail_type = preg_replace('/,[a-z]+_forward$/', '', $_POST['mail_type']); 
    206262                } 
    207                 $mail_accs[] = $value; 
    208         } 
    209263 
     264        } 
     265         
    210266        global $cfg; 
    211267        $status = $cfg['ITEM_CHANGE_STATUS']; 
    212268 
     
    217273              mail_users 
    218274          set 
    219275              mail_forward = ?, 
     276              mail_type = ?, 
    220277              status = ? 
    221278          where 
    222279              mail_id = ? 
    223280SQL_QUERY; 
    224281 
    225         $rs = exec_query($sql, $query, array(implode(',', $mail_accs), $status, $mail_id)); 
     282        $rs = exec_query($sql, $query, array($forward_list, $mail_type, $status, $mail_id)); 
    226283 
    227284        send_request(); 
    228285        write_log($_SESSION['user_logged'] . ": change mail forward: $mail_account"); 
     286        set_page_message(tr("Mail were updated successfully!")); 
    229287        header("Location: email_accounts.php"); 
    230288        die(); 
    231289} 
     
    259317                'TR_SAVE' => tr('Save'), 
    260318                'TR_PASSWORD' => tr('Password'), 
    261319                'TR_PASSWORD_REPEAT' => tr('Repeat password'), 
     320                'TR_FORWARD_MAIL' => tr('Forward mail'), 
     321        'TR_FORWARD_TO' => tr('Forward to'), 
     322        'TR_FWD_HELP' => tr("Separate multiple email addresses with a line-break."), 
    262323                'TR_EDIT' => tr('Edit'))); 
    263324 
    264325gen_page_message($tpl); 
  • gui/client/edit_mail_arsp.php

    old new  
    6464        if ($read_from_db) { 
    6565                $query = <<<SQL_QUERY 
    6666                        SELECT 
    67                                 mail_auto_respond, mail_acc 
     67                                mail_auto_respond_text, mail_acc 
    6868                        FROM 
    6969                                mail_users 
    7070                        WHERE 
     
    7373                $rs = exec_query($sql, $query, array($mail_id)); 
    7474                $mail_name = $rs->fields['mail_acc']; 
    7575 
    76                 $tpl->assign('ARSP_MESSAGE', $rs->fields['mail_auto_respond']); 
     76                $tpl->assign('ARSP_MESSAGE', $rs->fields['mail_auto_respond_text']); 
    7777                return; 
    7878        } else { 
    7979                $arsp_message = clean_input($_POST['arsp_message']); 
     
    9494                mail_users 
    9595            set 
    9696                status = ?, 
    97                 mail_auto_respond = ? 
     97                mail_auto_respond_text = ? 
    9898            where 
    9999                mail_id = ? 
    100100SQL_QUERY; 
  • gui/client/email_accounts.php

    old new  
    4747function gen_user_mail_auto_respond(&$tpl, $mail_id, $mail_type, $mail_status, $mail_auto_respond) { 
    4848        global $cfg; 
    4949 
    50         if (preg_match('/_mail$/', $mail_type) == 1) { 
     50        if (preg_match('/_mail/', $mail_type) == 1) { 
    5151                if ($mail_status === $cfg['ITEM_OK_STATUS']) { 
    52                         if ($mail_auto_respond === '_no_') { 
     52                        if ($mail_auto_respond == 0) { 
    5353                                $tpl->assign( 
    5454                                        array('AUTO_RESPOND_DISABLE' => tr('Enable'), 
    5555                                                'AUTO_RESPOND_DISABLE_SCRIPT' => "enable_mail_arsp.php?id=$mail_id", 
     
    9797          AND 
    9898            sub_id = 0 
    9999          AND 
    100             (mail_type  = 'normal_mail' OR mail_type  = 'normal_forward') 
     100            (mail_type  LIKE '%normal_mail%' OR mail_type  LIKE '%normal_forward%') 
    101101        ORDER BY 
    102             mail_type DESC, 
    103             mail_acc ASC 
     102            mail_acc ASC, 
     103            mail_type DESC 
     104             
    104105SQL_QUERY; 
    105106 
    106107        $rs = exec_query($sql, $dmn_query, array($dmn_id)); 
     
    121122 
    122123                        $show_dmn_name = decode_idna($dmn_name); 
    123124 
     125                        $mail_types = explode(',', $rs->fields['mail_type']); 
     126                         
     127                        $mail_type = ''; 
     128                         
     129                        foreach ($mail_types as $type) { 
     130                            $mail_type .= user_trans_mail_type($type) . '<br \>'; 
     131                        } 
     132 
    124133                        $tpl->assign( 
    125134                                array('MAIL_ACC' => $mail_acc . "@" . $show_dmn_name, 
    126                                         'MAIL_TYPE' => user_trans_mail_type($rs->fields['mail_type'])
     135                                        'MAIL_TYPE' => $mail_type
    127136                                        'MAIL_STATUS' => translate_dmn_status($rs->fields['status']), 
    128137                                        'MAIL_ACTION' => $mail_action, 
    129138                                        'MAIL_ACTION_SCRIPT' => $mail_action_script, 
     
    165174          AND 
    166175            t2.domain_id = ? 
    167176          AND 
    168             (t2.mail_type = 'subdom_mail' OR t2.mail_type = 'subdom_forward') 
     177            (t2.mail_type LIKE '%subdom_mail%' OR t2.mail_type LIKE '%subdom_forward%') 
    169178          AND 
    170179            t1.subdomain_id = t2.sub_id 
    171180        ORDER BY 
    172             t2.mail_type DESC, 
    173                        t2.mail_acc ASC 
     181            t2.mail_acc ASC, 
     182            t2.mail_type DESC 
    174183SQL_QUERY; 
    175184 
    176185        $rs = exec_query($sql, $sub_query, array($dmn_id, $dmn_id)); 
     
    194203 
    195204                        $show_dmn_name = decode_idna($dmn_name); 
    196205 
     206                        $mail_types = explode(',', $rs->fields['mail_type']); 
     207                         
     208                        $mail_type = ''; 
     209                         
     210                        foreach ($mail_types as $type) { 
     211                            $mail_type .= user_trans_mail_type($type) . '<br \>'; 
     212                        } 
     213 
    197214                        $tpl->assign( 
    198215                                array('MAIL_ACC' => $mail_acc . "@" . $show_sub_name . "." . $show_dmn_name, 
    199                                         'MAIL_TYPE' => user_trans_mail_type($rs->fields['mail_type'])
     216                                        'MAIL_TYPE' => $mail_type
    200217                                        'MAIL_STATUS' => translate_dmn_status($rs->fields['status']), 
    201218                                        'MAIL_ACTION' => $mail_action, 
    202219                                        'MAIL_ACTION_SCRIPT' => $mail_action_script, 
     
    240257          AND 
    241258            t1.alias_id = t2.sub_id 
    242259          AND 
    243             (t2.mail_type = 'alias_mail' OR t2.mail_type = 'alias_forward') 
     260            (t2.mail_type LIKE '%alias_mail%' OR t2.mail_type LIKE '%alias_forward%') 
    244261        ORDER BY 
    245             t2.mail_type DESC, 
    246                        t2.mail_acc ASC 
     262            t2.mail_acc ASC, 
     263            t2.mail_type DESC 
    247264SQL_QUERY; 
    248265 
    249266        $rs = exec_query($sql, $als_query, array($dmn_id, $dmn_id)); 
     
    266283 
    267284                        $show_als_name = decode_idna($rs->fields['als_name']); 
    268285 
     286                        $mail_types = explode(',', $rs->fields['mail_type']); 
     287                         
     288                        $mail_type = ''; 
     289                         
     290                        foreach ($mail_types as $type) { 
     291                            $mail_type .= user_trans_mail_type($type) . '<br \>'; 
     292                        } 
     293 
    269294                        $tpl->assign( 
    270295                                array('MAIL_ACC' => $mail_acc . "@" . $show_als_name, 
    271                                         'MAIL_TYPE' => user_trans_mail_type($rs->fields['mail_type'])
     296                                        'MAIL_TYPE' => $mail_type
    272297                                        'MAIL_STATUS' => translate_dmn_status($rs->fields['status']), 
    273298                                        'MAIL_ACTION' => $mail_action, 
    274299                                        'MAIL_ACTION_SCRIPT' => $mail_action_script, 
  • gui/client/enable_mail_arsp.php

    old new  
    7777                mail_users 
    7878            set 
    7979                status = ?, 
    80                 mail_auto_respond = ? 
     80                mail_auto_respond = '1', 
     81                mail_auto_respond_text = ? 
    8182            where 
    8283                mail_id = ? 
    8384SQL_QUERY; 
     
    106107                header("Location: email_accounts.php"); 
    107108                exit(0); 
    108109        } else { 
    109                 $tpl->assign('ARSP_MESSAGE', ''); 
     110                // Get Message 
     111                $query = <<<SQL_QUERY 
     112                        SELECT 
     113                                mail_auto_respond_text, mail_acc 
     114                        FROM 
     115                                mail_users 
     116                        WHERE 
     117                                mail_id = ? 
     118SQL_QUERY; 
     119                $rs = exec_query($sql, $query, array($mail_id)); 
     120                $mail_name = $rs->fields['mail_acc']; 
     121 
     122                $tpl->assign('ARSP_MESSAGE', $rs->fields['mail_auto_respond_text']); 
     123                return; 
    110124        } 
    111125} 
    112126