initial commit of file from CVS for smeserver-vacation on Sat Sep 7 21:13:49 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 21:13:49 +10:00
parent 7cb4cb28ec
commit aa21fb54b3
48 changed files with 4838 additions and 2 deletions

511
root/usr/local/bin/vacation Normal file
View File

@@ -0,0 +1,511 @@
#!/usr/bin/perl
#
# $Id: vacation.pl,v 1.3 1999/01/04 04:28:17 psamuel Exp $
#
# Vacation program for qmail. Based on the original version for
# sendmail by Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> and Tom
# Christiansen <tchrist@convex.com>.
#
# The original is available from CPAN as
#
# CPAN/scripts/mailstuff/vacation
#
# This version by Peter Samuel <peter@uniq.com.au>
#
# Minor changes by Daniel van Raay <danielvr@caa.org.au>
#
###########################################################################
use DB_File;
require 5;
$check_to_and_cc = 1;
$dot_vacation_prefix = "";
###########################################################################
#
# Process any command line arguments.
while ($ARGV[0] =~ /^-/)
{
$_ = shift;
if (/^-I/i)
{
&initialise();
exit(0);
}
if (/^-n/)
{
$no_msg_no_reply = 1;
}
if (/^-j/)
{
$check_to_and_cc = 0;
}
if (/^-s/)
{
chdir;
&get_user_details();
&show_dbm_file("$dbm_file");
exit(0);
}
if (/^-t([\d.]*)([smhdw])/)
{
&time_scales();
$timeout = $1;
$timeout *= $scale{$2} if $2;
}
if (/^-p*/)
{
$dot_vacation_prefix = $1;
}
}
&interactive() if (! scalar @ARGV);
###########################################################################
#
# Process incoming mail. Qmail provides a number of environment
# variables that detail the properties of the incoming mail message.
# Qmail always supplies $DTLINE. If it isn't set then we probably
# aren't being called by qmail.
exit(0) unless $ENV{'DTLINE'};
$rpline = $ENV{'RPLINE'};
$ufline = $ENV{'UFLINE'};
exit(0) if ($ufline =~ /-REQUEST\@/i);
exit(0) if ($rpline =~ /-REQUEST\@/i);
$home = $ENV{'HOME'};
$host = lc($ENV{'HOST'});
$sender = lc($ENV{'SENDER'});
$user = lc($ENV{'USER'});
$timeout = 60 * 60 * 24 * 7 unless $timeout;
chdir;
&get_program_details();
&check_ignores();
&check_headers();
&check_lastdate("$dbm_file");
&send_reply();
exit(0);
###########################################################################
sub interactive
{
chdir;
&get_user_details();
if (-f "$dot_qmail_file")
{
print
"You have a $dot_qmail_file in your home directory containing:\n\n";
&cat_file("$dot_qmail_file");
print "\n";
print "Would you like to remove it and disable the vacation feature?";
if (&yesno())
{
&delete_qmail_file("$dot_qmail_file");
&show_dbm_file("$dbm_file");
&clear_dbm_file("$dbm_file");
print "\nBack to normal reception of mail.\n";
exit(0);
}
print << "EOF";
Mail is still under the control of your $dot_qmail_file file.
EOF
exit(0);
}
print << "EOF";
This program can be used to answer your mail automatically
when you go away on vacation.
EOF
if (-f "$message_file")
{
print "You already have a message file in $home/$message_file.\n";
if (&yesno("Would you like to see it?"))
{
&show_file("$message_file");
}
if (&yesno("Would you like to edit it?"))
{
&edit_file("$message_file");
}
}
else
{
&create_msg_file("$message_file", "$vacation_msg");
print << "EOF";
A default vacation message has been created in $home/$message_file.
This message will be automatically returned to anyone sending you mail
while you're away.
EOF
if (&yesno("Would you like to see it?"))
{
&show_file("$message_file");
}
if (&yesno("Would you like to edit it?"))
{
&edit_file("$message_file");
}
}
print << "EOF";
To enable the vacation feature a $home/$dot_qmail_file file is created.
EOF
if (&yesno("Would you like to enable the vacation feature now?"))
{
&create_qmail_file("$dot_qmail_file", "$dot_qmail_commands");
&clear_dbm_file("$dbm_file");
print << "EOF";
The vacation feature has been enabled. Please remember to turn it off
when you return. Bon voyage!
EOF
}
else
{
print "\nThe vaction feature has not been enabled.\n";
}
exit(0);
}
sub initialise
{
chdir;
&get_user_details();
&clear_dbm_file("$dbm_file");
&create_msg_file("$message_file", "$vacation_msg");
&create_qmail_file("$dot_qmail_file", "$dot_qmail_commands");
exit(0);
}
sub edit_file
{
my($file) = @_;
system("$editor $file");
}
sub cat_file
{
my($file) = @_;
open(FILE, "$file");
print while(<FILE>);
close(FILE);
}
sub show_file
{
my($file) = @_;
system("$pager $file");
}
sub show_dbm_file
{
my($file) = @_;
local(%DBM); # Can't be my()
my($key);
require "ctime.pl";
open(PAGER, "| $pager");
print PAGER << "EOF";
Welcome back!
While you were away, vacation mail was sent to the following addresses:
EOF
dbmopen(%DBM, "$file", 0644);
foreach $key (sort keys %DBM)
{
print PAGER "$key\n";
print PAGER " ", ctime(unpack("L", $DBM{$key}));
}
dbmclose(%DBM);
close(PAGER);
}
sub clear_dbm_file
{
my($file) = @_;
local(%DBM); # Can't be my()
dbmopen(%DBM, "$file", 0644);
undef %DBM;
dbmclose(%DBM);
}
sub create_msg_file
{
my($file, $msg) = @_;
open(MSG, "> $file");
print MSG $msg;
close(MSG);
chmod(0644, $file);
}
sub create_qmail_file
{
my($file, $msg) = @_;
open(MSG, "> $file");
print MSG $msg;
close(MSG);
chmod(0644, $file);
}
sub delete_qmail_file
{
my($file) = @_;
unlink("$file");
}
sub yesno
{
my($msg) = @_;
my($answer);
while (1)
{
print "$msg [y/n] ";
$answer = <STDIN>;
last if $answer =~ /^[yn]/i;
}
$answer =~ /^y/i;
}
sub get_common_details
{
$message_file = $dot_vacation_prefix . ".vacation.msg";
$dbm_file = $dot_vacation_prefix . ".vacation";
$vacation_msg = << 'EOF'; # Must use single quotes
Subject: away from my mail
I will not be reading my mail for a while. Your mail regarding
"$SUBJECT"
will be read when I return.
EOF
}
sub get_program_details
{
&get_common_details();
$mailprog = "/var/qmail/bin/datemail -t";
$aliases = $dot_vacation_prefix . ".vacation.aliases";
$noreply = $dot_vacation_prefix . ".vacation.noreply";
}
sub get_user_details
{
&get_common_details();
$user = $ENV{'USER'} || $ENV{'LOGNAME'} || getlogin || (getpwuid($>))[0];
$dot_qmail_file = ".qmail";
$editor = $ENV{'VISUAL'} || $ENV{'EDITOR'} || 'vi';
$home = (getpwnam($user))[7];
$mailbox = "$home/Maildir/";
$pager = $ENV{'PAGER'} || 'less';
$vacation = "/usr/local/bin/vacation";
$dot_qmail_commands = << "EOF"; # Must use double quotes
| $vacation $user
$mailbox
EOF
}
sub time_scales
{
%scale =
(
's', 1,
'm', 60,
'h', 60 * 60,
'd', 60 * 60 * 24,
'w', 60 * 60 * 24 * 7,
);
}
sub check_ignores
{
&get_aliases();
push(@ignores, @aliases);
push(@ignores,
'daemon',
'postmaster',
'mailer-daemon',
'mailer',
'root',
'',
);
if (-f "$noreply")
{
open(NOREPLY, "$noreply");
while(<NOREPLY>)
{
chomp;
next if (/^\s*#|^$/);
push(@ignores, lc($_));
}
close(NOREPLY);
}
for (@ignores)
{
exit(0) if ($sender eq $_);
exit(0) if ($sender =~ /^$_\@/);
}
}
sub check_headers
{
my($header);
$/ = ''; # Read in paragraph mode
$header = <STDIN>;
$header =~ s/\n\s+/ /g; # Join continuation lines
exit(0) if ($header =~ /^Precedence:\s+(bulk|junk|list)/im);
exit(0) if ($header =~ /^From.*-REQUEST\@/im);
exit(0) if ($header =~ /^Mailing-List:/im);
exit(0) if ($header =~ /^X-Spam-Status:\s+Yes/im);
if ($check_to_and_cc)
{
($to) = ($header =~ /To:\s+(.*)/im);
($cc) = ($header =~ /Cc:\s+(.*)/im);
$to .= ', ' . $cc if $cc;
$to = lc($to);
for (@aliases)
{
++$alias_match if $to =~ /\b$_\b/im;
}
exit(0) unless $alias_match;
}
($subject) = ($header =~ /^Subject:\s+(.*)/im);
$subject =~ s/\s*$//m; # Remove trailing spaces
$subject = "(No subject)" unless $subject;
}
sub get_aliases
{
@aliases =
(
"$user\@$host",
);
if (-f "$aliases")
{
open(ALIASES, "$aliases");
while(<ALIASES>)
{
chomp;
next if (/^\s*#|^$/);
push(@aliases, lc($_));
}
close(ALIASES);
}
}
sub check_lastdate
{
my($file) = @_;
dbmopen(%DBM, "$file", 0644);
$now = time;
$then = unpack("L", $DBM{"$sender"});
exit(0) if (($now - $then) <= $timeout);
$DBM{$sender} = pack("L", $now);
close(%DBM);
}
sub send_reply()
{
if (-f "$message_file")
{
open(MSG, "$message_file");
undef $/; # Read in the entire file
$vacation_msg = <MSG>;
close(MSG);
}
else
{
# Do not generate a reply if the user doesn't have a message file
# and -n was supplied on the command line.
exit(0) if ($no_msg_no_reply);
}
my $type = ($vacation_msg =~ m/<html/ && $vacation_msg =~ m/<\/html>/ ) ? 'html':'plain';
$vacation_msg =~ s/\$SUBJECT/$subject/g;
open(MAILPROG, "| $mailprog");
print MAILPROG << "EOF";
To: $sender
Precedence: junk
Content-Type: text/$type; charset="UTF-8"
EOF
print MAILPROG $vacation_msg;
close(MAILPROG);
}

View File

@@ -0,0 +1,585 @@
.\"
.\" $Id: vacation.1,v 1.3 1999/01/04 04:28:02 psamuel Exp $
.\"
.TH vacation 1 "23 Sep 1998"
.SH NAME
vacation \- reply to mail automatically
.SH SYNOPSIS
.B vacation
.br
.B vacation
.RI [ -I ]
.br
.B vacation
.RI [ -s ]
.br
.B vacation
.RI [ -j ]
.RI [ -n ]
.RI [ -tN ]
.I username
.SH DESCRIPTION
.B vacation
automatically replies to incoming mail. This version of
.B vacation
has been specifically tailored for use with a
.B qmail
mail transport agent. It will almost certainly fail if used with a
different mail transport agent.
.SH USAGE
.SS Preparing to go away on vacation
.LP
Run
.B vacation
without any command line arguments.
.LP
The first time you run
.BR vacation ,
a default reply message will be created in
.BR ~/.vacation.msg .
If this file already exists, it will not be overwritten. You'll be
given the opportunity to see the contents of this file as well as the
chance to edit it to make your own changes.
.LP
Once you are satisfied with the contents of the reply message,
you will be asked if you would like to enable
.BR vacation .
.LP
If you answer
.IR yes ,
a default
.B ~/.qmail
file will be created. The contents of this file are:
.in 2i
| /usr/local/bin/vacation \fIusername\fP
.br
$home/Maildir/
.in
(If you see an environment variable above - such as
.I $home
or
.I $user
- it will be expanded to its correct value during
.B vacation's
setup phase).
.LP
These instructions tell the
.B qmail-local
mail delivery agent to send an automatic reply to the sender of the
message and to save a copy of the message in your default mailbox.
.LP
Answering
.I yes
also instructs
.B vacation
to initialise the
.I dbm
database file(s). The
.I dbm
database file(s) will contain details of who was sent an automatic
reply and when it was sent. If the
.I dbm
database file(s) already exist, the contents will be cleared.
.LP
If you answer
.I no
when asked if you wish to enable
.BR vacation ,
neither the
.B ~/.qmail
nor the
.I dbm
database file(s) will be created.
.SS Returning from vacation
Run
.B vacation
without any command line arguments.
.LP
.B vacation
displays the contents of your
.B ~/.qmail
file and asks if you would like to remove the file, thereby disabling
.BR vacation .
.LP
If you answer
.IR yes ,
your
.B ~/.qmail
file will be removed.
.B vacation
will then display the contents of the
.I dbm
database, listing the mail addresses of those who were sent an
automatic reply to their mail while you were away and the date on which
the automatic reply was sent. The
.I dbm
database will then be cleared.
.LP
If you answer
.IR no ,
your
.B ~/.qmail
file will not be removed and the contents of the
.I dbm
database will remain unchanged.
.SS Processing incoming mail
When not in setup mode,
.B vacation
reads an incoming mail message from standard input and automatically
sends a reply message to the sender. The reply text is taken from
.BR ~/.vacation.msg .
If this file does not exist, a default message will be used.
.B vacation
will
.I not
generate a reply if any of the following conditions are met:
.TP
.B -
The sender address includes the string
.BR -REQUEST@ .
.TP
.B -
The sender is you.
.TP
.B -
The sender's name is any of:
.in 2i
daemon
.br
postmaster
.br
mailer-daemon
.br
mailer
.br
root
.in
.TP
.B -
The sender matches any of the mail addresses listed in the optional
files
.B ~/.vacation.aliases
and
.BR ~/.vacation.noreply .
See the
.B FILES
section below for more details on these files.
.TP
.B -
There is a
.B Precedence: bulk
or
.B Precedence: junk
header.
.TP
.B -
There is a
.B Mailing-List:
header.
.TP
.B -
Your mail address, or any address you have listed in the optional
.B ~/.vacation.aliases
file does
.I not
appear in either the
.B To:
or
.B Cc:
headers. This feature can be disabled using the
.B -j
option. See the
.B OPTIONS
section below for more details on this option.
.TP
.B -
An automatic reply has already been sent to the same address during
the last week. The timeout value may be changed using the
.B -t
option. See the
.B OPTIONS
section below for more details on this option.
.TP
.B -
.B -n
was specified on the command line and the user does not have a
.B ~/.vacation.msg
file.
.SH OPTIONS
.TP 10
.I none
If no command line options are provided,
.B vacation
will run as an interactive setup program. If you do not have a
.B ~/.qmail
file,
.B vacation
will assume you wish to enable its services. If you have a
.B ~/.qmail
file,
.B vacation
will assume you wish to disable its services.
.TP 10
.B -I
Hands free initialisation.
.B vacation
will create your
.BR ~/.qmail ,
.B ~/.vacation.msg
and
.I dbm
database files. If
.I any
of these files already exist, their contents will be replaced by the
.B vacation
defaults.
.B vacation
will exit after the initialisation process, regardless of any other
command line options provided.
.TP 10
.B -s
Show the contents of the
.I dbm
database. The contents will not be cleared and your
.B ~/.qmail
and
.B ~/.vacation.msg
files will remain intact.
.B vacation
will exit after displaying the contents of the
.I dbm
database, regardless of any other command line options provided.
.TP 10
.B -j
Do not examine the incoming message
.B To:
or
.B Cc:
headers to determine if the message was sent directly to you rather
than an alias. Using this option means that mail sent to an alias of
which you are a member may generate an automatic reply. This option is
only useful when specified in the
.B ~/.qmail
file.
.TP 10
.B -n
Do not generate a reply message if the user's
.B ~/.vacation.msg
does not exist. Updates to the
.I dbm
database will still be performed. This option is for those users who
wish to quickly disable
.B vacation
by removing their
.B ~/.vacation.msg
file. It can also be used at sites where users do not have shell
accounts but can remove their own files via ftp or perhaps a purpose
built web interface.
.TP 10
.BI -t N
Change the interval between repeat replies to the same sender. The
default is 1 week. A trailing
.BR s ,
.BR m ,
.BR h ,
.BR d ,
or
.B w
scales the number
.I N
to seconds, minutes, hours, days or weeks respectively. For example, to
set the interval value to 3 days you would specify
.B -t3d.
There should be
.I no
spaces between the
.B -t
and
.IR N .
This option is only useful when specified in the
.B ~/.qmail
file.
.TP 10
.I username
Your login name. When
.B vacation
sees this argument it will examine standard input for an incoming mail
message. The value of this argument is not actually used by this
implementation of
.B vacation
as your login name is provided by a
.B qmail
environment variable. However an argument
.I must
be supplied so that
.B vacation
knows when to process incoming mail and when to provide an interactive
setup session. Using your login name for this argument simply maintains
a look and feel similar to the
.B sendmail
version of
.BR vacation .
.SH ENVIRONMENT
.LP
If the environment variable
.B $VISUAL
is set and is not null, its value determines the editor used to edit
the
.BR ~/.vacation.msg .
If
.B $VISUAL
is not set or its value is null, the environment variable
.B $EDITOR
is examined. If it is set and is not null, its value determines the
editor to be used. If
.B $EDITOR
is not set or its value is null, the default editor
.B vi
will be used.
.LP
If the environment variable
.B $PAGER
is set and is not null, its value determines the page viewing program
to be used to display the
.B ~/.vacation.msg
and the contents of the
.I dbm
database. If it is not set or its value is null, the default page
viewer
.B less
will be used.
.SH FILES
.TP 10
.B ~/.vacation.msg
Contains the text of the automatic reply message. It should
.I not
contain any
.B From:
or
.B To:
headers. If the string
.B $SUBJECT
appears in
.BR ~/.vacation.msg ,
it will be replaced with the subject of the original message. The
default message is:
.in 2i
Subject: away from my mail
I will not be reading my mail for a while. Your mail regarding
"$SUBJECT"
will be read when I return.
.in
.TP 10
.B ~/.qmail
Contains the delivery instructions for
the local mail delivery agent,
.BR qmail-local .
The default contents of this file are:
.in 2i
| /usr/local/bin/vacation \fIusername\fP
.br
$home/Maildir/
.in
(If you see an environment variable above - such as
.I $home
or
.I $user
- it will be expanded to its correct value during
.B vacation's
setup phase).
The first line instructs
.B qmail-local
to generate an automatic reply and the second line instructs
.B qmail-local
to save the incoming message in your default mailbox. Failure to
include this line will result in automatic replies being generated but
.I no
mail will be saved in your default Mailbox.
.TP 10
.B ~/.vacation.*
The
.I dbm
database file(s) used to store sender mail addresses and time stamps.
The actual name of this file, or files, depends on the implementation
of
.B Perl
you have at your site. Possibilities include
.B ~/.vacation.pag
and
.B ~/.vacation.dir
or
.BR ~/.vacation.db .
The actual names are unimportant as
.B Perl
deals with them internally.
.TP 10
.B ~/.vacation.aliases
This optional file contains a list of mail addresses, one per line.
Each address should be a fully qualified alias for yourself. This file
serves two purposes.
Unless started
with the
.B -j
option,
.B vacation
examines the incoming message
.B To:
and
.B Cc:
headers. If your mail address, or any of the mail addresses specified
in
.BR ~/.vacation.aliases ,
match any of the addresses in these headers, an automatic reply will
be generated for the message. If there is no match, an automatic reply
will not be generated. This restricts
.B vacation
to replying to mail explicitly addressed to you or any of your
aliases.
The second purpose is to avoid sending an automatic reply to any
incoming mail from yourself or one of your aliases - you already know
you're on vacation!
Lines beginning with a
.I #
character and blank lines will be ignored.
.TP 10
.B ~/.vacation.noreply
This file contains a list of mail addresses, one per line. If an
incoming mail message matches one of the listed addresses, an
automatic reply will not be generated for that message. The addresses
need not be fully qualified. If you will be sending yourself mail from
a remote site, you may wish to include your remote address to avoid
sending yourself an automatic reply.
Lines beginning with a
.I #
character and blank lines will be ignored.
.SH CAVEATS
If you already have a
.B ~/.qmail
file, which contains delivery instructions other than those specified
by
.BR vacation ,
there is a risk that it will be deleted by
.BR vacation .
It is good practise to keep a copy of your
.B ~/.qmail
file.
If you are hand editing your
.B ~/.qmail
file, remember to include a delivery instruction to save the message in
your default Mailbox, which should be
.BR $home/Maildir/ .
You
.I must
expand any environment variables - such as
.I $home
or
.I $user
- as
.B qmail-local
will not expand them for you.
If you have a detailed
.B ~/.vacation.msg
with text different from the default, there is a risk that it will be
deleted by
.BR vacation .
It is good practise to keep a copy of your
.B ~/.vacation.msg
file.
If you are hand editing your
.B ~/.vacation.msg
file, the first block of lines up to the first blank line will form
part of the mail headers.
There is
.I no
need to run this version of
.B vacation
through
.BR qmail 's
.B preline
program.
.B preline
is used to insert a
.B UUCP
style
.B From
header into the message. This version of
.B vacation
does not need that header. In fact, running this version of
.B vacation
through
.B preline
will cause problems if the incoming message is larger than your system's
standard I/O buffer size.
.B preline
expects to pipe the entire message through a subsequent command.
However
.B vacation
only examines the headers of the message, and then stops reading from
standard input. This upsets
.B preline
if the size of the message is larger than a single I/O buffer. In this
case
.B preline
will terminate with a transient error to
.B qmail-send
and you'll see the following message in your mail logs:
.in 1i
.B deferral: preline:_fatal:_unable_to_copy_input:_broken_pipe/
.in
The same problem exists if you use the traditional
.B sendmail
version of
.B vacation
with
.BR qmail .
That version of
.B vacation
requires the use of
.B preline
to provide it with the
.B UUCP
style
.B From
header.
.SH VERSION
Version 1.3
.SH AUTHOR
Peter Samuel, Uniq Professional Services
.br
<Peter.Samuel@uniq.com.au>
.SH AVAILABILITY
The latest version of
.B vacation
for
.B qmail
should always be available from
.I ftp://ftp.uniq.com.au/pub/tools
.SH SEE ALSO
.BR vi (1),
.BR less (1),
.BR dot-qmail (5),
.BR qmail (7),
.BR qmail-command (8),
.BR qmail-local (8),
.BR qmail-send (8).

View File

@@ -0,0 +1,463 @@
#----------------------------------------------------------------------
# uservacations.pm
# support@dungog.net
#----------------------------------------------------------------------
package esmith::FormMagick::Panel::uservacations;
use strict;
use warnings;
use esmith::util;
use esmith::FormMagick;
use esmith::AccountsDB;
use esmith::ConfigDB;
use Exporter;
use Carp qw(verbose);
use HTML::Tabulate;
our @ISA = qw(esmith::FormMagick Exporter);
our @EXPORT = qw();
our $db = esmith::ConfigDB->open();
our $adb = esmith::AccountsDB->open();
our $PanelUser = $ENV{'REMOTE_USER'} ||'';
$PanelUser = $1 if ($PanelUser =~ /^([a-z][\.\-a-z0-9]*)$/);
our %delegatedVacations;
sub new {
shift;
my $self = esmith::FormMagick->new(filename => '/etc/e-smith/web/functions/uservacations');
$self->{calling_package} = (caller)[0];
bless $self;
return $self;
}
#server-manager functions
sub user_accounts_exist
{
my $self = shift;
my $q = $self->{cgi};
#return scalar $adb->users;
if (scalar $adb->users)
{ return $self->localise('DESCRIPTION'); }
}
sub print_vacation_table
{
my $self = shift;
my $q = $self->{cgi};
#We want to retrieve granted group from DB, and retrieve users of groups
my $record = $adb->get($PanelUser);
my $dg=$record->prop('delegatedVacations')||'';
$dg =~ s/ //g;
my @g = split(/,/, $dg);
my @visiblemembers = ();
foreach my $g (@g) {
my $members = $adb->get_prop("$g",'Members');
next unless defined $members;
$members =~ s/ //g;
my @members = split(/,/, $members);
push @visiblemembers , @members ;
}
foreach my $k ( @visiblemembers )
{
$delegatedVacations{$k}=1;
}
my @users = $adb->users;
return $self->localise("ACCOUNT_USER_NONE") if (@users == 0);
return $self->localise("NO_USERS_IN_GRANTED_GROUPS") if (@visiblemembers == 0 && $dg ne '');
my $vacation_table =
{
title => $self->localise('USER_LIST_CURRENT'),
stripe => '#D4D0C8',
fields => [ qw(User FullName status Modify) ],
labels => 1,
field_attr => {
User => { label_escape => 0, escape => 0 , label => $self->localise('ACCOUNT') },
FullName => { label_escape => 0, escape => 0 , label => $self->localise('USER_NAME') },
status => { label_escape => 0, escape => 0 , label => $self->localise('LABEL_VACATION') },
Modify => { label_escape => 0,
label => $self->localise('MODIFY'),
link => \&modify_link
},
}
};
my @data = ();
for my $user (@users)
{
next if %delegatedVacations and not $delegatedVacations{$user->key};
# make it clearer which uses have vacation
my $EmailVacation = $user->prop('EmailVacation') || '';
my $EmailVacationFrom = $user->prop('EmailVacationFrom') || '';
my $EmailVacationTo = $user->prop('EmailVacationTo') || '';
my $status = $user->prop('EmailVacation') || '';
if ($status eq 'yes') { $status = 'YES'; } else { $status = ''; }
push @data,
{ User => $user->key,
FullName => $user->prop('FirstName') . " " .
$user->prop('LastName'),
status => $self->localise($status),
EmailVacation => $EmailVacation,
EmailVacationFrom => $EmailVacationFrom,
EmailVacationTo => $EmailVacationTo,
Modify => $self->localise('MODIFY'),
}
}
my $t = HTML::Tabulate->new($vacation_table);
$t->render(\@data, $vacation_table);
}
sub modify_link
{
my ($data_item, $row, $field) = @_;
return "uservacations?" .
join("&",
"page=0",
"page_stack=",
"Next=Next",
"User=" . $row->{User},
"FullName=" . $row->{FullName},
"EmailVacation=" . $row->{EmailVacation},
"EmailVacationFrom=" . $row->{EmailVacationFrom},
"EmailVacationTo=" . $row->{EmailVacationTo},
"wherenext=VACATION_PAGE_MODIFY");
}
# this formats the text to display on screen
sub get_vacation_text
{
my $self = shift;
my $q = $self->{cgi};
my $domain = $db->get_value('DomainName');
my $user = $q->param('User');
my $fullname = $adb->get_prop($user, "FirstName") . " " .
$adb->get_prop($user, "LastName");
my $vfile = "/home/e-smith/files/users/$user/.vacation.msg";
my $from = 'From:';
my $away = $self->localise('AWAY_FROM_MAIL');
my $return = $self->localise('ANSWER_TO_OBJECT_SENDER');
my $ExistingMessage = "$from $fullname &lt\;$user\@$domain&gt\;\n"."Subject: $return\n".
"\n$away\n"."\n--\n$fullname";
# if exists and is not empty
if (( -e $vfile ) && (! -z $vfile ))
{
open (VACATION, "<$vfile")
or die "Error: Could not open file: $vfile\n";
my @vacationTemp;
#reformat so email address isn't hidden inside < >
while (<VACATION>)
{
$_ =~ s/</&lt\;/;
$_ =~ s/>/&gt\;/;
push (@vacationTemp, $_);
}
$ExistingMessage = join ("", @vacationTemp);
close VACATION;
}
my $start = '<tr>
<td class="sme-noborders-label">' . $self->localise('MESSAGE') . '
<td class="sme-noborders-content"><TEXTAREA NAME="new_message" ROWS="10" COLS="60">';
my $end = '</TEXTAREA></td>
</tr>';
return $start . $ExistingMessage . $end;
}
# saves the text to .vacation.msg
sub change_settings
{
my $self = shift;
my $q = $self->{cgi};
my $domain = $db->get_value('DomainName');
my $user = $q->param('User');
my $EmailVacation = $q->param('EmailVacation');
my $EmailVacationFrom = $q->param('EmailVacationFrom');
my $EmailVacationTo = $q->param('EmailVacationTo');
my $new_message = $q->param('new_message');
my $vfile = "/home/e-smith/files/users/$user/.vacation.msg";
my $fullname = $adb->get_prop($user, "FirstName") . " " .
$adb->get_prop($user, "LastName");
my $from = 'From:';
my $away = $self->localise('AWAY_FROM_MAIL');
my $return = $self->localise('ANSWER_TO_OBJECT_SENDER');
my $vacation_text = "$from $fullname \<$user\@$domain\>\n"."Subject: $return\n".
"\n$away \n"."\n--\n$fullname";
my $reset = $vacation_text;
# if exists and is not empty
if (( -e $vfile ) && (! -z $vfile ))
{
open (VACATION, "<$vfile")
or die "Error: Could not open file: $vfile\n";
my @vacationTemp = <VACATION>;
$vacation_text = join ("", @vacationTemp);
close VACATION;
}
chomp $new_message;
# reset msg to default,
if ($new_message =~ /reset/)
{ $vacation_text = $reset; }
else
{
#or save new_message
unless ($new_message eq "")
{ $vacation_text = $new_message; }
}
# Strip out DOS Carriage Returns (CR)
$vacation_text =~ s/\r//g;
unlink $vfile;
open (VACATION, ">$vfile")
or die ("Error opening vacation message.\n");
print VACATION "$vacation_text";
close VACATION;
esmith::util::chownFile($user, $user,
"/home/e-smith/files/users/$user/.vacation.msg");
$adb->set_prop($user, 'EmailVacation', $EmailVacation);
$adb->set_prop($user, 'EmailVacationFrom', $EmailVacationFrom);
$adb->set_prop($user, 'EmailVacationTo', $EmailVacationTo);
#the first is more correct but is slower
#system ("/sbin/e-smith/signal-event", "email-update", $user) == 0
system ("/etc/e-smith/events/actions/qmail-update-user event $user") == 0
or die ("Error occurred updating .qmail\n");
if (($EmailVacation eq 'no') && ( -e "/home/e-smith/files/users/$user/.vacation"))
{
system ("/bin/rm /home/e-smith/files/users/$user/.vacation") == 0
or die ("Error resetting vacation db.\n");
}
return $self->success("SUCCESS");
}
#userpanel functions ######################################################
sub get_panel_user
{
return $PanelUser;
}
sub get_full_name
{
return $adb->get_prop($PanelUser, "FirstName") . " " .
$adb->get_prop($PanelUser, "LastName");
}
sub get_vacation_status
{
return $adb->get_prop($PanelUser, "EmailVacation");
}
sub get_vacation_date_from
{
return $adb->get_prop($PanelUser, "EmailVacationFrom");
}
sub get_vacation_date_to
{
return $adb->get_prop($PanelUser, "EmailVacationTo");
}
# this formats the text to display on screen
sub userpanel_get_vacation_text
{
my $self = shift;
my $q = $self->{cgi};
my $domain = $db->get_value('DomainName');
# single difference in userpanel function
my $user = $PanelUser;
my $fullname = $adb->get_prop($user, "FirstName") . " " .
$adb->get_prop($user, "LastName");
my $vfile = "/home/e-smith/files/users/$user/.vacation.msg";
my $from = 'From:';
my $away = $self->localise('AWAY_FROM_MAIL');
my $return = $self->localise('ANSWER_TO_OBJECT_SENDER');
my $ExistingMessage = "$from $fullname &lt\;$user\@$domain&gt\;\n"."Subject: $return\n".
"\n$away"."\n--\n$fullname";
# if exists and is not empty
if (( -e $vfile ) && (! -z $vfile ))
{
open (VACATION, "<$vfile")
or die "Error: Could not open file: $vfile\n";
my @vacationTemp;
#reformat so email address isn't hidden inside < >
while (<VACATION>)
{
$_ =~ s/</&lt\;/;
$_ =~ s/>/&gt\;/;
push (@vacationTemp, $_);
}
$ExistingMessage = join ("", @vacationTemp);
close VACATION;
}
my $start = '<tr>
<td class="sme-noborders-label">' . $self->localise('MESSAGE') . '
<td class="sme-noborders-content"><TEXTAREA NAME="new_message" ROWS="10" COLS="60">';
my $end = '</TEXTAREA></td>
</tr>';
return $start . $ExistingMessage . $end;
}
# saves the text to .vacation.msg
sub userpanel_change_settings
{
my $self = shift;
my $q = $self->{cgi};
my $domain = $db->get_value('DomainName');
# single difference in userpanel function
my $user = $PanelUser;
my $EmailVacation = $q->param('EmailVacation');
my $new_message = $q->param('new_message');
my $EmailVacationFrom = $q->param('EmailVacationFrom');
my $EmailVacationTo = $q->param('EmailVacationTo');
my $vfile = "/home/e-smith/files/users/$user/.vacation.msg";
my $fullname = $adb->get_prop($user, "FirstName") . " " .
$adb->get_prop($user, "LastName");
my $from = 'From:';
my $away = $self->localise('AWAY_FROM_MAIL');
my $return = $self->localise('ANSWER_TO_OBJECT_SENDER');
my $vacation_text = "$from $fullname \<$user\@$domain\>\n"."Subject: $return\n".
"\n$away \n"."\n--\n$fullname";
my $reset = $vacation_text;
# if exists and is not empty
if (( -e $vfile ) && (! -z $vfile ))
{
open (VACATION, "<$vfile")
or die "Error: Could not open file: $vfile\n";
my @vacationTemp = <VACATION>;
$vacation_text = join ("", @vacationTemp);
close VACATION;
}
chomp $new_message;
# reset msg to default,
if ($new_message =~ /reset/)
{ $vacation_text = $reset; }
else
{
#or save new_message
unless ($new_message eq "")
{ $vacation_text = $new_message; }
}
# Strip out DOS Carriage Returns (CR)
$vacation_text =~ s/\r//g;
unlink $vfile;
# for the next lines to avoid race condition vulnerability, we switch the effective user to
# the one needed see SME #9073 . Those 4 lines are for explanation of the used variables.
#$< - real user id (uid); unique value
#$> - effective user id (euid); unique value
#$( - real group id (gid); list (separated by spaces) of groups
#$) - effective group id (egid); list (separated by spaces) of groups
# remember the UID of the user currently running this script
my $original_uid = $>;
my $original_gid = $);
# switch effective UID running this script to $user
# in order to prevent race condition vulnerability
my $uid = getpwnam($user) or die "Could not get UID for $user\n";
my $gid = getgrnam($user) or die "Could not get GID for $user\n";
$) = $gid;# should be switched first while still root!
$> = $uid;
open (VACATION, ">$vfile")
or die ("Error opening vacation message.\n");
print VACATION "$vacation_text";
close VACATION;
# switch effective UID and GID back to original user
$> = $original_uid;
$) = $original_gid;
$adb->set_prop($user, 'EmailVacation', $EmailVacation);
$adb->set_prop($user, 'EmailVacationFrom', $EmailVacationFrom);
$adb->set_prop($user, 'EmailVacationTo', $EmailVacationTo);
#the first is more correct but is slower
#system ("/sbin/e-smith/signal-event", "email-update", $user) == 0
system ("/etc/e-smith/events/actions/qmail-update-user event $user") == 0
or die ("Error occurred updating .qmail\n");
if (($EmailVacation eq 'no') && ( -e "/home/e-smith/files/users/$user/.vacation"))
{
system ("/bin/rm /home/e-smith/files/users/$user/.vacation") == 0
or die ("Error resetting vacation db.\n");
}
return $self->success("SUCCESS");
}
1;

