e-smith-email/root/etc/e-smith/web/functions/emailsettings

562 lines
19 KiB
XML
Executable File

#!/usr/bin/perl -wT
# vim: ft=xml:
#----------------------------------------------------------------------
# heading : Configuration
# description : E-mail
# navigation : 6000 6700
#
# copyright (C) 1999-2005 Mitel Networks Corporation
# copyright (C) 2004 Shad L. Lords <slords@mail.com>
# copyright (C) 2005 Gordon Rowell <gordonr@gormand.com.au>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
use strict;
use esmith::TestUtils;
use esmith::FormMagick::Panel::emailsettings;
my $f = esmith::FormMagick::Panel::emailsettings->new();
$f->display();
=head1 TESTING
=begin testing
use esmith::FormMagick::Tester;
use esmith::TestUtils;
use esmith::ConfigDB;
my $panel = 'emailsettings';
my $panel_path = "/etc/e-smith/web/functions/".$panel;
my $ua = esmith::FormMagick::Tester->new();
is (mode($panel_path), '4750', "Check permissions on script");
ok ($ua->get_panel($panel), "ABOUT TO RUN L10N TESTS");
is ($ua->{status}, 200, "200 OK");
like($ua->{content}, qr/FORM_TITLE/, "Saw untranslated form title");
ok ($ua->set_language("en-us"), "Set language to U.S. English");
ok ($ua->get_panel($panel), "Get panel");
is ($ua->{status}, 200, "200 OK");
like($ua->{content}, qr/E-mail settings/, "Saw translated form title");
# Testing changes
ok ($ua->get_panel($panel), "Testing panel retrieval");
can_ok($ua, "field");
ok ($ua->{form}->find_input('FreqWeekend'), 'Finding the FreqWeekend field');
ok ($ua->{form}->find_input('SecondaryMailEnvelope'), 'Finding the SecondaryMailEnvelope field');
ok ($ua->{form}->find_input('SpecifyHeader'), 'Finding the SpecifyHeader field');
ok ($ua->{form}->find_input('SecondaryMailPassword'), 'Finding the SecondaryMailPassword field');
ok ($ua->{form}->find_input('FreqOffice'), 'Finding the FreqOffice field');
ok ($ua->{form}->find_input('SecondaryMailAccount'), 'Finding the SecondaryMailAccount field');
ok ($ua->{form}->find_input('SecondaryMailServer'), 'Finding the SecondaryMailServer field');
ok ($ua->{form}->find_input('FreqOutside'), 'Finding the FreqOutside field');
ok ($ua->{form}->find_input('DelegateMailServer'), 'Finding the DelegateMailServer field');
ok ($ua->{form}->find_input('FetchmailMethod'), 'Finding the FetchmailMethod field');
ok ($ua->get_panel($panel), "Testing panel retrieval");
can_ok($ua, "field");
ok ($ua->{form}->find_input('AdminEmail'), "Finding form field");
ok ($ua->{form}->find_input('EmailUnknownUser'), "Finding form field");
ok ($ua->{form}->find_input('SMTPSmartHost'), "Finding form field");
ok ($ua->{form}->find_input('POPAccess'), "Finding form field");
ok ($ua->{form}->find_input('WebMail'), "Finding form field");
SKIP: {
skip 16, "Unsafe!" unless destruction_ok();
$ua->field('FreqWeekend' => 'never');
$ua->field('SecondaryMailEnvelope' => 'X-Recipient');
$ua->field('SpecifyHeader' => 'on');
$ua->field('SecondaryMailPassword' => 'poppassword');
$ua->field('FreqOffice' => 'every5min');
$ua->field('SecondaryMailAccount' => 'popaccount');
$ua->field('SecondaryMailServer' => 'ivy.fsck.com');
$ua->field('FreqOutside' => 'every30min');
$ua->field('DelegateMailServer' => '192.168.23.1');
$ua->field('FetchmailMethod' => 'etrn');
ok ($ua->click("Save"), "Click Save");
is ($ua->{status}, 200, "200 OK");
like($ua->{content}, qr/settings have been saved/, "Saw validation messages");
# Gotta open this later, so we don't cache stale data
my $db = esmith::ConfigDB->open;
is ($db->get('fetchmail')->prop('FreqWeekend'), 'never', 'Validated value for FreqWeekend');
is ($db->get('fetchmail')->prop('SecondaryMailEnvelope'), 'X-Recipient', 'Validated value for SecondaryMailEnvelope');
is ($db->get('fetchmail')->prop('SecondaryMailPassword'), 'poppassword', 'Validated value for SecondaryMailPassword');
is ($db->get('fetchmail')->prop('FreqOffice'), 'every5min', 'Validated value for FreqOffice');
is ($db->get('fetchmail')->prop('SecondaryMailAccount'), 'popaccount', 'Validated value for SecondaryMailAccount');
is ($db->get('fetchmail')->prop('SecondaryMailServer'), 'ivy.fsck.com', 'Validated value for SecondaryMailServer');
is ($db->get('fetchmail')->prop('FreqOutside'), 'every30min', 'Validated value for FreqOutside');
is ($db->get('DelegateMailServer')->value(), '192.168.23.1', 'Validated value for DelegateMailServer');
is ($db->get('fetchmail')->prop('Method'), 'etrn', 'Validated value for FetchmailMethod');
ok ($ua->get_panel($panel), "Testing bogus IP Address");
can_ok($ua, "field");
$ua->field('DelegateMailServer' => '192.168.256.1');
is ($ua->{status}, 200, "200 OK");
unlike($ua->{content}, qr/settings have been saved/, "Didn't see validation message");
}
SKIP: {
skip 8, "Unsafe!" unless destruction_ok();
$ua->field("AdminEmail" => 'bob');
$ua->field("EmailUnknownUser" => 'returntosender');
$ua->field("SMTPSmartHost" => 'foo.example.com');
$ua->field("POPAccess" => 'public');
$ua->field("WebMail" => 'enabled');
ok ($ua->click("Save"), "Click Save");
is ($ua->{status}, 200, "200 OK");
like($ua->{content}, qr/settings have been saved/, "Settings saved");
# Gotta open this later, so we don't cache stale data
my $db = esmith::ConfigDB->open;
my $adb = esmith::AccountsDB->open;
is ($adb->get('admin')->prop('ForwardAddress'), 'bob', "Set the value for Email");
is ($db->get('EmailUnknownUser')->value(), 'returntosender', "Set the value for Email");
is ($db->get('SMTPSmartHost')->value(), 'foo.example.com', "Set the value for Smarthost");
is ($db->get('pop3')->prop('access'), 'public', "Set the value for POPAccess");
is ($db->get('horde')->prop('status'), 'enabled', "Set the value for web mail");
}
=end testing
=cut
__DATA__
<form
title="FORM_TITLE"
header="/etc/e-smith/web/common/head.tmpl"
footer="/etc/e-smith/web/common/foot.tmpl">
<page name="First" pre-event="print_status_message()">
<field
type="literal"
id="state_POPAccess"
display="get_prop('pop3', 'type')"
value="get_current_pop3_access('localise')">
<label>LABEL_POP_ACCESS_CONTROL</label>
</field>
<field
type="literal"
id="state_IMAPAccess"
display="get_prop('imap', 'type')"
value="get_current_imap_access('localise')">
<label>LABEL_IMAP_ACCESS_CONTROL</label>
</field>
<field
type="literal"
id="state_WebMail"
display="get_prop('imp', 'type')"
value="get_current_webmail_status('localise')">
<label>LABEL_WEBMAIL</label>
</field>
<field
type="literal"
id="button_access"
display="display_access_page()"
value="">
<description>DESC_STATE_ACCESS_BUTTON</description>
</field>
<field
type="literal"
id="section_bar"
display="display_access_page()">
<description>DESC_SECTIONBAR</description>
</field>
<field
type="literal"
id="state_Virus"
display="get_prop('clamav', 'type')"
value="get_virus_status('localise')">
<label>LABEL_VIRUS_SCAN</label>
</field>
<field
type="literal"
id="state_Spam"
display="get_prop('spamassassin', 'type')"
value="get_spam_status('localise')">
<label>LABEL_SPAM_SCAN</label>
</field>
<field
type="literal"
id="state_Patterns"
value="get_patterns_status('localise')">
<label>LABEL_BLOCK_EXECUTABLE_CONTENT</label>
</field>
<field
type="literal"
id="button_filtering"
value="">
<description>DESC_STATE_FILTERING_BUTTON</description>
</field>
<field type="literal"
id="state_mode"
value="get_current_retrieval('localise')">
<label>LABEL_MODE</label>
<description>DESC_SECTIONBAR</description>
</field>
<field
type="literal"
id="state_smtpauth"
value="get_current_smtp_auth('localise')">
<label>LABEL_SMTP_AUTH_CONTROL</label>
</field>
<field
type="literal"
id="button_reception"
value="">
<description>DESC_STATE_RECEPTION_BUTTON</description>
</field>
<field
type="literal"
id="state_EmailUnknownUser"
value="get_emailunknownuser_status('localise')">
<label>LABEL_UNKNOWN</label>
<description>DESC_SECTIONBAR</description>
</field>
<field
type="literal"
id="state_DelegateMailServer"
value="get_value('DelegateMailServer')">
<label>LABEL_DELEGATE</label>
</field>
<field
type="literal"
id="state_SMTPSmartHost"
value="get_value('SMTPSmartHost')">
<label>LABEL_SMARTHOST</label>
</field>
<field
type="literal"
id="button_delivery"
value="">
<description>DESC_STATE_DELIVERY_BUTTON</description>
</field>
</page>
<page name="EMAIL_PAGE_RECEPTION"
pre-event="turn_off_buttons"
post-event="change_settings_reception()">
<field type="select"
id="FetchmailMethod"
options="get_retrieval_options()"
value="get_current_retrieval()">
<label>LABEL_MODE</label>
<description>DESC_MODE</description>
</field>
<field
type="select"
id="SMTPAuth"
options="get_smtp_auth_options()"
value="get_current_smtp_auth()">
<label>LABEL_SMTP_AUTH_CONTROL</label>
<description>DESC_SMTP_AUTH_CONTROL</description>
</field>
<field
type="text"
id="SecondaryMailServer"
display="display_multidrop()"
value="get_prop('fetchmail','SecondaryMailServer')">
<label>LABEL_SECONDARY</label>
<description>DESC_SECONDARY</description>
</field>
<field
type="select"
id="FreqOffice"
display="display_multidrop()"
options="fetchmail_frequencies()"
value="get_prop('fetchmail', 'FreqOffice')">
<label>LABEL_FETCH_PERIOD</label>
<description>DESC_FETCH_PERIOD</description>
</field>
<field
type="select"
id="FreqOutside"
display="display_multidrop()"
options="fetchmail_frequencies()"
value="get_prop('fetchmail', 'FreqOutside')">
<label>LABEL_FETCH_PERIOD_NIGHTS</label>
</field>
<field
type="select"
id="FreqWeekend"
display="display_multidrop()"
options="fetchmail_frequencies()"
value="get_prop('fetchmail', 'FreqWeekend')">
<label>LABEL_FETCH_PERIOD_WEEKENDS</label>
</field>
<field
type="text"
id="SecondaryMailAccount"
display="display_multidrop()"
value="get_prop('fetchmail','SecondaryMailAccount')">
<label>LABEL_POP_ACCOUNT</label>
</field>
<field
type="password"
id="SecondaryMailPassword"
display="display_multidrop()"
value="get_prop('fetchmail','SecondaryMailPassword')">
<label>LABEL_POP_PASS</label>
</field>
<field
type="select"
id="SpecifyHeader"
display="display_multidrop()"
options="'off'=> 'DEFAULT', 'on' => 'SPECIFY_BELOW'"
value="get_secondary_mail_use_envelope()">
<label>LABEL_SORT_METHOD</label>
</field>
<field
type="text"
id="SecondaryMailEnvelope"
display="display_multidrop()"
validation=""
value="get_prop('fetchmail','SecondaryMailEnvelope')">
<label>LABEL_SORT_HEADER</label>
</field>
<subroutine src="print_button('SAVE')" />
</page>
<page name="EMAIL_PAGE_FILTERING"
pre-event="turn_off_buttons"
post-event="change_settings_filtering()">
<field type="select"
id="VirusStatus"
display="get_prop('clamav', 'type')"
options="'enabled' => 'ENABLED', 'disabled' => 'DISABLED'"
value="get_virus_status()">
<label>LABEL_VIRUS_SCAN</label>
<description>DESC_VIRUS_SCAN</description>
</field>
<field type="select"
id="Spamstatus"
display="get_prop('spamassassin', 'type')"
options="'enabled' => 'ENABLED', 'disabled' => 'DISABLED'"
value="get_spam_status()">
<label>LABEL_SPAM_SCAN</label>
<description>DESC_SPAM_SCAN</description>
</field>
<field type="select"
id="SpamSensitivity"
display="get_prop('spamassassin', 'type')"
options=" 'verylow' => 'VERYLOW', 'low'=>'LOW', 'medium'=>'MEDIUM', 'high'=>'HIGH', 'veryhigh' => 'VERYHIGH', 'custom' => 'CUSTOM' "
value="get_prop('spamassassin','Sensitivity','medium')">
<label>LABEL_SPAM_SENSITIVITY</label>
</field>
<field
type="select"
id="SpamTagLevel"
display="get_prop('spamassassin', 'type')"
options="get_spam_level_options()"
value="get_prop('spamassassin','TagLevel')">
<label>LABEL_SPAM_TAGLEVEL</label>
</field>
<field
type="select"
id="SpamRejectLevel"
display="get_prop('spamassassin', 'type')"
options="get_spam_level_options()"
value="get_prop('spamassassin','RejectLevel','0')">
<label>LABEL_SPAM_REJECTLEVEL</label>
</field>
<field
type="select"
id="SpamSortSpam"
display="get_prop('spamassassin', 'type')"
options=" 'enabled'=>'ENABLED', 'disabled'=>'DISABLED' "
value="get_prop('spamassassin','SortSpam','enabled')">
<label>LABEL_SORTSPAM</label>
</field>
<field
type="select"
id="SpamSubjectTag"
display="get_prop('spamassassin', 'type')"
options=" 'enabled'=>'ENABLED', 'disabled'=>'DISABLED' "
value="get_prop('spamassassin','SubjectTag')">
<label>LABEL_SPAM_SUBJECTTAG</label>
<description>DESC_SPAM_SUBJECT</description>
</field>
<field
type="text"
id="SpamSubject"
display="get_prop('spamassassin', 'type')"
value="get_prop('spamassassin','Subject')">
<label>LABEL_SPAM_SUBJECT</label>
</field>
<field
type="select" multiple="1"
id="BlockExecutableContent"
options="get_patterns_options()"
value="get_patterns_current_options()">
<label>LABEL_CONTENT_TO_BLOCK</label>
<description>DESC_BLOCK_EXECUTABLE_CONTENT</description>
</field>
<subroutine src="print_button('SAVE')" />
</page>
<page name="EMAIL_PAGE_DELIVERY"
pre-event="turn_off_buttons"
post-event="change_settings_delivery()">
<field
type="select"
id="EmailUnknownUser"
options="get_emailunknownuser_options()"
value="get_emailunknownuser_status()">
<label>LABEL_UNKNOWN</label>
<description>DESC_UNKNOWN</description>
</field>
<field
type="text"
id="DelegateMailServer"
validation="blank_or_ip_number()"
value="get_value('DelegateMailServer')">
<label>LABEL_DELEGATE</label>
<description>DESC_DELEGATE</description>
</field>
<field
type="text"
id="SMTPSmartHost"
validation="validate_smarthost(), nonblank_if_smtpauth()"
value="get_value('SMTPSmartHost')">
<label>LABEL_SMARTHOST</label>
<description>DESC_SMARTHOST</description>
</field>
<field
type="select"
id="SMTPAUTHPROXY_status"
options="'enabled' => 'ENABLED', 'disabled' => 'DISABLED'"
value="get_prop('smtp-auth-proxy', 'status')">
<label>LABEL_SMARTHOST_SMTPAUTH_STATUS</label>
</field>
<field
type="text"
id="SMTPAUTHPROXY_Userid"
validation="nonblank_if_smtpauth()"
value="get_prop('smtp-auth-proxy', 'Userid')">
<label>LABEL_SMARTHOST_SMTPAUTH_USERID</label>
</field>
<field
type="password"
id="SMTPAUTHPROXY_Passwd"
validation="nonblank_if_smtpauth()"
value="get_prop('smtp-auth-proxy', 'Passwd')">
<label>LABEL_SMARTHOST_SMTPAUTH_PASSWD</label>
</field>
<subroutine src="print_button('SAVE')" />
</page>
<page name="EMAIL_PAGE_ACCESS"
pre-event="turn_off_buttons"
post-event="change_settings_access()">
<field
type="select"
id="POPAccess"
options="get_pop_options()"
value="get_current_pop3_access()">
<label>LABEL_POP_ACCESS_CONTROL</label>
<description>DESC_POP_ACCESS_CONTROL</description>
</field>
<field
type="select"
id="IMAPAccess"
options="get_imap_options()"
value="get_current_imap_access()">
<label>LABEL_IMAP_ACCESS_CONTROL</label>
<description>DESC_IMAP_ACCESS_CONTROL</description>
</field>
<field
type="select"
id="WebMail"
display="get_prop('imp', 'type')"
options="get_webmail_options()"
value="get_current_webmail_status()">
<label>LABEL_WEBMAIL</label>
<description>DESC_WEBMAIL</description>
</field>
<subroutine src="print_button('SAVE')" />
</page>
<page
name="Done"
pre-event="turn_off_buttons">
<description>SUCCESS</description>
</page>
</form>