AcePerl
view release on metacpan or search on metacpan
acebrowser/cgi-bin/misc/feedback view on Meta::CPAN
# This page called with the parameters:
# recipients- numeric index(es) for recipients of message
# name - name of object to update
# class - class of object to update
# from - sender's e-mail address
# subject - subject of mail message
# remark - body of e-mail message
my $object_name = param('name');
my $object_class = param('class');
my $where_from = param('referer') || referer();
if (param('return') && $where_from !~ /\/feedback/ ) {
print redirect($where_from);
exit 0;
}
PrintTop(undef,undef,'Feedback Page');
if (Configuration->Feedback_recipients) {
@FEEDBACK_RECIPIENTS = @{Configuration->Feedback_recipients};
if (param('submit') && send_mail($object_name,$object_class,$where_from)) {
print_confirmation();
} else {
print start_form;
print_instructions();
print_form( $object_name,$object_class,DB_Name(),$where_from );
print end_form;
}
} else {
print p("No recipients for feedback are defined.");
print start_form(),
hidden(-name=>'referer',-value=>$where_from),br,
submit(-name=>'return',-value=>'Cancel & Return',-class=>'error'),
end_form();
}
PrintBottom;
sub print_top {
my $title = 'Data Submissions and Comments';
print start_html (
'-Title' => $title,
'-style' => Style(),
),
Header,
h1($title);
}
sub print_instructions {
my @defaults;
for (my $i=0; $i<@FEEDBACK_RECIPIENTS; $i++) {
push @defaults,$i if $FEEDBACK_RECIPIENTS[$i][2];
}
print
p({-class=>'small'},
"Use this form to send new data or corrections to",
"the maintainers of this database. An e-mail message",
"will be sent to the individuals selected from the list",
"below."),
blockquote({-class=>'small'},
checkbox_group(-name => 'recipients',
-Values => [(0..$#FEEDBACK_RECIPIENTS)],
-Labels => { map {
$_=>"$FEEDBACK_RECIPIENTS[$_]->[0] ($FEEDBACK_RECIPIENTS[$_]->[1])"
} (0..$#FEEDBACK_RECIPIENTS) },
-defaults=>\@defaults,
-linebreak=>1));
}
sub print_bottom {
print Footer;
}
sub print_form {
my ($name,$class,$db,$where_from) = @_;
print
table(
TR(th({-align=>'RIGHT'},"Your full name:"),
td({-align=>'LEFT'},textfield(-name=>'full_name',-size=>40))),
TR(th({-align=>'RIGHT'},"Your institution:"),
td({-align=>'LEFT'},textfield(-name=>'institution',-size=>40))),
TR(th({-align=>'RIGHT'},"Your e-mail address:"),
td({-align=>'LEFT'},textfield(-name=>'from',-size=>40))),
TR(th({-align=>'RIGHT'},"Subject:"),
td({-align=>'LEFT'},textfield(-name=>'subject',
-value=>$class && $name ?
"Comments on $class $name ($db db)": '',
-size=>60))),
TR(th({-colspan=>2,-align=>'LEFT'},'Comment or Correction:')),
TR(td({-colspan=>2},textarea(-name=>'remark',
-rows=>12,
-cols=>80,
-wrap=>'VIRTUAL'
))),
),
hidden(-name=>'name',-value=>$name),
hidden(-name=>'class',-value=>$class),
hidden(-name=>'db',-value=>$db),
hidden(-name=>'referer',-value=>$where_from),br,
submit(-name=>'return',-value=>'Cancel & Return',-class=>'error'),
submit(-name=>'submit',-value=>'Submit Data');
}
sub send_mail {
my ($obj_name,$obj_class,$where_from) = @_;
$obj_name ||= '(unknown name)';
$obj_class ||= '(unknown class)';
$where_from ||= '(unknown)';
my @addresses = map { $FEEDBACK_RECIPIENTS[$_] ?
$FEEDBACK_RECIPIENTS[$_]->[0]
: () } param('recipients');
my @missing;
( run in 1.520 second using v1.01-cache-2.11-cpan-39bf76dae61 )