View File

@@ -0,0 +1,384 @@
package SrvMngr::Controller::Uservacations;
#----------------------------------------------------------------------
# heading : User management
# description : User Vacations
# navigation : 2000 150
#
# name : Uservacationsget, method : get, url : /uservacations, ctlact : Uservacations#main
# name : Uservacationspost,method : post, url : /Uservacations, ctlact : Uservacations#do_display
# name : Uservacations1, method : get, url : /Uservacations1, ctlact : Uservacations#do_display
# name : Uservacations2, method : post, url : /Uservacations2, ctlact : Uservacations#do_display
# routes : end
#----------------------------------------------------------------------
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
#use DateTime; #Not part of SME10 mix
use POSIX;
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use Data::Dumper;
use esmith::util;
use esmith::HostsDB;
use esmith::AccountsDB;
our $db = esmith::ConfigDB->open();
our $adb = esmith::AccountsDB->open();
our $PanelUser = $ENV{'REMOTE_USER'} ||'';
$PanelUser = $1 if ($PanelUser =~ /^([a-z][\.\-a-z0-9]*)$/);
our %delegatedVacations;
use constant FALSE => 0;
use constant TRUE => 1;
sub main {
my $c = shift;
$c->app->log->info( $c->log_req );
my %vac_datas = ();
my $title = $c->l('vac_FORM_TITLE');
my $modul = '';
$vac_datas{trt} = 'LIST';
my @vacations = get_vacation_table($c);
my $empty = (scalar @vacations == 0);
$vac_datas{"first"} = 'vac_MODIFY_DESCRIPTION';
$c->stash(
title => $title,
modul => $modul,
vac_datas => \%vac_datas,
vacations =>\@vacations,
empty => $empty
);
$c->render( template => 'uservacations' );
}
sub do_display {
my $c = shift;
$c->app->log->info( $c->log_req );
my $rt = $c->current_route;
my $trt = ( $c->param('trt') || 'LIST' );
$trt = 'ADD' if ( $rt eq 'Uservacations1' );
$trt = 'ADD1' if ( $rt eq 'Uservacations2' );
my %vac_datas = ();
my $title = $c->l('vac_FORM_TITLE');
my $modul = '';
if ( $trt eq 'ADD' ) {
# Add or change a vacation message - called from the list panel
# Get the data and pass it across.
my $account = $c->param("account");
my $user = $adb->get($account);
my $username = $user->prop("FirstName")." ".$user->prop("LastName");
my $EmailVacation = $user->prop('EmailVacation') || '';
my $EmailVacationFrom = $user->prop('EmailVacationFrom') || '';
my $EmailVacationTo = $user->prop('EmailVacationTo') || '';
my $VacText = get_vacation_text($c);
$c->stash(account=>$account,
username=>$username,
EmailVacation=>$EmailVacation,
EmailVacationFrom=>$EmailVacationFrom,
EmailVacationTo=>$EmailVacationTo,
VacText=>$VacText
);
}
if ( $trt eq 'ADD1' ) {
#Add or edit vacation message.
my $ret = add_vac_message($c);
#Return to list page if success
if ($ret eq "OK") {
$trt = "LIST";
$vac_datas{success} = "vac_SUCCESS";
} else {
my $account = $c->param("account");
my $user = $adb->get($account);
my $username = $user->prop("FirstName")." ".$user->prop("LastName");
my $EmailVacationFrom = $c->param('EmailVacationFrom') || '';
my $EmailVacationTo = $c->param('EmailVacationTo') || '';
my $EmailVacation = $c->param('EmailVacation') || '';
my $VacText = $c->param("VacText");
$c->stash(account=>$account,
username=>$username,
EmailVacation=>$EmailVacation,
EmailVacationFrom=>$EmailVacationFrom,
EmailVacationTo=>$EmailVacationTo,
VacText=>$VacText
);
#Error - return to Add page
$trt = "ADD";
$vac_datas{error} = $ret;
}
}
if ( $trt eq 'LIST' ) {
#List all the users and vacation message details.
my @vacations = get_vacation_table($c);
my $empty = (scalar @vacations == 0);
$c->stash(
empty => $empty,
vacations =>\@vacations
);
}
$vac_datas{'trt'} = $trt;
$c->stash( title => $title, modul => $modul, vac_datas => \%vac_datas );
$c->render( template => 'uservacations' );
}
sub user_accounts_exist
{
my $q = shift;
#return scalar $adb->users;
if (scalar $adb->users)
{ return $q->l('vac_DESCRIPTION'); }
}
sub get_vacation_table
{
my $self = shift;
#We want to retrieve granted group from DB, and retrieve users of groups
my $record = $adb->get($PanelUser);
my $dg;
if ($record) {$dg=$record->prop('delegatedVacations')||'';}
else {$dg = '';}
$dg =~ s/ //g;
my @g = split(/,/, $dg);
my @visiblemembers = ();
foreach my $g (@g) {
my $members = $adb->get_prop("$g",'Members');
next unless defined $members;
$members =~ s/ //g;
my @members = split(/,/, $members);
push @visiblemembers , @members ;
}
foreach my $k ( @visiblemembers )
{
$delegatedVacations{$k}=1;
}
my @users = $adb->users;
return () if (@users == 0); ##$self->l("ACCOUNT_USER_NONE")
return () if (@visiblemembers == 0 && $dg ne '');#; #$self->l("NO_USERS_IN_GRANTED_GROUPS")
my @data = ();
for my $user (@users)
{
next if %delegatedVacations and not $delegatedVacations{$user->key};
# make it clearer which uses have vacation
my $EmailVacation = $user->prop('EmailVacation') || '';
my $EmailVacationFrom = $user->prop('EmailVacationFrom') || '';
my $EmailVacationTo = $user->prop('EmailVacationTo') || '';
my $status = $user->prop('EmailVacation') || '';
if ($status eq 'yes') { $status = 'YES'; } else { $status = ''; }
push @data,
{ User => $user->key,
FullName => $user->prop('FirstName') . " " .$user->prop('LastName'),
status => $self->l($status),
EmailVacation => $EmailVacation,
EmailVacationFrom => showDate($EmailVacationFrom),
EmailVacationTo => showDate($EmailVacationTo),
Modify => $self->l('vac_MODIFY'),
}
}
return @data;
}
sub showDate
{
my $strDate = shift;
my ($Year,$Month,$Day) = ($strDate =~ /(\d{4})(\d{2})(\d{2})/);
#my $Unix = mktime(0,0,0,$Day,$Month,$Year);
return "$Year-$Month-$Day";
}
sub modify_link
{
my ($data_item, $row, $field) = @_;
return "uservacations?" .
join("&",
"page=0",
"page_stack=",
"Next=Next",
"User=" . $row->{User},
"FullName=" . $row->{FullName},
"EmailVacation=" . $row->{EmailVacation},
"EmailVacationFrom=" . $row->{EmailVacationFrom},
"EmailVacationTo=" . $row->{EmailVacationTo},
"wherenext=VACATION_PAGE_MODIFY");
}
# this formats the text to display on screen
sub get_vacation_text
{
my $q = shift;
my $domain = $db->get_value('DomainName');
my $user = $q->param('account');
my $fullname = $adb->get_prop($user, "FirstName") . " " .
$adb->get_prop($user, "LastName");
my $vfile = "/home/e-smith/files/users/$user/.vacation.msg";
my $from = $q->l('vac_FROM');
my $Subject = $q->l('vac_SUBJECT');
my $away = $q->l('vac_AWAY_FROM_MAIL');
my $return = $q->l('vac_ANSWER_TO_OBJECT_SENDER');
#my $ExistingMessage = "$from $fullname &lt\;$user\@$domain&gt\;\n"."$Subject $return\n".
# "\n$away\n"."\n--\n$fullname";
my $ExistingMessage = "$from $fullname \<$user\@$domain\>\n"."$Subject $return\n".
"\n$away\n"."\n--\n$fullname";
# if exists and is not empty
if (( -e $vfile ) && (! -z $vfile ))
{
open (VACATION, "<$vfile")
or die "Error: Could not open file: $vfile\n";
my @vacationTemp;
#reformat so email address isn't hidden inside < >
while (<VACATION>)
{
$_ =~ s/</&lt\;/;
$_ =~ s/>/&gt\;/;
push (@vacationTemp, $_);
}
$ExistingMessage = join ("", @vacationTemp);
close VACATION;
}
return $ExistingMessage;
}
# saves the text to .vacation.msg
sub add_vac_message
{
my $q = shift;
my $domain = $db->get_value('DomainName');
my $user = $q->param('account');
my $EmailVacation = $q->param('EmailVacation')||"no";
#die($EmailVacation);
#if ($EmailVacation eq "yes") {$EmailVacation = "yes";} else {$EmailVacation = "no";}
#Decode To and FROM to standard format - comes over in html5 iso format yyyy-mm-dd
my $EmailVacationFrom = trim($q->param('EmailVacationFrom'));
my ($fromYear,$fromMonth,$fromDay) = ($EmailVacationFrom =~ /(\d{4})-(\d{2})-(\d{2})/);
$EmailVacationFrom = $fromYear.$fromMonth.$fromDay;
if ($EmailVacationFrom !~ m/^2[0-9]{3}[0|1][0-9][0-3][0-9]$/ and $EmailVacationFrom ne "") {return "vac_FROM_DATE_INCORRECT";}
my $EmailVacationTo = trim($q->param('EmailVacationTo'));
my ($toYear,$toMonth,$toDay) = ($EmailVacationTo =~ /(\d{4})-(\d{2})-(\d{2})/);
$EmailVacationTo = $toYear.$toMonth.$toDay;
# $EmailVacationTo =~ s/-//g; #Just take out "-".
if ($EmailVacationTo !~ m/^2[0-9]{3}[0|1][0-9][0-3][0-9]$/ and $EmailVacationFrom ne "") {return "vac_TO_DATE_INCORRECT";}
#Check not the same or From follows To.
if ($EmailVacationTo ne "" and $EmailVacationTo eq $EmailVacationFrom) {return "vac_DATES_THE_SAME";}
my $UnixFrom = mktime(0,0,0,$fromDay,$fromMonth,$fromYear);
my $UnixTo = mktime(0,0,0,$toDay,$toMonth,$toYear);
if ($UnixTo < $UnixFrom) {return "vac_TO_DATE_MUST_BE_LATER";}
my $new_message = $q->param('VacText');
my $vfile = "/home/e-smith/files/users/$user/.vacation.msg";
my $fullname = $adb->get_prop($user, "FirstName") . " " .
$adb->get_prop($user, "LastName");
my $from = 'From:';
my $away = $q->l('vac_AWAY_FROM_MAIL');
my $return = $q->l('vac_ANSWER_TO_OBJECT_SENDER');
my $vacation_text = "$from $fullname \<$user\@$domain\>\n"."Subject: $return\n".
"\n$away \n"."\n--\n$fullname";
my $reset = $vacation_text;
# if exists and is not empty
if (( -e $vfile ) && (! -z $vfile ))
{
open (VACATION, "<$vfile")
or die "Error: Could not open file: $vfile\n";
my @vacationTemp = <VACATION>;
$vacation_text = join ("", @vacationTemp);
close VACATION;
}
chomp $new_message;
# reset msg to default,
if ($new_message =~ /reset/)
{ $vacation_text = $reset; }
else
{
#or save new_message
unless ($new_message eq "")
{ $vacation_text = $new_message; }
}
# Strip out DOS Carriage Returns (CR)
$vacation_text =~ s/\r//g;
unlink $vfile;
open (VACATION, ">$vfile")
or die ("Error opening vacation message.\n");
print VACATION "$vacation_text";
close VACATION;
esmith::util::chownFile($user, $user,
"/home/e-smith/files/users/$user/.vacation.msg");
$adb->set_prop($user, 'EmailVacation', $EmailVacation);
$adb->set_prop($user, 'EmailVacationFrom', $EmailVacationFrom);
$adb->set_prop($user, 'EmailVacationTo', $EmailVacationTo);
#the first is more correct but is slower
#system ("/sbin/e-smith/signal-event", "email-update", $user) == 0
system ("/etc/e-smith/events/actions/qmail-update-user event $user") == 0
or die ("Error occurred updating .qmail\n");
if (($EmailVacation eq 'no') && ( -e "/home/e-smith/files/users/$user/.vacation"))
{
system ("/bin/rm /home/e-smith/files/users/$user/.vacation") == 0
or die ("Error resetting vacation db.\n");
}
return "OK";
}
sub trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
1;

