Okay, figured it out! If there are others who have primarily 2 different validation letters to send, and you'd like to be able to select one or the other without having to modify the text on the fly every time, here's how to do it. (This is for template users only.) Building on the code Bmxer provided above:
after the code he provided:
Code:
my $emailadd = &load_template ('email-add.txt', \%tmp);
ADD:
Code:
my $emailadd2 = &load_template ('email-add2.txt', \%tmp);
AFTER the code he gives in the radio button section:
Code:
<textarea name="emailadd-$tmp{$db_key}" rows=4 cols=40>$emailadd</textarea><br>
ADD:
Code:
<TR><TD VALIGN=TOP><INPUT TYPE="RADIO" NAME="$tmp{$db_key}" VALUE="validate2"> <$font><a href="$tmp{'URL'}" target="_blank">Validate 2</a></font> <textarea name="emailadd2-$tmp{$db_key}" rows=4 cols=40>$emailadd2</textarea><br>
</TD></TR>
Then COPY the sub html_validate_email routine and RENAME the NEW subroutine
sub html_validate_email2
In the sub html_validate_email2 routine:
CHANGE:
Code:
my $msg = $in{"emailadd-$link{$db_key}"};
TO:
Code:
my $msg = $in{"emailadd2-$link{$db_key}"};
That's it for admin_html.pl. THEN go to
db.pl and make the following changes:
find the subroutine
sub validate_records { Replace:
Code:
my ($rec_to_delete, $rec_to_validate, $rec_to_modify,
%delete_list, %validate_list, %modify_list, %links,
@lines, @data, $id, $first, $last, $errstr, $output);
With:
Code:
my ($rec_to_delete, $rec_to_validate, $rec_to_validate2, $rec_to_modify,
%delete_list, %validate_list, %validate_list2, %modify_list, %links,
@lines, @data, $id, $first, $last, $errstr, $output);
After:
Code:
($in{$key} eq "validate") and $validate_list{$key} = 1 and $rec_to_validate = 1;
Add:
Code:
($in{$key} eq "validate2") and $validate_list2{$key} = 1 and $rec_to_validate2 = 1;
After:
Code:
# If there isn't anything to do, let's complain.
Replace:
Code:
if (!$rec_to_validate and !$rec_to_delete and !$rec_to_modify) {
With:
Code:
if (!$rec_to_validate and !$rec_to_validate2 and !$rec_to_delete and !$rec_to_modify) {
After:
Code:
# Let's go through the validation file and remove all the ones
# we want to validate as well as all the ones we want to delete.
Replace:
Code:
if ($rec_to_validate or $rec_to_delete) {
With:
Code:
if ($rec_to_validate or $rec_to_validate2 or $rec_to_delete) {
After:
Code:
if ($delete_list{$id}) { $delete_list{$id} = 0; }
elsif ($validate_list{$id}) { $validate_list{$id} = 2; }
Add:
Code:
elsif ($validate_list2{$id}) { $validate_list2{$id} = 2; }
After:
Code:
if ($rec_to_validate) {
open (DB, ">>$db_file_name") or &cgierr("error in validate_records, unable to open db file: $db_file_name. Reason: $!");
flock(DB, 2) if ($db_use_flock);
foreach $id (keys %validate_list) {
if ($validate_list{$id} == 2) {
print DB &join_encode(%{$links{$id}});
$validate_list{$id} = 0;
}
}
close DB;
}
Add:
Code:
if ($rec_to_validate2) {
open (DB, ">>$db_file_name") or &cgierr("error in validate_records, unable to open db file: $db_file_name. Reason: $!");
flock(DB, 2) if ($db_use_flock);
foreach $id (keys %validate_list2) {
if ($validate_list2{$id} == 2) {
print DB &join_encode(%{$links{$id}});
$validate_list2{$id} = 0;
}
}
close DB;
}
After:
Code:
foreach $key (keys %validate_list) {
if ($validate_list{$key}) { $errstr .= "<li>Validate Error: <strong>$key</strong>. Couldn't find record in validation database."; }
else { $valsuc .= "$key,"; }
}
Add:
Code:
foreach $key (keys %validate_list2) {
if ($validate_list2{$key}) { $errstr .= "<li>Validate Error: <strong>$key</strong>. Couldn't find record in validation database."; }
else { $valsuc .= "$key,"; }
}
After:
Code:
if ($db_email_add) {
ID: foreach $id (keys %validate_list) {
if ($validate_list{$id}) { next ID; }
elsif (${$links{$id}}{'Job Poster Email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ | |
${$links{$id}}{'Job Poster Email'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
$errstr .= ($errstr, "<li>Email Error: <strong>$id</strong>. Record validated, but couldn't send auto email. Reason: Bad Email addres: '${$links{$id}}{'Contact Email'}'.");
}
else { &html_validate_email (%{$links{$id}}); }
}
Add:
Code:
ID: foreach $id (keys %validate_list2) {
if ($validate_list2{$id}) { next ID; }
elsif (${$links{$id}}{'Job Poster Email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ | |
${$links{$id}}{'Job Poster Email'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
$errstr .= ($errstr, "<li>Email Error: <strong>$id</strong>. Record validated, but couldn't send auto email. Reason: Bad Email addres: '${$links{$id}}{'Contact Email'}'.");
}
else { &html_validate_email2 (%{$links{$id}}); }
}
}
Then create a new email text template, called email-add2.txt and upload it to your templates folder.
This should allow you to choose between two validate email letters, as well as allow you to modify either letter on the fly.
Melanie