Add UI field to use the global notify address, and respect it

This commit is contained in:
Jamie Cameron
2024-10-14 20:32:07 -07:00
parent 7476d48ab7
commit 086f366954
4 changed files with 18 additions and 5 deletions

View File

@@ -7254,8 +7254,10 @@ foreach my $k (keys %{$params_hash}) {
# Construct description if one is needed
my $lm = $m || "global";
my $lu = $base_remote_user || $remote_user;
my $logemailto = $gconfig{'logemail'} eq "*" ? $gconfig{'webmin_email_to'}
: $gconfig{'logemail'};
my $logemail =
$gconfig{'logemail'} &&
$logemailto &&
(!$gconfig{'logmodulesemail'} ||
&indexof($lm, split(/\s+/, $gconfig{'logmodulesemail'})) >= 0) &&
(!$gconfig{'logusersemail'} ||
@@ -7320,7 +7322,7 @@ if ($logemail) {
}
&mailboxes::send_text_mail(
&mailboxes::get_from_address(),
$gconfig{'logemail'},
$logemailto,
undef,
$subj,
$body);

View File

@@ -133,8 +133,18 @@ if ($access{'notify'}) {
&ui_yesno_radio("notify", $gconfig{'logemail'} ? 1 : 0));
# Send notification to
print &ui_table_row($text{'index_notify_email'},
&ui_textbox("email", $gconfig{'logemail'}, 60));
$email = $gconfig{'logemail'};
if ($gconfig{'webmin_email_to'}) {
print &ui_table_row($text{'index_notify_email'},
&ui_opt_textbox(
"email", $email eq "*" ? "" : $email, 60,
$text{'index_notify_email_def'}.
" <tt>$gconfig{'webmin_email_to'}</tt>"));
}
else {
print &ui_table_row($text{'index_notify_email'},
&ui_textbox("email", $email, 60));
}
# Message subject options
print &ui_table_row($text{'index_notify_usub'},

View File

@@ -37,6 +37,7 @@ index_notify=Send email for Webmin actions?
index_notify_mods=For actions in modules
index_notify_users=For actions by users
index_notify_email=Send email to
index_notify_email_def=Default notification address
index_notify_usub=Include username in email subject?
index_notify_msub=Include action in email subject?
index_searchtab=Search logs

View File

@@ -13,7 +13,7 @@ $access{'notify'} || &error($text{'notify_ecannot'});
if ($in{'notify'}) {
$in{'email'} =~ /\S/ || &error($text{'notify_eemail'});
$gconfig{'logemail'} = $in{'email'};
$gconfig{'logemail'} = $in{'email_def'} ? "*" : $in{'email'};
}
else {
delete($gconfig{'logemail'});