View File

@@ -0,0 +1,63 @@
package SrvMngr::I18N::Modules::Uservacations::en;
use strict;
use warnings;
use utf8;
use Mojo::Base 'SrvMngr::I18N';
use SrvMngr::I18N::Modules::General::en;
my %lexicon = (
'vac_User vacations' =>'User vacations',
'vac_Vacation Message' =>'Vacation Message',
'vac_FORM_TITLE' =>'Change user vacation settings',
'vac_DESCRIPTION' =>' You can modify a users vacation message by clicking
on the link to the right of their name below.
',
'vac_LABEL_VACATION' =>'Vacation',
'vac_NO_FORWARDS'=>'No users found for forwarding',
'vac_VACATION_FROM' =>'Vacation starts on <br>(YYYY-MM-DD)',
'vac_VACATION_TO' =>'Vacation finishes on <br>(YYYY-MM-DD)',
'vac_VACATION_FROM1' =>'Vacation starts on',
'vac_VACATION_TO1' =>'Vacation finishes on',
'vac_MESSAGE' =>'Vacation message',
'vac_VACATION_STATUS' =>'Enable vacation messages',
'vac_FROM' =>'From:',
'vac_SUBJECT' =>'Subject:',
'vac_AWAY_FROM_MAIL' =>'I will not be reading my mail for a while. Your mail regarding $SUBJECT will be read when I return.',
'vac_NO_USERS_IN_GRANTED_GROUPS' =>'There are no users in the group(s) that you are granted to manage.',
'vac_ANSWER_TO_OBJECT_SENDER' => 'Re: $SUBJECT - Away from my email ',
'vac_FROM_DATE_INCORRECT'=>'From date must have YYYYMMDD format',
'vac_TO_DATE_INCORRECT'=>'To date must have YYYYMMDD format',
'vac_DATES_THE_SAME'=>"The Start and Finish dates cannot be the same",
'vac_TO_DATE_MUST_BE_LATER'=>"The Finish dates cannot be earlier than the Start date",
'vac_SUCCESS'=>'Vacation message saved sucessfully',
'vac_MODIFY_DESCRIPTION' =>'
<p>
Enter a vacation message here. You can use $SUBJECT
anywhere in the text to be replaced with the subject line
from the email that activated the auto-reply.</p>
<p>
This message must be composed of two parts separated by a blank line.
The first will be integrated into the headings of the email reply,
you must thus ensure you leave at least a blank line before typing your message.
The primary domain is added to the address automatically,or you can insert a virtual domain by replacing the domain part of the sender address
in the first line of the message with the virtual domain name (eg. replace the default From: user@primary.domain with From: user@virtual.domain).
To change the vacation message back to the default type reset.</p>
<p>
You can also fill out the Enable vacation on and Disable vacation on fields in order to
automatically enable and disable sending of the vacation message for this user account on the given dates.
</p>
<p>
The dates in the two fields must not be the same.<br>
If you want to use this functionality, leave the Enable vacation messages setting at No - it will be automatically activated based on the date given.
</p>'
);
our %Lexicon = (
%{ SrvMngr::I18N::Modules::General::en::Lexicon },
%lexicon
);
1;

