Allow character set for autoreply message to be chosen.

https://www.virtualmin.com/node/16309
This commit is contained in:
Jamie Cameron
2010-11-17 13:58:18 -08:00
parent c931350930
commit 5dba7b2b39
7 changed files with 40 additions and 1 deletions

View File

@@ -32,6 +32,9 @@ while(<FILE>) {
elsif (/^From:\s*(.*)/) {
$simple->{'from'} = $1;
}
elsif (/^Charset:\s*(\S+)/) {
$simple->{'charset'} = $1;
}
else {
push(@lines, $_);
}
@@ -75,6 +78,9 @@ if ($simple->{'autoreply_end'}) {
if ($simple->{'from'}) {
&print_tempfile(AUTO, "From: $simple->{'from'}\n");
}
if ($simple->{'charset'}) {
&print_tempfile(AUTO, "Charset: $simple->{'charset'}\n");
}
&print_tempfile(AUTO, $simple->{'autotext'});
&close_tempfile(AUTO);
}

View File

@@ -216,6 +216,9 @@ print &ui_table_row(
"<td>".&ui_date_input($etm[3], $etm[4], $etm[5],
"dend", "mend", "yend")." ".
&date_chooser_button("dend", "mend", "yend")."</td> </tr>\n".
"<tr> <td><b>$text{'index_charset'}</b></td> ".
"<td>".&ui_opt_textbox("charset", $r->{'charset'}, 20,
$text{'default'}." (iso-8859-1)")."</td> </tr>\n".
"</table>",
undef, \@tds);

View File

@@ -28,6 +28,11 @@ print &ui_table_row($text{'auto_reply'},
&ui_textarea("reply", $filter->{'reply'}->{'autotext'}, 5, 80,
undef, $dis));
# Character set
print &ui_table_row($text{'auto_charset'},
&ui_opt_textbox("charset", $filter->{'reply'}->{'charset'}, 20,
$text{'default'}." (iso-8859-1)"));
# Period
if (!$config{'reply_force'}) {
$r = $filter->{'reply'};

View File

@@ -39,6 +39,7 @@ index_noperiod=No minimum
index_mins=minutes
index_astart=Don't send autoreply before
index_aend=Don't send autoreply after
index_charset=Autoreply message character set
index_nowebmin=This module is only for use in Usermin. If it is visible in Webmin, the theme you are using is incomplete.
edit_title1=Create Filter
@@ -81,6 +82,7 @@ save_enewfolder2=Invalid new folder name
save_enewfolder3=A folder with the same name already exists
save_estart=Invalid autoreply start date
save_eend=Invalid autoreply end date
save_echarset=Missing or invalid autoreply character set
delete_err=Failed to delete filters
delete_enone=None selected
@@ -100,6 +102,7 @@ auto_title=Email Automatic Reply
auto_header=Automatic email reply options
auto_enabled=Automatic response enabled?
auto_reply=Reply message
auto_charset=Message character set
auto_period=Minimum interval between replies
auto_err=Failed to save automatic reply

View File

@@ -178,6 +178,15 @@ else {
delete($filter->{'reply'}->{'autoreply_'.$p});
}
}
# Save character set
if ($in{'charset_def'}) {
delete($filter->{'reply'}->{'charset'});
}
else {
$in{'charset'} =~ /^[a-z0-9\.\-\_]+$/i ||
error($text{'save_echarset'});
$filter->{'reply'}->{'charset'} = $in{'charset'};
}
}
elsif ($in{'amode'} == 7) {
# Create a new folder for saving (always in Maildir format)

View File

@@ -62,6 +62,16 @@ elsif ($in{'enabled'}) {
"$user_module_config_directory/replies";
}
# Save character set
if ($in{'charset_def'}) {
delete($filter->{'reply'}->{'charset'});
}
else {
$in{'charset'} =~ /^[a-z0-9\.\-\_]+$/i ||
error($text{'save_echarset'});
$filter->{'reply'}->{'charset'} = $in{'charset'};
}
if ($old) {
&modify_filter($filter);
}

View File

@@ -232,15 +232,18 @@ foreach $f (@files) {
# Work out the content type and encoding
$type = $rbody =~ /<html[^>]*>|<body[^>]*>/i ? "text/html" : "text/plain";
$cs = $rheader{'Charset'};
delete($rheader{'Charset'});
if ($rbody =~ /[\177-\377]/) {
# High-ascii
$enc = "quoted-printable";
$encrbody = &quoted_encode($rbody);
$type .= "; charset=iso-8859-1";
$type .= "; charset=".($cs || "iso-8859-1");
}
else {
$enc = undef;
$encrbody = $rbody;
$type .= "; charset=$cs" if ($cs);
}
# run sendmail and feed it the reply