Show import_complete.html syntax highlighted
% # vim:set syntax=mason:
<%args>
$data => ''
$fn => 0
$ln => 0
$em => 0
$al => 0
</%args>
<& /mail/header.mhtml, title => 'Choose email address' &>
<P>Uncheck any address you don't want to import, edit any aliases that you want to change, then press Save. Duplicate aliases will automatically have a number appended onto them during the save.</P>
<form method="post" action="/mail/addressbook/import_csv_save.html">
<div class="control">
<input type="submit" name="save" value="Save">
<input type="submit" name="cancel" value="Cancel">
</div>
<table class="import_verify">
<tr>
<th>
Import
</th>
<th>
Alias
</th>
<th>
Entry
</th>
</tr>
<%perl>
my ($address, $fname, $lname, $alias, @ao);
open DATA, "<$data";
my @lines = <DATA>;
close DATA;
@lines = sort { lc($a) cmp lc($b) } @lines;
my $line = 0;
for my $n (@lines) {
$logger->debug("Line $n");
$_ = $n;
my @fields = split /,/;
$alias = $fields[$al];
$fname = $fields[$fn];
$lname = $fields[$ln];
if(!$alias) { # attempt to make an alias if none exists
if($fname) {
$alias = lc($fname);
if($alias =~ m/^(\S*)\s.*$/) {
$alias = $1;
}
}
if(!$alias) {
$fields[$em] =~ m/^([^@]*)\@/;
$alias = $1;
}
}
@ao = Email::Address->parse($fields[$em]);
if(!$alias || !@ao) {
</%perl>
<tr>
<td colspan="3">
Skipped entry: (<% "$fname $lname" |h %>)
</td>
</tr>
<%perl>
next;
}
if($#ao > 0) {
$address = "";
for my $a (@ao) {
my $obj = new Email::Address(undef, $a->address);
$address .= $obj->format . ", ";
}
$address =~ s/,\s*$//;
} else {
my $obj = new Email::Address("$fname $lname", $ao[0]->address);
$address = $obj->format;
}
</%perl>
<tr>
<th>
<input type="checkbox" name="line" value="<% $line %>" checked>
</th>
<th>
<input type="text" name="alias" size="15" value="<% $alias |h %>">
</th>
<th>
<input type="text" name="entry" size="50" value="<% $address |h %>">
</th>
</tr>
<%perl>
$line++;
}
</%perl>
</table>
</form>
<& /mail/footer.mhtml &>
<%once>
use Email::Address;
our $logger = Log::Log4perl->get_logger('alphamail');
</%once>
See more files for this project here