View File

@@ -0,0 +1,55 @@
<div id='vac_add'>
% my $btn = l('ADD');
% if ($config->{debug} == 1) {
<p>
%= dumper $c->current_route
%= dumper $EmailVacation
</p>
% }
%= form_for '/Uservacations2' => (method => 'POST') => begin
<span class=label>
%=l 'ACCOUNT'
</span><span class=data>
%= $account
</span><br>
<span class=label>
%=l 'USER_NAME'
</span><span class=data>
%=$username
</span><br>
<span class=label>
%=$c->render_to_string(inline =>$c->l('vac_VACATION_FROM1'))
</span>
<span class=data>
%=date_field 'EmailVacationFrom' =>$EmailVacationFrom
</span><br>
<span class=label>
%=$c->render_to_string(inline =>$c->l('vac_VACATION_TO1'))
</span>
<span class=data>
%=date_field 'EmailVacationTo' =>$EmailVacationTo
</span><br>
<span class=label>
%=l 'vac_MESSAGE'
</span>
<span class=data>
% $VacText = b("$VacText");
%=text_area 'VacText' => $VacText, cols=>40, rows=>15
</span><br>
<span class=label>
%=l 'vac_VACATION_STATUS'
</span>
<span class=data>
% param EmailVacation => "$EmailVacation";
%=select_field EmailVacation =>[['Yes'=>'yes'],['No'=>'no']]
</span><br>
%= hidden_field 'account' => $account
%= submit_button "$btn", class => 'action'
%end
</div>

