AcePerl

 view release on metacpan or  search on metacpan

acebrowser/cgi-bin/misc/feedback  view on Meta::CPAN

            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;
    push @missing,"At least one message recipient"
	unless  @addresses;
    push @missing,"Your full name (needed for proper attribution)"
	unless my $name = param('full_name');
    push @missing,"Your institution (needed for proper attribution)"
	unless my $institution = param('institution');
    push @missing,"Your e-mail address"     
	unless my $from = param('from');
    push @missing,"A properly formatted e-mail address"
	if $from && $from !~ /.+\@[\w.]+/;
    push @missing,"A subject line"          
	unless my $subject = param('subject');
    push @missing,"A comment or correction" 
	unless my $remark = param('remark');
    if (@missing) {
	print
	    p({-class=>'error'},
	      "Your submission could not be processed because",
	      "the following information was missing:"),
	    ol({-class=>'error'},
	       li(\@missing)),
	    p({-class=>'error'},
	      "Please fill in the missing fields and try again.");
	return;
    }


    my $error = <<END;
Unable to send mail.  Please try again later.  
If the problem persists, contact the site\'s webmaster.
END
    ;
    unless (open (MAIL,"|/usr/lib/sendmail -oi -t")) {
	AceError($error);
	return;
    }
    my $to = join(", ",@addresses);
    print MAIL <<END;
From: $from ($name via ACEDB feedback page)
To: $to
Subject: $subject

Full name:   $name
Institution: $institution
Address:     $from

DATABASE RECORD: $obj_class: $obj_name

SUBMITTED FROM PAGE: $where_from

COMMENT TEXT:
$remark
END
    ;
    
    unless (close MAIL) {
	AceError($error);
	return;
    }
    return 1;
}

sub print_confirmation {
    print 
	p("Thank you for taking the time to submit this information.",
	  "Please use the buttons below to submit more reports or to",
	  "return to the database.",
	  ),
	start_form,
	submit(-name=>'restart',-label=>'Submit Another Report'),
	hidden('referer'),
	submit(-name=>'return',-label=>'Return to Database'),
	end_form;
}



( run in 0.765 second using v1.01-cache-2.11-cpan-140bd7fdf52 )