Skip to content

Commit 2be1a52

Browse files
authored
[Fix] Fixes multiple small bugs in email stack (hestiacp#1501)
* Allow use of :blackhole: [hestiacp#1460] Removed requirement password for :forward_only: [hestiacp#1001] Fixed bug that password requirement didn’t need to be met with new email account [hestiacp#1450] * Added an option forward to blackhole via checkbox * Update text Todo update Getext * Hide fwd_for field when blackhole is selected
1 parent 1c03e24 commit 2be1a52

File tree

11 files changed

+119
-44
lines changed

11 files changed

+119
-44
lines changed

bin/v-add-mail-account-forward

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ format_domain_idn
3434
#----------------------------------------------------------#
3535

3636
check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
37-
is_format_valid 'user' 'domain' 'account' 'email_forward'
37+
is_format_valid 'user' 'domain' 'account'
38+
if [ "$email_forward" != ':blackhole:' ]; then
39+
is_format_valid 'email_forward'
40+
fi
3841
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
3942
is_object_valid 'user' 'USER' "$user"
4043
is_object_unsuspended 'user' 'USER' "$user"

bin/v-delete-mail-account-forward

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ format_domain_idn
3434
#----------------------------------------------------------#
3535

3636
check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
37-
is_format_valid 'user' 'domain' 'account' 'forward'
37+
if [ "$forward" != ':blackhole:' ]; then
38+
is_format_valid 'forward'
39+
fi
3840
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
3941
is_object_valid 'user' 'USER' "$user"
4042
is_object_unsuspended 'user' 'USER' "$user"

install/deb/themes/dark.css

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,29 @@ label {
621621
label:hover {
622622
color: #d4d4d4 !important;
623623
}
624+
.vst-textinput {
625+
background-color: #454545;
626+
border: 1px solid #606060;
627+
color: #d4d4d4;
628+
box-shadow: 0px 1px 4px rgba(0,0,0,0.35);
629+
}
630+
.vst-textinput:hover {
631+
border: 1px solid #0090ff;
632+
background-color: #494949;
633+
}
634+
.vst-textinput:focus {
635+
background-color: #222222;
636+
border-color: #0080df;
637+
color: #fff !important;
638+
box-shadow: 0px 1px 6px rgba(0,52,91,0.75);
639+
}
640+
.vst-textinput.console{
641+
642+
}
643+
.vst-textinput.short {
644+
645+
}
646+
624647
.vst-input {
625648
background-color: #454545;
626649
border: 1px solid #606060;
@@ -640,7 +663,9 @@ label:hover {
640663
}
641664

642665
.vst-input:disabled,
643-
.vst-list:disabled {
666+
.vst-list:disabled,
667+
.vst-textinput:disabled
668+
{
644669
background-color: #303030;
645670
text-shadow: 1px 1px rgba(0,0,0,0.3);
646671
color: #acacac;
@@ -651,7 +676,8 @@ label:hover {
651676
}
652677

653678
.vst-input:disabled:hover,
654-
.vst-list:disabled:hover {
679+
.vst-list:disabled:hover,
680+
.vst-textinput:disabled:hover {
655681
border-color: #606060 !important;
656682
}
657683

@@ -740,32 +766,6 @@ a.vst-text:active b{
740766

741767
.advanced-options .fas {
742768

743-
}
744-
745-
.vst-textinput {
746-
background-color: #454545;
747-
border: 1px solid #606060;
748-
color: #d4d4d4;
749-
box-shadow: 0px 1px 4px rgba(0,0,0,0.35);
750-
}
751-
.vst-textinput:hover {
752-
border: 1px solid #0090ff;
753-
background-color: #494949;
754-
}
755-
.vst-textinput:focus {
756-
background-color: #222222;
757-
border-color: #0080df;
758-
color: #fff !important;
759-
box-shadow: 0px 1px 6px rgba(0,52,91,0.75);
760-
}
761-
.vst-textinput:disabled {
762-
background-color: #454545;
763-
}
764-
.vst-textinput.console{
765-
766-
}
767-
.vst-textinput.short {
768-
769769
}
770770
#advanced-options .console{
771771

web/add/mail/index.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,18 @@
9898
}
9999

100100

101-
101+
// Check antispam option
102+
if (!empty($_POST['v_blackhole'])) {
103+
$v_blackhole = 'yes';
104+
} else {
105+
$v_blackhole = 'no';
106+
}
102107
// Check empty fields
103108
if (empty($_POST['v_domain'])) $errors[] = _('domain');
104109
if (empty($_POST['v_account'])) $errors[] = _('account');
105-
if (empty($_POST['v_password'])) $errors[] = _('password');
110+
if ((empty($_POST['v_fwd_only']) && empty($_POST['v_password']))) {
111+
if (empty($_POST['v_password'])) $errors[] = _('password');
112+
}
106113
if (!empty($errors[0])) {
107114
foreach ($errors as $i => $error) {
108115
if ( $i == 0 ) {
@@ -122,7 +129,7 @@
122129
}
123130

124131
// Check password length
125-
if (empty($_SESSION['error_msg']) && !empty($_POST['v_fwd_only']) ) {
132+
if (empty($_SESSION['error_msg']) && (empty($_POST['v_fwd_only']))) {
126133
if (!validate_password($_POST['v_password'])) { $_SESSION['error_msg'] = _('Password does not match the minimum requirements');}
127134
}
128135

@@ -168,6 +175,13 @@
168175
}
169176
}
170177

178+
if ((!empty($_POST['v_blackhole'])) && (empty($_SESSION['error_msg']))){
179+
exec (HESTIA_CMD."v-add-mail-account-forward ".$user." ".$v_domain." ".$v_account." :blackhole:", $output, $return_var);
180+
check_return_code($return_var,$output);
181+
unset($output);
182+
//disable any input in v_fwd
183+
$_POST['v_fwd'] = '';
184+
}
171185
// Add Forwarders
172186
if ((!empty($_POST['v_fwd'])) && (empty($_SESSION['error_msg']))) {
173187
$vfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);

web/css/src/styles.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,19 +2553,23 @@ label:hover {
25532553
}
25542554

25552555
.vst-input:disabled,
2556-
.vst-list:disabled {
2556+
.vst-list:disabled,
2557+
.vst-textinput:disabled
2558+
{
25572559
background-color: #e7e7e7;
25582560
text-shadow: 1px 1px rgba(255,255,255,1);
25592561
color: #686868;
25602562
}
25612563

2562-
.vst-input:focus:disabled {
2564+
.vst-input:focus:disabled,
2565+
.vst-textinput:disabled {
25632566
border-color: #f1f1f1;
25642567
background-color: #f1f1f1;
25652568
}
25662569

25672570
.vst-input:disabled:hover,
2568-
.vst-list:disabled:hover {
2571+
.vst-list:disabled:hover
2572+
.vst-textinput:disabled:hover {
25692573
border-color: #cfcfcf;
25702574
}
25712575

web/css/styles.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/edit/mail/index.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@
9393
$v_aliases = str_replace(',', "\n", $data[$v_account]['ALIAS']);
9494
$valiases = explode(",", $data[$v_account]['ALIAS']);
9595
$v_fwd = str_replace(',', "\n", $data[$v_account]['FWD']);
96+
if ($v_fwd == ":blackhole:") {
97+
$v_fwd = '';
98+
$v_blackhole = "yes";
99+
}else{
100+
$v_blackhole = "no";
101+
}
96102
$vfwd = explode(",", $data[$v_account]['FWD']);
97103
$v_fwd_only = $data[$v_account]['FWD_ONLY'];
98104
$v_quota = $data[$v_account]['QUOTA'];
@@ -155,7 +161,7 @@
155161
unset($output);
156162
}
157163

158-
// Add antivirs
164+
// Add antivirus
159165
if (($v_antivirus == 'no') && (!empty($_POST['v_antivirus'])) && (empty($_SESSION['error_msg']))) {
160166
exec (HESTIA_CMD."v-add-mail-domain-antivirus ".$v_username." ".escapeshellarg($v_domain), $output, $return_var);
161167
check_return_code($return_var,$output);
@@ -450,9 +456,23 @@
450456
}
451457
}
452458
}
453-
459+
// Change forwarders to :blackhole:
460+
if (empty($_SESSION['error_msg']) && !empty($_POST['v_blackhole'])) {
461+
foreach ($vfwd as $forward) {
462+
if ((empty($_SESSION['error_msg'])) && (!empty($forward))) {
463+
exec (HESTIA_CMD."v-delete-mail-account-forward ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($v_account)." ".escapeshellarg($forward), $output, $return_var);
464+
check_return_code($return_var,$output);
465+
unset($output);
466+
}
467+
exec (HESTIA_CMD."v-add-mail-account-forward ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($v_account)." :blackhole:", $output, $return_var);
468+
check_return_code($return_var,$output);
469+
unset($output);
470+
$v_fwd = '';
471+
$v_blackhole = "yes";
472+
}
473+
}
454474
// Change forwarders
455-
if (empty($_SESSION['error_msg'])) {
475+
if (empty($_SESSION['error_msg']) && empty($_POST['v_blackhole'])) {
456476
$wfwd = preg_replace("/\n/", " ", $_POST['v_fwd']);
457477
$wfwd = preg_replace("/,/", " ", $wfwd);
458478
$wfwd = preg_replace('/\s+/', ' ',$wfwd);
@@ -475,6 +495,7 @@
475495
unset($output);
476496
}
477497
}
498+
$v_blackhole = "no";
478499
}
479500

480501
// Delete FWD_ONLY flag

web/js/pages/add_mail_acc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ App.Helpers.isUnlimitedValue = function(value) {
6666
// Trigger listeners
6767
App.Listeners.MAIL_ACC.init();
6868
App.Listeners.MAIL_ACC.checkbox_unlimited_feature();
69+
$('#v_blackhole').on('click', function(evt){
70+
if($('#v_blackhole').is(':checked')){
71+
$('#v_fwd').prop('disabled', true);
72+
$('#v_fwd_for').prop('checked', true);
73+
$('#id_fwd_for').hide();
74+
}else{
75+
$('#v_fwd').prop('disabled', false);
76+
$('#id_fwd_for').show();
77+
}
78+
});
6979
$('form[name="v_quota"]').on('submit', function(evt) {
7080
$('input:disabled').each(function(i, elm) {
7181
$(elm).attr('disabled', false);

web/js/pages/edit_mail_acc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ App.Listeners.MAIL_ACC.keypress_v_password = function() {
7979
});
8080
}
8181

82+
$('#v_blackhole').on('click', function(evt){
83+
if($('#v_blackhole').is(':checked')){
84+
$('#v_fwd').prop('disabled', true);
85+
$('#v_fwd_for').prop('checked', true);
86+
$('#id_fwd_for').hide();
87+
}else{
88+
$('#v_fwd').prop('disabled', false);
89+
$('#id_fwd_for').show();
90+
}
91+
});
92+
8293
App.Listeners.MAIL_ACC.keypress_v_password();
8394

8495

web/templates/admin/add_mail_acc.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,17 @@
122122
</tr>
123123
<tr>
124124
<td>
125-
<textarea size="20" class="vst-textinput short" name="v_fwd"><?=htmlentities(trim($v_fwd, "'"))?></textarea>
125+
<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>
126126
</td>
127127
</tr>
128128
<tr>
129129
<td class="vst-text input-label">
130-
<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>
130+
<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>
131+
</td>
132+
</tr>
133+
<tr <?php if ($v_blackhole == 'yes') echo 'style="display:none"'; ?> id="id_fwd_for">
134+
<td class="vst-text input-label">
135+
<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>
131136
</td>
132137
</tr>
133138
</table>

0 commit comments

Comments
 (0)