View File

@@ -0,0 +1,51 @@
<div id='vac_list'>
%# my $btn = l('vac_CREATE_RULE');
%= form_for '/Uservacations1' => (method => 'POST') => begin
<br><br>
% if ($empty){
<br>
%=l 'vac_NO_FORWARDS'
% } else {
<table class="sme-border TableSort"><thead>
<tr>
<th class='sme-border'>
%=l 'ACCOUNT'
</th>
<th class='sme-border'>
%=l 'USER_NAME'
</th>
<th class='sme-border'>
%=l 'vac_LABEL_VACATION'
</th>
<th class='sme-border'>
%=$c->render_to_string(inline =>l('vac_VACATION_FROM'))
</th>
<th class='sme-border'>
%=$c->render_to_string(inline =>l('vac_VACATION_TO'))
</th>
<th class='sme-border' '>
%=l 'ACTION'
</th>
</tr>
</thead><tbody>
% foreach my $vacation (@$vacations) {
<tr>
%= t td => (class => 'sme-border') => $vacation->{"User"}
%= t td => (class => 'sme-border') => $vacation->{"FullName"}
%= t td => (class => 'sme-border') => $vacation->{"status"}
%= t td => (class => 'sme-border') => $vacation->{"EmailVacationFrom"}
%= t td => (class => 'sme-border') => $vacation->{"EmailVacationTo"}
<td>
<a href="/smanager/Uservacations1?trt=ADD&account=<%= $vacation->{"User"}%>"><%=l 'MODIFY'%></a>
</td>
</tr>
%}
</tbody>
</table>
%}
% end
</div>

View File

@@ -0,0 +1,42 @@
% layout 'default', title => "Sme server 2 - User Vacations", share_dir => './';
% content_for 'module' => begin
<div id="module" class="module vacation-panel">
% if ($config->{debug} == 1) {
<p>
%= dumper $c->current_route
</p>
% }
<h1><%=$title%></h1>
%= $modul
%if ($vac_datas->{first}) {
<br>
%=$c->render_to_string(inline =>$c->l($vac_datas->{first}))
%} elsif ($vac_datas->{success}) {
<div class='"success"'>
<h2> Operation Status Report</h2>
%= $c->l($vac_datas->{success});
</div>
%} elsif ($vac_datas->{error}) {
<div class='sme-error'>
<h2> Operation Status Report - error</h2>
%= $c->l($vac_datas->{error});
</div>
%}
% if ($vac_datas->{trt} eq 'ADD') {
%= include 'partials/_vac_add'
%} elsif ($vac_datas->{trt} eq 'ADD1') {
%= include 'partials/_vac_add'
%} else {
%= include 'partials/_vac_list'
%}
</div>
%end