Pārlūkot izejas kodu

[Fix] Fixes multiple small bugs in email stack (#1501)

* Allow use of :blackhole: [#1460]
Removed requirement password for :forward_only: [#1001]
Fixed bug that password requirement didn’t need to be met with new email account  [#1450]

* Added an option forward to blackhole via checkbox

* Update text Todo update Getext

* Hide fwd_for field when blackhole is selected
Jaap Marcus 5 gadi atpakaļ
vecāks
revīzija
2be1a52d44

+ 4 - 1
bin/v-add-mail-account-forward

@@ -34,7 +34,10 @@ format_domain_idn
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
 check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
-is_format_valid 'user' 'domain' 'account' 'email_forward'
+is_format_valid 'user' 'domain' 'account'
+if [ "$email_forward"  != ':blackhole:' ]; then
+    is_format_valid 'email_forward'
+fi
 is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
 is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"

+ 3 - 1
bin/v-delete-mail-account-forward

@@ -34,7 +34,9 @@ format_domain_idn
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
 check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
-is_format_valid 'user' 'domain' 'account' 'forward'
+if [ "$forward"  != ':blackhole:' ]; then
+    is_format_valid 'forward'
+fi
 is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
 is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"

+ 28 - 28
install/deb/themes/dark.css

@@ -621,6 +621,29 @@ label {
 label:hover {
 label:hover {
   color: #d4d4d4 !important;
   color: #d4d4d4 !important;
 }
 }
+.vst-textinput {
+    background-color: #454545;
+    border: 1px solid #606060;
+    color: #d4d4d4;
+    box-shadow: 0px 1px 4px rgba(0,0,0,0.35);
+}
+.vst-textinput:hover {
+    border: 1px solid #0090ff;
+    background-color: #494949;
+}
+.vst-textinput:focus {
+    background-color: #222222;
+    border-color: #0080df;
+    color: #fff !important;
+    box-shadow: 0px 1px 6px rgba(0,52,91,0.75);
+}
+.vst-textinput.console{
+    
+}
+.vst-textinput.short {
+    
+}
+    
 .vst-input {
 .vst-input {
   background-color: #454545;
   background-color: #454545;
   border: 1px solid #606060;
   border: 1px solid #606060;
@@ -640,7 +663,9 @@ label:hover {
 }
 }
 
 
 .vst-input:disabled,
 .vst-input:disabled,
-.vst-list:disabled {
+.vst-list:disabled,
+.vst-textinput:disabled
+ {
   background-color: #303030;
   background-color: #303030;
   text-shadow: 1px 1px rgba(0,0,0,0.3);
   text-shadow: 1px 1px rgba(0,0,0,0.3);
   color: #acacac;
   color: #acacac;
@@ -651,7 +676,8 @@ label:hover {
 }
 }
 
 
 .vst-input:disabled:hover,
 .vst-input:disabled:hover,
-.vst-list:disabled:hover {
+.vst-list:disabled:hover,
+.vst-textinput:disabled:hover {
   border-color: #606060 !important;
   border-color: #606060 !important;
 }
 }
 
 
@@ -740,32 +766,6 @@ a.vst-text:active b{
 
 
 .advanced-options .fas {
 .advanced-options .fas {
 
 
-}
-
-.vst-textinput {
-  background-color: #454545;
-  border: 1px solid #606060;
-  color: #d4d4d4;
-  box-shadow: 0px 1px 4px rgba(0,0,0,0.35);
-}
-.vst-textinput:hover {
-  border: 1px solid #0090ff;
-  background-color: #494949;
-}
-.vst-textinput:focus {
-  background-color: #222222;
-  border-color: #0080df;
-  color: #fff !important;
-  box-shadow: 0px 1px 6px rgba(0,52,91,0.75);
-}
-.vst-textinput:disabled {
-  background-color: #454545;
-}
-.vst-textinput.console{
-
-}
-.vst-textinput.short {
-
 }
 }
 #advanced-options .console{
 #advanced-options .console{
 
 

+ 17 - 3
web/add/mail/index.php

@@ -98,11 +98,18 @@ if (!empty($_POST['ok_acc'])) {
     }
     }
     
     
     
     
-
+    // Check antispam option
+    if (!empty($_POST['v_blackhole'])) {
+        $v_blackhole = 'yes';
+    } else {
+        $v_blackhole = 'no';
+    }
     // Check empty fields
     // Check empty fields
     if (empty($_POST['v_domain'])) $errors[] = _('domain');
     if (empty($_POST['v_domain'])) $errors[] = _('domain');
     if (empty($_POST['v_account'])) $errors[] = _('account');
     if (empty($_POST['v_account'])) $errors[] = _('account');
-    if (empty($_POST['v_password'])) $errors[] = _('password');
+    if ((empty($_POST['v_fwd_only']) && empty($_POST['v_password']))) {
+        if (empty($_POST['v_password'])) $errors[] = _('password');
+    }
     if (!empty($errors[0])) {
     if (!empty($errors[0])) {
         foreach ($errors as $i => $error) {
         foreach ($errors as $i => $error) {
             if ( $i == 0 ) {
             if ( $i == 0 ) {
@@ -122,7 +129,7 @@ if (!empty($_POST['ok_acc'])) {
     }
     }
     
     
     // Check password length
     // Check password length
-    if (empty($_SESSION['error_msg']) && !empty($_POST['v_fwd_only']) ) {
+    if (empty($_SESSION['error_msg']) && (empty($_POST['v_fwd_only']))) {
         if (!validate_password($_POST['v_password'])) { $_SESSION['error_msg'] = _('Password does not match the minimum requirements');}
         if (!validate_password($_POST['v_password'])) { $_SESSION['error_msg'] = _('Password does not match the minimum requirements');}
     }
     }
 
 
@@ -168,6 +175,13 @@ if (!empty($_POST['ok_acc'])) {
         }
         }
     }
     }
 
 
+    if ((!empty($_POST['v_blackhole'])) && (empty($_SESSION['error_msg']))){
+        exec (HESTIA_CMD."v-add-mail-account-forward ".$user." ".$v_domain." ".$v_account." :blackhole:", $output, $return_var);
+        check_return_code($return_var,$output);
+        unset($output);
+        //disable  any input in v_fwd
+        $_POST['v_fwd'] = '';
+    }
     // Add Forwarders
     // Add Forwarders
     if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) {
     if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) {
         $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);
         $vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);

+ 7 - 3
web/css/src/styles.css

@@ -2553,19 +2553,23 @@ label:hover {
 }
 }
 
 
 .vst-input:disabled,
 .vst-input:disabled,
-.vst-list:disabled {
+.vst-list:disabled,
+.vst-textinput:disabled
+ {
   background-color: #e7e7e7;
   background-color: #e7e7e7;
   text-shadow: 1px 1px rgba(255,255,255,1);
   text-shadow: 1px 1px rgba(255,255,255,1);
   color: #686868;
   color: #686868;
 }
 }
 
 
-.vst-input:focus:disabled {
+.vst-input:focus:disabled,
+.vst-textinput:disabled {
   border-color: #f1f1f1;
   border-color: #f1f1f1;
   background-color: #f1f1f1;
   background-color: #f1f1f1;
 }
 }
 
 
 .vst-input:disabled:hover,
 .vst-input:disabled:hover,
-.vst-list:disabled:hover {
+.vst-list:disabled:hover
+.vst-textinput:disabled:hover {
   border-color: #cfcfcf;
   border-color: #cfcfcf;
 }
 }
 
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
web/css/styles.min.css


+ 24 - 3
web/edit/mail/index.php

@@ -93,6 +93,12 @@ if ((!empty($_GET['domain'])) && (!empty($_GET['account']))) {
     $v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']);
     $v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']);
     $valiases = explode(",", $data[$v_account]['ALIAS']);
     $valiases = explode(",", $data[$v_account]['ALIAS']);
     $v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']);
     $v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']);
+    if ($v_fwd == ":blackhole:") {
+        $v_fwd = '';
+        $v_blackhole = "yes";
+    }else{
+        $v_blackhole = "no";        
+    }
     $vfwd = explode(",", $data[$v_account]['FWD']);
     $vfwd = explode(",", $data[$v_account]['FWD']);
     $v_fwd_only = $data[$v_account]['FWD_ONLY'];
     $v_fwd_only = $data[$v_account]['FWD_ONLY'];
     $v_quota = $data[$v_account]['QUOTA'];
     $v_quota = $data[$v_account]['QUOTA'];
@@ -155,7 +161,7 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['accou
         unset($output);
         unset($output);
     }
     }
 
 
-    // Add antivirs
+    // Add antivirus
     if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) {
     if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) {
         exec (HESTIA_CMD."v-add-mail-domain-antivirus ".$v_username." ".escapeshellarg($v_domain), $output, $return_var);
         exec (HESTIA_CMD."v-add-mail-domain-antivirus ".$v_username." ".escapeshellarg($v_domain), $output, $return_var);
         check_return_code($return_var,$output);
         check_return_code($return_var,$output);
@@ -450,9 +456,23 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['acco
             }
             }
         }
         }
     }
     }
-
+    // Change forwarders to :blackhole: 
+    if (empty($_SESSION['error_msg']) && !empty($_POST['v_blackhole'])) {
+        foreach ($vfwd as $forward) {
+            if ((empty($_SESSION['error_msg'])) && (!empty($forward))) {
+                exec (HESTIA_CMD."v-delete-mail-account-forward ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($v_account)." ".escapeshellarg($forward), $output, $return_var);
+                check_return_code($return_var,$output);
+                unset($output);
+            }
+            exec (HESTIA_CMD."v-add-mail-account-forward ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($v_account)." :blackhole:", $output, $return_var);
+            check_return_code($return_var,$output);
+            unset($output);
+            $v_fwd  = '';
+            $v_blackhole = "yes";
+        }   
+    }
     // Change forwarders
     // Change forwarders
-    if (empty($_SESSION['error_msg'])) {
+    if (empty($_SESSION['error_msg']) && empty($_POST['v_blackhole'])) {
         $wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);
         $wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);
         $wfwd = preg_replace("/,/", " ", $wfwd);
         $wfwd = preg_replace("/,/", " ", $wfwd);
         $wfwd = preg_replace('/\s+/', ' ',$wfwd);
         $wfwd = preg_replace('/\s+/', ' ',$wfwd);
@@ -475,6 +495,7 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (!empty($_GET['acco
                 unset($output);
                 unset($output);
             }
             }
         }
         }
+        $v_blackhole = "no";
     }
     }
 
 
     // Delete FWD_ONLY flag
     // Delete FWD_ONLY flag

