Gossamer Forum
Home : Products : Links 2.0 : Customization :

Suggest Custom Validate Email

Quote Reply
Suggest Custom Validate Email
Hi,

If the admin chooses to delete or reject a submission, the admin can customize the Delete email right on the spot.

It would be nice to be able to do the same thing with Validate and Modify, as well.

It could be used to tell the submitter of something special on your site, etc. I had to separately write to someone to tell them of a certain webring that I thought they might like to join. It would have been easier if I could have written it at the time I validated their submission.

Anybody know how to set this up?

Many Thanks.

------------------
www.armynavy.com/

[This message has been edited by TrainedMonkey (edited August 15, 1999).]
Quote Reply
Re: Suggest Custom Validate Email In reply to
what about the email-add.html template

modify it right from the admin console
Quote Reply
Re: Suggest Custom Validate Email In reply to
Ok, I got this working with me, hold on a sec so i remember what i did

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
webmaster@lh.yi.org
Quote Reply
Re: Suggest Custom Validate Email In reply to
 It took me 10 minutes to do this so it should take you about 4-5 minutes to add it.

In admin_html.pl in the
Code:
sub html_validate_form {
# --------------------------------------------------------
part, find these lines(Just look for the first one $reason, treason was something else i was doing)

Code:
my $reason = &load_template ('email-del.txt', \%tmp);
my $treason = &load_template ('email-del2.txt', \%tmp);
add this right after:
Code:
my $emailadd = &load_template ('email-add.txt', \%tmp);
then go down a little bit until you find where it says input name = radio for the validate, add this to the end:
Code:
<textarea name="emailadd-$tmp{$db_key}" rows=4 cols=40>$emailadd</textarea><br>


Then go down to the EMAIL MESSAGES section in this subroutine
Code:
sub html_validate_email {
where you find my $msg = whatever it said, replace what it says with
Code:
$in{"emailadd-$link{$db_key}"};

I think that should be it, but if its not write back here and i'll tell you some things i left. I left them out because it took me a while to realize why it wasn't emailing. Then i remember i turned off the send email thing in links.cfg. Smile. Oh if you have trouble with the tables in the
Code:
<textarea name="emailadd-$tmp{$db_key}" rows=4 cols=40>$emailadd</textarea><br>
part, just add <TR> at the beginning where the input type radio button text begins. That should put it on a new line. Good Luck.

------------------
------------------------------------------
Lavon Russell
LookHard! Search
www.lh.yi.org
webmaster@lh.yi.org


[This message has been edited by Bmxer (edited August 15, 1999).]
Quote Reply
Re: Suggest Custom Validate Email In reply to
Thanks a ton, Lavon, and thanks for all the detail.

I'll give it a shot. It'll take me a little more than 4 or 5 mins, though, I'm sure.

------------------
http://www.armynavy.com/
Quote Reply
Re: Suggest Custom Validate Email In reply to
Super Duper,Lavon!

Here are the sections of code for those who need it.

This first part takes care of $my reason and textarea. I just copied the whole table so you could cut and paste:

<table border=1><TR><TD colspan=2>|;
&html_record_form_mult (%tmp);
my $reason = &load_template ('email-del.txt', \%tmp);
my $emailadd = &load_template ('email-add.txt', \%tmp);
print qq|
</TD></TR>
<TR><TD VALIGN=TOP><INPUT TYPE="RADIO" NAME="$tmp{$db_key}" VALUE="validate"> <$font><a href="$tmp{'URL'}" target="_blank">Validate</a></font> <textarea name="emailadd-$tmp{$db_key}" rows=4 cols=40>$emailadd</textarea><br>
</TD></TR>
<TR><TD VALIGN=TOP ROWSPAN=2><INPUT TYPE="RADIO" NAME="$tmp{$db_key}" VALUE="delete"> <$font>Delete. Email Reason:</font><br> <textarea name="reason-$tmp{$db_key}" rows=4 cols=40>$reason</textarea>
</TD>
</TR>
<TR><TD VALIGN=TOP><$font><a href="$db_script_url?view_records=1&$db_cols[$db_url]=$tmp{$db_cols[$db_url]}" target="_blank">Duplicate Check</a></font></TD></TR>
</TABLE>


The second part takes care of the email:

sub html_validate_email {
# --------------------------------------------------------
# All the link information is stored in %link.
my (%link) = @_;

# Set the to, from, subject and message to send.
my $to = $link{'Contact Email'};
my $from = $db_admin_email;
my $subject = "Your link has been added!";
my $msg = $in{"emailadd-$link{$db_key}"};

# Then mail it away!
require "$db_lib_path/Mailer.pm";
my $mailer = new Mailer ( { smtp => $db_smtp_server,
sendmail => $db_mail_path,
from => $from,
subject => $subject,
to => $to,
msg => $msg,
log => $db_mailer_log
} ) or
&cgierr("Unable to init mailer! Reason: $Mailer::error");
$mailer->send or &cgierr ("Unable to send addition message. Reason: $Mailer::error");
}


I think that's it. Make sure you make a backup before modifying anything.

Thanks, again, Lavon. This is a nice addition.



------------------
http://www.armynavy.com/
Quote Reply
Re: Suggest Custom Validate Email In reply to
This little mod takes me about halfway where I need to go...

I am using one installation of links as a job board directory. My association has requested that we allow recruiter job postings with a nominal fee; however, others may post for free. Therefore, I have two different validation emails - one that just confirms the addition and one that sends an invoice. I could use this modification and just cut and paste the text in for the invoice; however, it would be nice if I could just check the correct letter (with radio button choices) and have it send the appropriate email. I'm wondering, Bmxer, with your reference to $reason and $treason, if this is something you've done and could offer some pointers on getting the correct email to send. I've already put the text area, etc in for the additional validate choice; I just don't know what I need to do to get the html_validate_email sub send the correct message.

Any help would be appreciated. Thanks!

Melanie
Quote Reply
Re: Suggest Custom Validate Email In reply to
Do you want it to load both templates in their own textarea like this mod does, and then be able to edit them, from the admin, and send one or the other. or do you want it to load both templates in their own textarea like this mod does, and then be able to edit them,
and when you submit, send both?

I have a thought for the first one, the second one is easy.


------------------
LookHard Search
lookhard.hypermart.net
Lavon Russell
Quote Reply
Re: Suggest Custom Validate Email In reply to
I would like to be able to send one or the other, but not both. It would be nice to be able to load them both and then I can edit as necessary and select the appropriate one to be sent. I suppose another option is to build into the add form (and in the db) a "recruiter" field, then if that is checked/selected, pull the appropriate email. I was thinking, though, that what you have below, with a few modifications would be easier to accomplish and serve my needs, plus relying on a "recruiter" field to load the correct email template is only as reliable as the person completing the job postings form.

Melanie
Quote Reply
Re: Suggest Custom Validate Email In reply to
I added this MOD and it doesn't send the email for Validate (yes I have my SMTP set correctly and eveything in that area) I tested the Rejected letter and that is sent ok.

I put everything exactly as it was shown.

Anyone have a clue as to why I don't receive an email?

Thank you Smile
Quote Reply
Re: Suggest Custom Validate Email In reply to
Just pulling this thread to the top. Smile

Melanie
Quote Reply
Re: Suggest Custom Validate Email In reply to
Jerri,

Did you already found a sollution?
Quote Reply
Re: Suggest Custom Validate Email In reply to
Bmxer (or someone else), have you given any more thought to this? You mentioned having an idea. I still need to find a way to have two different validation letters and be able to select which one I want to send on the fly. If not, I can probably make the code work by maintaining a copy of the second letter and just copying and pasting it in when it's needed. That just seems a somewhat cumbersome option. I'd appreciate any help you could offer on this. Thanks!

Melanie
Quote Reply
Re: Suggest Custom Validate Email In reply to
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'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ &#0124; &#0124;
${$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'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ &#0124; &#0124;
${$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