* Sat Oct 11 2025 Brian Read <brianr@koozali.org> 11.0.0-5.sme
- Add Dovecot Sieve generation and application [SME: 13232]
This commit is contained in:
@@ -35,6 +35,29 @@ my $pdb;
|
||||
#my $hdb
|
||||
#my $ddb
|
||||
|
||||
# Extra routine
|
||||
sub do_extras {
|
||||
#my $fred = 1/0;
|
||||
my $c = shift;
|
||||
if (defined $c->param("ApplyRules")){
|
||||
$user = $c->get_panel_user();
|
||||
$res = qx(sieve-filter -W -u $user -e ~$user/.sievefilter INBOX expunge 2>&1 | tee /var/log/sieve-filter.log | grep -v "warning" | grep -v "left message in mailbox 'INBOX'" | wc -l);
|
||||
$ms_data{command_result} = ($res == 0) ? 'none' : $res;
|
||||
$c->do_display('TABLE');
|
||||
} elsif (defined $c->param("ReSerialise")) {
|
||||
|
||||
} elsif (defined $c->param("GenerateRule")) {
|
||||
$res = qx(signal-event mailsorting-conf)
|
||||
}
|
||||
|
||||
#my $referer = $c->req->headers->referrer;
|
||||
#if ($referer) {
|
||||
## Redirect back to the referring URL
|
||||
#$c->redirect_to($referer);
|
||||
#} else {
|
||||
# }
|
||||
}
|
||||
|
||||
# Validation routines - parameters for each panel
|
||||
|
||||
sub validate_TABLE {
|
||||
@@ -106,18 +129,61 @@ my $pdb;
|
||||
sub get_data_for_panel_TABLE {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
$cdb = esmith::ConfigDB::UTF8->open();
|
||||
$adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
|
||||
my $PanelUser = $c->get_panel_user();
|
||||
# Count number of emails in top level INBOX
|
||||
my $inbox_dir;
|
||||
if ($PanelUser eq 'admin'){
|
||||
$inbox_dir = "/home/e-smith/Maildir/cur/";
|
||||
} else {
|
||||
$inbox_dir = "/home/e-smith/files/users/$PanelUser/Maildir/cur/";
|
||||
}
|
||||
opendir(my $dh, $inbox_dir) or die "Cannot open directory: $!";
|
||||
my @files = grep { -f "$inbox_dir/$_" && !/^\.{1,2}$/ } readdir($dh);
|
||||
closedir($dh);
|
||||
my $file_count = scalar @files;
|
||||
# Get a list of the users.
|
||||
my @users = $adb->get('admin');
|
||||
push @users, $adb->users();
|
||||
my @actualusers;
|
||||
|
||||
foreach my $user (@users) {
|
||||
push @actualusers, [ $user->key()." - ".$user->prop('FirstName') . " " . $user->prop('LastName'),$user->key()];
|
||||
}
|
||||
|
||||
my $actualusers_ref = \@actualusers; # array reference of key => firstname.lastname hashrefs
|
||||
|
||||
my %ret = (
|
||||
'Data1'=>'Data for TABLE', #Example
|
||||
# fields from Inputs in TABLE $fields['TABLE']
|
||||
'account'=>$c->get_panel_user(),
|
||||
'account'=> $PanelUser,
|
||||
'username'=> $c->get_full_name(),
|
||||
|
||||
'FilterType' => $c->get_filtertype($PanelUser),
|
||||
'Geekmode' => $adb->get_prop($PanelUser, "Geekmode") || FALSE,
|
||||
'EmailCount' => $file_count,
|
||||
'users' => $actualusers_ref
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
|
||||
sub get_filtertype{
|
||||
my $c = shift;
|
||||
my $PanelUser = shift;
|
||||
$cdb = esmith::ConfigDB::UTF8->open();
|
||||
$adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
|
||||
#Either the filtertype is set per user or it is global
|
||||
my $globalFilterType = $cdb->get_prop('qmail', "FilterType");
|
||||
if (! $globalFilterType) {
|
||||
return $adb->get_prop($PanelUser,'FilterType') || ''
|
||||
} else {
|
||||
return $globalFilterType;
|
||||
}
|
||||
}
|
||||
|
||||
sub get_data_for_panel_RULES {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $cdb = esmith::ConfigDB::UTF8->open();
|
||||
my $c = shift;
|
||||
my $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
|
||||
my $PanelUser = $c->get_panel_user();
|
||||
@@ -142,10 +208,18 @@ sub get_data_for_panel_RULES {
|
||||
my $rule_info = get_rule_from_db($c, $rule);
|
||||
# and add heading message
|
||||
$rule_info->{topmessage} = $c->l('ms_You_can_change_the_order');
|
||||
|
||||
my $FilterType = $c->get_filtertype($PanelUser);
|
||||
my $FilterRule = 'No filter configured';
|
||||
my $DBRemoveRule = "Db entries:".$c->esmith_db_record_to_multiline($pdb,$key,$PanelUser);
|
||||
$FilterRule = "\nProcmail Rule:\n--------------\n".$c->get_procmail_rule($pdb,$key,$PanelUser) if $FilterType eq 'procmail';
|
||||
$FilterRule = "\nMaildrop Rule:\n--------------\n".$c->get_maildrop_rule($pdb,$key,$PanelUser) if $FilterType eq 'maildrop';
|
||||
$FilterRule = "\nDovecot-Sieve Rule:\n----------------------\n".$c->get_sieve_rule($pdb,$key,$PanelUser) if $FilterType eq 'sieve';
|
||||
|
||||
# Add/override any fields specific to the panel as needed
|
||||
my %ret = (
|
||||
%$rule_info,
|
||||
'FilterRule'=> $FilterRule
|
||||
);
|
||||
|
||||
return %ret;
|
||||
@@ -154,12 +228,21 @@ sub get_data_for_panel_RULES {
|
||||
sub get_data_for_panel_REMOVE {
|
||||
# Return a hash with the fields required which will be loaded into the shared data
|
||||
my $c = shift;
|
||||
my $cdb = esmith::ConfigDB::UTF8->open();
|
||||
my $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
|
||||
my $PanelUser = $c->get_panel_user();
|
||||
my $key = $c->param('Selected');
|
||||
my $FilterType = $c->get_filtertype($PanelUser);
|
||||
my $FilterRule = 'No filter configured';
|
||||
my $DBRemoveRule = "Db entries:".$c->esmith_db_record_to_multiline($pdb,$key);
|
||||
$FilterRule = "\nProcmail Rule:\n--------------\n".$c->get_procmail_rule($pdb,$key,$PanelUser) if $FilterType eq 'procmail';
|
||||
$FilterRule = "\nMaildrop Rule:\n--------------\n".$c->get_maildrop_rule($pdb,$key,$PanelUser) if $FilterType eq 'maildrop';
|
||||
$FilterRule = "\nDovecot-Sieve Rule:\n----------------------\n".$c->get_sieve_rule($pdb,$key,$PanelUser) if $FilterType eq 'sieve';
|
||||
|
||||
my %ret = (
|
||||
# fields from Inputs in REMOVE $fields['REMOVE']
|
||||
'RemoveRule'=>"Db entries:\n------------\n".$c->esmith_db_record_to_multiline($pdb,$key)."\n\nProcmail Rule:\n--------------".$c->get_procmail_rule($pdb,$key),
|
||||
'RemoveRule'=> $DBRemoveRule,
|
||||
'FilterRule' => $FilterRule
|
||||
);
|
||||
return %ret;
|
||||
}
|
||||
@@ -338,6 +421,7 @@ sub get_getAllRules {
|
||||
my $PanelUser = $c->get_panel_user();
|
||||
my $rec = $pdb->get($rule); # || return "Rule:$rule not found";
|
||||
$rec->delete;
|
||||
$c->app->log->info("Running: "."/sbin/e-smith/signal-event mailsorting-conf $PanelUser");
|
||||
unless ( system ("/sbin/e-smith/signal-event mailsorting-conf $PanelUser") == 0 )
|
||||
{ return $self->error('ERROR_UPDATING'); }
|
||||
return 'ok';
|
||||
@@ -355,7 +439,21 @@ sub create_link{
|
||||
sub get_panel_user
|
||||
{
|
||||
my $c = shift;
|
||||
return $c->session->{username};
|
||||
my $adb = esmith::AccountsDB::UTF8->open();
|
||||
if (!$c->is_admin){
|
||||
return $c->session->{username};
|
||||
} else {
|
||||
if (my $thisUser = $c->param('account')) {
|
||||
#Check it is a valid user
|
||||
if ($adb->get_prop($thisUser, "FirstName")){
|
||||
return $thisUser
|
||||
} else {
|
||||
return $c->session->{username}
|
||||
}
|
||||
} else {
|
||||
return $c->session->{username}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub get_full_name{
|
||||
@@ -520,6 +618,7 @@ sub save_rule
|
||||
foreach ("criterion","criterion2","action","action2","copy","basis","basis2","deliver","deliver2" )
|
||||
{ $pdb->set_prop($rule, "$_", $filtered{$_}); }
|
||||
|
||||
$c->app->log->info("Running: "."/sbin/e-smith/signal-event mailsorting-conf $PanelUser");
|
||||
unless ( system ("/sbin/e-smith/signal-event mailsorting-conf $PanelUser") == 0 )
|
||||
{ return 'ERROR_UPDATING'; }
|
||||
|
||||
@@ -538,7 +637,7 @@ sub esmith_db_record_to_multiline {
|
||||
next unless defined $value && $value ne '';
|
||||
push @lines, "$field: $value";
|
||||
}
|
||||
return join("\n", @lines);
|
||||
return "$key:"."\n------------\n".join("\n", @lines);
|
||||
}
|
||||
|
||||
sub get_esmith_db_record_hashref {
|
||||
@@ -549,54 +648,107 @@ sub get_esmith_db_record_hashref {
|
||||
return \%props; # return a hashref
|
||||
}
|
||||
|
||||
sub get_maildrop_rule {
|
||||
my $c = shift;
|
||||
my ($pdb, $key,$PanelUser) = @_;
|
||||
return $c->extract_rule_from_file("~$PanelUser/.mailfilter",$key)
|
||||
}
|
||||
|
||||
sub expand_tilde {
|
||||
my ($filename) = @_;
|
||||
# Special case for ~admin and ~admin/...
|
||||
$filename =~ s{\A~admin(?:/|\z)}{/home/e-smith/};
|
||||
# Generic ~ and ~user handling
|
||||
$filename =~ s{\A~([^/]*)}
|
||||
{ $1 ? (getpwnam($1))[7] : ($ENV{HOME} || (getpwuid($<))[7]) }ex;
|
||||
return $filename;
|
||||
}
|
||||
|
||||
sub extract_rule_from_file {
|
||||
my ($c,$filename, $rule_id) = @_;
|
||||
$c->app->log->info("get rule:$filename");
|
||||
|
||||
# Expand ~ to full home directory path if present
|
||||
$filename = expand_tilde($filename);
|
||||
$c->app->log->info("get rule:$filename");
|
||||
|
||||
# Read entire file content
|
||||
open my $fh, '<', $filename or die "Could not open file '$filename': $!";
|
||||
local $/; # Enable slurp mode to read whole file
|
||||
my $content = <$fh>;
|
||||
close $fh;
|
||||
|
||||
# Prepare start and end markers for the rule
|
||||
my $start_marker = "# User rule $rule_id";
|
||||
my $end_marker = "# End of User rule $rule_id";
|
||||
|
||||
# Extract the text block between the markers
|
||||
if ($content =~ /(\Q$start_marker\E.*?\Q$end_marker\E)/s) {
|
||||
return $1; # return matched block including markers
|
||||
} else {
|
||||
return "No matching rule found $filename $rule_id"
|
||||
}
|
||||
}
|
||||
|
||||
sub get_sieve_rule {
|
||||
my $c = shift;
|
||||
my ($pdb, $key,$PanelUser) = @_;
|
||||
return $c->extract_rule_from_file("~$PanelUser/.sievefilter",$key)
|
||||
}
|
||||
|
||||
sub get_procmail_rule {
|
||||
my $c = shift;
|
||||
# Logic taken from template expansion
|
||||
my ($pdb, $key) = @_;
|
||||
|
||||
my $basis = $pdb->get_prop($key, "basis") || '';
|
||||
my $criterion = $pdb->get_prop( $key, "criterion") || '';
|
||||
my $basis2 = $pdb->get_prop( $key, "basis2") || '';
|
||||
my $secondtest_orig = $pdb->get_prop( $key, "basis2") || '';
|
||||
my $criterion2 = $pdb->get_prop( $key, "criterion2") || '';
|
||||
my $deliver = $pdb->get_prop( $key, "deliver") || '';
|
||||
my $deliver2 = $pdb->get_prop( $key, "deliver2") || '';
|
||||
my $copy = $pdb->get_prop( $key, "copy") || '';
|
||||
my $action = $pdb->get_prop( $key, "action") || '';
|
||||
my $action2 = $pdb->get_prop( $key, "action2") || '';
|
||||
|
||||
# Process basis fields
|
||||
foreach my $b (\$basis, \$basis2) {
|
||||
$$b = $c->process_basis($$b);
|
||||
}
|
||||
|
||||
# Handle spaces in deliver addresses
|
||||
unless (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled')) {
|
||||
$_ =~ s/ /\\ /g for ($deliver, $deliver2);
|
||||
}
|
||||
|
||||
# Build delivery paths
|
||||
$deliver = $c->build_delivery_path($action, $deliver, $USERNAME);
|
||||
$deliver2 = $c->build_delivery_path($action2, $deliver2, $USERNAME) if $action2;
|
||||
|
||||
# Construct second test line
|
||||
my $secondtest = $secondtest_orig ? "* $basis2$criterion2\n" : '';
|
||||
|
||||
# Build rule string
|
||||
my $rule = "\n";
|
||||
if ($copy eq 'no') {
|
||||
$rule .= ":0\n* $basis$criterion\n$secondtest$deliver\n";
|
||||
}
|
||||
elsif ($copy eq 'yes' && $action2 eq 'inbox') {
|
||||
$rule .= ":0 c\n* $basis$criterion\n$secondtest$deliver\n";
|
||||
}
|
||||
else {
|
||||
$rule .= ":0\n* $basis$criterion\n$secondtest\{\n"
|
||||
. " :0 c\n $deliver\n\n :0\n $deliver2\n\}\n";
|
||||
}
|
||||
|
||||
return $rule;
|
||||
my ($pdb, $key,$PanelUser) = @_;
|
||||
return $c->extract_rule_from_file("~$PanelUser/.procmailrc",$key)
|
||||
}
|
||||
# No longer needed - rule extracted from .procmailrc file.
|
||||
#my $c = shift;
|
||||
## Logic taken from template expansion (dangerous!)
|
||||
#my ($pdb, $key) = @_;
|
||||
|
||||
#my $basis = $pdb->get_prop($key, "basis") || '';
|
||||
#my $criterion = $pdb->get_prop( $key, "criterion") || '';
|
||||
#my $basis2 = $pdb->get_prop( $key, "basis2") || '';
|
||||
#my $secondtest_orig = $pdb->get_prop( $key, "basis2") || '';
|
||||
#my $criterion2 = $pdb->get_prop( $key, "criterion2") || '';
|
||||
#my $deliver = $pdb->get_prop( $key, "deliver") || '';
|
||||
#my $deliver2 = $pdb->get_prop( $key, "deliver2") || '';
|
||||
#my $copy = $pdb->get_prop( $key, "copy") || '';
|
||||
#my $action = $pdb->get_prop( $key, "action") || '';
|
||||
#my $action2 = $pdb->get_prop( $key, "action2") || '';
|
||||
|
||||
## Process basis fields
|
||||
#foreach my $b (\$basis, \$basis2) {
|
||||
#$$b = $c->process_basis($$b);
|
||||
#}
|
||||
|
||||
## Handle spaces in deliver addresses
|
||||
#unless (($zarafa1 eq 'enabled') || ($zarafa2 eq 'enabled')) {
|
||||
#$_ =~ s/ /\\ /g for ($deliver, $deliver2);
|
||||
#}
|
||||
|
||||
## Build delivery paths
|
||||
#$deliver = $c->build_delivery_path($action, $deliver, $USERNAME);
|
||||
#$deliver2 = $c->build_delivery_path($action2, $deliver2, $USERNAME) if $action2;
|
||||
|
||||
## Construct second test line
|
||||
#my $secondtest = $secondtest_orig ? "* $basis2$criterion2\n" : '';
|
||||
|
||||
## Build rule string
|
||||
#my $rule = "\n";
|
||||
#if ($copy eq 'no') {
|
||||
#$rule .= ":0\n* $basis$criterion\n$secondtest$deliver\n";
|
||||
#}
|
||||
#elsif ($copy eq 'yes' && $action2 eq 'inbox') {
|
||||
#$rule .= ":0 c\n* $basis$criterion\n$secondtest$deliver\n";
|
||||
#}
|
||||
#else {
|
||||
#$rule .= ":0\n* $basis$criterion\n$secondtest\{\n"
|
||||
#. " :0 c\n $deliver\n\n :0\n $deliver2\n\}\n";
|
||||
#}
|
||||
|
||||
#return $rule;
|
||||
#}
|
||||
|
||||
sub process_basis {
|
||||
my ($c,$basis) = @_;
|
||||
|
||||
@@ -10,10 +10,11 @@ package SrvMngr::Controller::Mailsorting;
|
||||
# navigation : 6000 1200
|
||||
# menucat : U
|
||||
#
|
||||
# name : mailsorting, method : get, url : /mailsorting, ctlact : Mailsorting#main
|
||||
# name : mailsortingu, method : post, url : /mailsortingu, ctlact : Mailsorting#do_update
|
||||
# name : mailsortingd, method : get, url : /mailsortingd, ctlact : Mailsorting#do_display
|
||||
# name : mailsorting, method : get, url : /mailsorting, ctlact : Mailsorting#main
|
||||
# name : mailsortingu, method : post, url : /mailsortingu, ctlact : Mailsorting#do_update
|
||||
# name : mailsortingd, method : get, url : /mailsortingd, ctlact : Mailsorting#do_display
|
||||
# name : mailsortinge, method : post, url : /mailsortinge, ctlact : Mailsorting#do_update
|
||||
# name : mailsortingx, method : get, url : /mailsortingx, ctlact : Mailsorting#do_extras
|
||||
#
|
||||
# routes : end
|
||||
#
|
||||
@@ -52,7 +53,7 @@ my $ndb;
|
||||
my $hdb;
|
||||
my $ddb;
|
||||
|
||||
my %ms_data;
|
||||
our %ms_data;
|
||||
|
||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Mailsorting-Custom.pm'; #The code that is to be added by the developer
|
||||
|
||||
@@ -121,6 +122,12 @@ sub do_update {
|
||||
|
||||
my $c = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
$c->app->log->info("Updating:".$c->param('user'));
|
||||
|
||||
#$c->app->log->info($c->dumper($c->req->body_params->to_hash));
|
||||
#$c->app->log->info($c->dumper($c->req->query_params->to_hash));
|
||||
#$c->app->log->info($c->dumper($c->req->params->to_hash));
|
||||
|
||||
my $modul = '';
|
||||
|
||||
#The most common ones - you might want to comment out any not used.
|
||||
@@ -250,6 +257,11 @@ sub do_display {
|
||||
|
||||
my ($c,$trt) = @_;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
#$c->app->log->info($c->dumper($c->req->body_params->to_hash));
|
||||
#$c->app->log->info($c->dumper($c->req->query_params->to_hash));
|
||||
#$c->app->log->info($c->dumper($c->req->params->to_hash));
|
||||
|
||||
|
||||
#The most common ones - you might want to comment out any not used.
|
||||
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
'ms_deliver2' => 'deliver',
|
||||
'ms_basis2' => 'basis',
|
||||
'ms_Mail_sorting_rules' => 'Mail sorting rules',
|
||||
'ms_User_Name' => 'User Name',
|
||||
'ms_User_Name' => 'Full Name',
|
||||
'ms_folder' => 'Folder (if sorting)',
|
||||
'ms_action' => '2nd Action',
|
||||
'ms_copy' => 'Copy',
|
||||
@@ -51,4 +51,13 @@
|
||||
'ms_deliver2_email' => '2nd action Delivery email (if forwarding)',
|
||||
'ms_key' => 'Order of rule execution',
|
||||
'ms_new_record' => 'Select the part of the email to be tested. You can match against part of an email address, header, subject, or the email size. Size is in bytes. Delete, sort or Forward any matches. The second match is optional, but if used both rules must match',
|
||||
'ms_ERROR_FORWARD_NO_EMAIL' => 'No email address provided for forwarding',
|
||||
'ms_ERROR_FORWARD_NO_EMAIL' => 'No email address provided for forwarding',
|
||||
'ms_No_filtering' => 'No email filtering is configured',
|
||||
'ms_This_account_is_in_geek_mode' => 'This accounts email filtering is solely according to the contents of .procmailrc, .mailfilter or .sievefilter no automatic generation of those files will occur',
|
||||
'ms_Filtering_is_being_done_by' => 'Email filtering is using: ',
|
||||
'ms_Number_of_Emails' => 'Number of Emails in INBOX: ',
|
||||
'ms_Re_Serialise' => 'Re Serialise the Rules',
|
||||
'ms_Apply_Sieve' => 'Apply rules to INBOX',
|
||||
'ms_Result_of_command' => 'Number emails affected: ',
|
||||
'ms_Filter_contents' => 'Corresponding filter contents',
|
||||
'ms_Generate_Filter' => 'Generate filter rule'
|
||||
@@ -32,6 +32,16 @@ Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.
|
||||
.inline-buttons .link:active {
|
||||
background-color: #c0c0c0; /* Even darker shade on click */
|
||||
}
|
||||
|
||||
textarea {
|
||||
field-sizing: content;
|
||||
min-width: 400px;
|
||||
font-family: Verdana, Tahoma, sans-serif;
|
||||
font-size: 11.5px;
|
||||
font-weight: normal;
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.Mailsorting-panel {}
|
||||
|
||||
@@ -3,3 +3,45 @@
|
||||
//
|
||||
$(document).ready(function() {
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// When the select changes, copy selected text (full name) to username field
|
||||
//document.getElementById('account_select').addEventListener('change', function() {
|
||||
//var select = this;
|
||||
//var selectedOption = select.options[select.selectedIndex];
|
||||
//document.getElementById('username_text').value = selectedOption.text;
|
||||
//});
|
||||
|
||||
// On button click, reload page with ?user=<accountname>
|
||||
const applyBtn = document.getElementById('applyBtn');
|
||||
if (applyBtn) {
|
||||
applyBtn.addEventListener('click', function() {
|
||||
const select = document.getElementById('account_select');
|
||||
const account = select ? select.value : '';
|
||||
const url = new URL('smanager/mailsorting', window.location.origin);
|
||||
if (account) {
|
||||
url.searchParams.set('account', account);
|
||||
}
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
}
|
||||
|
||||
const backBtn = document.getElementById('backBtn');
|
||||
if (backBtn) {
|
||||
backBtn.addEventListener('click', function() {
|
||||
const url = new URL('smanager/mailsorting', window.location.origin);
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
}
|
||||
|
||||
const generateBtn = document.getElementById('generateBtn');
|
||||
if (generateBtn) {
|
||||
generateBtn.addEventListener('click', function() {
|
||||
const url = new URL('smanager/mailsortingx?GenerateRule', window.location.origin);
|
||||
//alert(url.toString());
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
@@ -42,7 +42,7 @@
|
||||
</div>
|
||||
<br />
|
||||
%}
|
||||
|
||||
|
||||
%#Routing to partials according to trt parameter.
|
||||
%#This ought to be cascading if/then/elsif, but is easier to just stack the if/then's rather like a case statement'
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
%#
|
||||
<div id="Mailsorting-REMOVE" class="partial Mailsorting-REMOVE">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
@@ -18,6 +14,7 @@
|
||||
%= hidden_field 'trt' => $ms_data->{trt}
|
||||
%# die("here");
|
||||
%= hidden_field 'Selected' => $c->param('Selected')
|
||||
%= hidden_field ''account'' => $c->param('account')
|
||||
|
||||
%# Inputs etc in here.
|
||||
|
||||
@@ -29,7 +26,14 @@
|
||||
%=l('ms_Rule_contents')
|
||||
</span><span class=data>
|
||||
% param 'RemoveRule' => $ms_data->{RemoveRule} unless param 'RemoveRule';
|
||||
%= text_area 'RemoveRule', cols=>60, rows=>20, Readonly=>'true'
|
||||
%= text_area 'RemoveRule', cols=>60, rows=>12, Readonly=>'true'
|
||||
</span><br>
|
||||
|
||||
<span class=label>
|
||||
%=l('ms_Filter_contents')
|
||||
</span><span class=data>
|
||||
% param 'FilterRule' => $ms_data->{FilterRule} unless param 'FilterRule';
|
||||
%= text_area 'FilterRule', cols=>60, rows=>12, Readonly=>'true'
|
||||
</span><br>
|
||||
|
||||
<span class='data'>
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
%#
|
||||
<div id="Mailsorting-RULES" class="partial Mailsorting-RULES">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $ms_data
|
||||
@@ -17,6 +12,8 @@
|
||||
% param 'trt' => $ms_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $ms_data->{trt}
|
||||
%= hidden_field 'oldkey' => $ms_data->{oldkey}
|
||||
%= hidden_field 'account' => $c->param('account')
|
||||
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1 class='head'><%=l('ms_Mail_sorting_rules')%></h1>
|
||||
@@ -113,10 +110,29 @@
|
||||
% param 'key' => $ms_data->{key} unless param 'key';
|
||||
%= text_field 'key', size => '50', class => 'textinput key' , pattern=>'.*' , placeholder=>'key', title =>'Pattern regex mismatch', id => 'key_text'
|
||||
<br></span></p>
|
||||
|
||||
|
||||
<br /><br />
|
||||
|
||||
<!--
|
||||
<p><span class=label>
|
||||
%=l('')
|
||||
</span><span class=data>
|
||||
<button type="button" id="generateBtn"><%=l('ms_Generate_Filter')%></button>
|
||||
<br></span></p>
|
||||
-->
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_Filter_contents')
|
||||
</span><span class=data>
|
||||
% param 'FilterRule' => $ms_data->{FilterRule} unless param 'FilterRule';
|
||||
%= text_area 'FilterRule', cols=>60, rows=>12, Readonly=>'true'
|
||||
</span></p>
|
||||
|
||||
<span class='data'>
|
||||
%= submit_button l('ms_Save'), class => 'action subm12'
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-05-04 12:59:05
|
||||
%#
|
||||
<div id="Mailsorting-TABLE" class="partial Mailsorting-TABLE">
|
||||
<script>
|
||||
window.onload = function() {
|
||||
SelectInput();
|
||||
};
|
||||
</script>
|
||||
% if (config->{debug} == 1) {
|
||||
<pre>
|
||||
%= dumper $ms_data
|
||||
@@ -20,6 +15,7 @@
|
||||
%= form_for "mailsortingu" => (method => 'POST') => begin
|
||||
% param 'trt' => $ms_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $ms_data->{trt}
|
||||
%= hidden_field 'account' => $c->{account}
|
||||
%# Inputs etc in here.
|
||||
|
||||
<h1 class='head'><%=l('ms_Mail_sorting_rules')%></h1>
|
||||
@@ -27,28 +23,85 @@
|
||||
<p class='paragraph para1'>
|
||||
%=l('ms_Rules_are_executed_as_email')
|
||||
</p>
|
||||
|
||||
% if (! $c->is_admin){
|
||||
% # Single user mode
|
||||
<p><span class=label>
|
||||
%=l('ms_Account')
|
||||
</span><span class=data>
|
||||
% param 'account' => $ms_data->{account} unless param 'account';
|
||||
%= text_field 'account', size => '50', class => 'textinput account' , readonly => 'readonly', pattern=>'.*' , placeholder=>'account', title =>'Pattern regex mismatch', id => 'account_text'
|
||||
<br></span></p>
|
||||
|
||||
<p>
|
||||
<span class="label">
|
||||
%= l('ms_User_Name')
|
||||
</span>
|
||||
<span class="data">
|
||||
% param 'username' => $ms_data->{username} unless param 'username';
|
||||
%= text_field 'username', size => '50', class => 'textinput username', readonly => 'readonly', pattern=>'.*', placeholder=>'username', title =>'Pattern regex mismatch', id => 'username_text'
|
||||
<br>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
% } else {
|
||||
% # Called by Admin
|
||||
<p>
|
||||
<span class="label">
|
||||
%= l('ms_Account')
|
||||
</span>
|
||||
<span class="data">
|
||||
% param 'account' => $ms_data->{account} unless param 'account';
|
||||
%= select_field 'account' => $ms_data->{users}, class => 'input', id => 'account_select'
|
||||
<button type="button" id="applyBtn">Switch User</button>
|
||||
<button type="button" id="backBtn">Back to admin</button>
|
||||
<br>
|
||||
</span>
|
||||
</p>
|
||||
% }
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_Account')
|
||||
</span><span class=data>
|
||||
% param 'account' => $ms_data->{account} unless param 'account';
|
||||
%= text_field 'account', size => '50', class => 'textinput account' , pattern=>'.*' , placeholder=>'account', title =>'Pattern regex mismatch', id => 'account_text'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('ms_User_Name')
|
||||
</span><span class=data>
|
||||
% param 'username' => $ms_data->{username} unless param 'username';
|
||||
%= text_field 'username', size => '50', class => 'textinput username' , pattern=>'.*' , placeholder=>'username', title =>'Pattern regex mismatch', id => 'username_text'
|
||||
<br></span></p>
|
||||
|
||||
|
||||
% if ($ms_data->{Geekmode}){
|
||||
<p class='paragraph para1'>
|
||||
%= l('ms_This_account_is_in_geek_mode')
|
||||
</p>
|
||||
%}
|
||||
|
||||
% my $filterstr = $ms_data->{FilterType} eq 'procmail' ? 'Procmail' :
|
||||
% $ms_data->{FilterType} eq 'maildrop' ? 'Maildrop' :
|
||||
% $ms_data->{FilterType} eq 'sieve' ? 'Dovecot Sieve' :
|
||||
% l('ms_No_filtering');
|
||||
|
||||
<p class='paragraph para1'>
|
||||
%== $c->l('ms_Filtering_is_being_done_by')."<b>".$filterstr."</b>";
|
||||
</p>
|
||||
<p class='paragraph para1'>
|
||||
%== $c->l('ms_Number_of_Emails')."<b>".$ms_data->{EmailCount}."</b>";
|
||||
</p>
|
||||
|
||||
% if (defined $ms_data->{command_result}) {
|
||||
<p class='paragraph para1'>
|
||||
<%= $c->l('ms_Result_of_command') %><b><%= $ms_data->{command_result} %></b>
|
||||
</p>
|
||||
% }
|
||||
|
||||
<br />
|
||||
|
||||
<div class = 'inline-buttons'>
|
||||
<a href='mailsortingd?trt=RULES' class='link link1'>
|
||||
%= l('ms_Add_new_rule')
|
||||
</a>
|
||||
% if ($filterstr eq "Dovecot Sieve"){
|
||||
<a href='mailsortingx?ApplyRules' class='link link1'>
|
||||
%= l('ms_Apply_Sieve');
|
||||
</a>
|
||||
% }
|
||||
%# <a href='mailsortingx?ReSerialise' class='link link1'>
|
||||
%#= l('ms_Re_Serialise');
|
||||
%# </a>
|
||||
|
||||
</div>
|
||||
%#= link_to l('ms_Add_new_rule'), 'mailsortinge?trt=RULES' , class=>'link link1'
|
||||
|
||||
|
||||
<h2 class='subh'><%=l('ms_Current_rules')%></h2>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user