+ 10 - 0
web/js/pages/add_mail_acc.js

@@ -66,6 +66,16 @@ App.Helpers.isUnlimitedValue = function(value) {
 // Trigger listeners
 // Trigger listeners
 App.Listeners.MAIL_ACC.init();
 App.Listeners.MAIL_ACC.init();
 App.Listeners.MAIL_ACC.checkbox_unlimited_feature();
 App.Listeners.MAIL_ACC.checkbox_unlimited_feature();
+$('#v_blackhole').on('click', function(evt){
+    if($('#v_blackhole').is(':checked')){
+       $('#v_fwd').prop('disabled', true);
+       $('#v_fwd_for').prop('checked', true);
+       $('#id_fwd_for').hide();
+    }else{
+       $('#v_fwd').prop('disabled', false);
+       $('#id_fwd_for').show();        
+    }
+});
 $('form[name="v_quota"]').on('submit', function(evt) {
 $('form[name="v_quota"]').on('submit', function(evt) {
     $('input:disabled').each(function(i, elm) {
     $('input:disabled').each(function(i, elm) {
         $(elm).attr('disabled', false);
         $(elm).attr('disabled', false);

+ 11 - 0
web/js/pages/edit_mail_acc.js

@@ -79,6 +79,17 @@ App.Listeners.MAIL_ACC.keypress_v_password = function() {
     });
     });
 }
 }
 
 
+$('#v_blackhole').on('click', function(evt){
+       if($('#v_blackhole').is(':checked')){
+           $('#v_fwd').prop('disabled', true);
+           $('#v_fwd_for').prop('checked', true);
+           $('#id_fwd_for').hide();
+       }else{
+           $('#v_fwd').prop('disabled', false);
+           $('#id_fwd_for').show();       
+       }
+    });
+
 App.Listeners.MAIL_ACC.keypress_v_password();
 App.Listeners.MAIL_ACC.keypress_v_password();
 
 
 
 

+ 7 - 2
web/templates/admin/add_mail_acc.html

@@ -122,12 +122,17 @@
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
                                     <td>
                                     <td>
-                                        <textarea size="20" class="vst-textinput short" name="v_fwd"><?=htmlentities(trim($v_fwd, "'"))?></textarea>
+                                        <textarea size="20" class="vst-textinput short" name="v_fwd" id="v_fwd" <?php if($v_blackhole == 'yes') echo "disabled";?>><?=htmlentities(trim($v_fwd, "'"))?></textarea>
                                     </td>
                                     </td>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
                                     <td class="vst-text input-label">
                                     <td class="vst-text input-label">
-                                        <label><input type="checkbox" size="20" class="vst-checkbox" name="v_fwd_only" <?php if ($v_fwd_only == 'yes') echo "checked=yes" ?>> <?php print _('Do not store forwarded mail');?></label>
+                                        <label><input type="checkbox" size="20" class="vst-checkbox" id="v_blackhole" name="v_blackhole" <?php if ($v_blackhole == 'yes') echo "checked=yes" ?>> <?php print _('Discard all mail');?></label>
+                                    </td>
+                                </tr>
+                                <tr <?php if ($v_blackhole == 'yes') echo 'style="display:none"'; ?> id="id_fwd_for">
+                                    <td class="vst-text input-label">
+                                        <label><input type="checkbox" size="20" class="vst-checkbox" id="v_fwd_for" name="v_fwd_only" <?php if ($v_fwd_only == 'yes') echo "checked=yes" ?>> <?php print _('Do not store forwarded mail');?></label>
                                     </td>
                                     </td>
                                 </tr>
                                 </tr>
                             </table>
                             </table>

+ 7 - 2
web/templates/admin/edit_mail_acc.html

@@ -115,12 +115,17 @@
                         </tr>
                         </tr>
                         <tr>
                         <tr>
                             <td>
                             <td>
-                                <textarea size="20" class="vst-textinput short" name="v_fwd"><?=htmlentities(trim($v_fwd, "'"))?></textarea>
+                                <textarea size="20" class="vst-textinput short" name="v_fwd"  id="v_fwd" <?php if($v_blackhole == 'yes') echo "disabled";?>><?=htmlentities(trim($v_fwd, "'"))?></textarea>
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
+                            <td class="vst-text input-label">
+                                <label><input type="checkbox" size="20" class="vst-checkbox"  id="v_blackhole" name="v_blackhole" <?php if ($v_blackhole == 'yes') echo "checked=yes" ?>> <?php print _('Discard all mail');?></label>
+                            </td>
+                        </tr>
+                        <tr <?php if ($v_blackhole == 'yes') echo 'style="display:none"'; ?> id="id_fwd_for">
                             <td class="vst-text input-type input-label">
                             <td class="vst-text input-type input-label">
-                                <label><input type="checkbox" size="20" class="vst-checkbox" name="v_fwd_only" <?php if ($v_fwd_only == 'yes') echo "checked=yes" ?>> <?php print _('Do not store forwarded mail');?></label>
+                                <label><input type="checkbox" size="20" class="vst-checkbox" id="v_fwd_for" name="v_fwd_only" <?php if ($v_fwd_only == 'yes') echo "checked=yes" ?>> <?php print _('Do not store forwarded mail');?></label>
                             </td>
                             </td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels