Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Email link owner - reviewed added (again ;)

Quote Reply
Email link owner - reviewed added (again ;)
Hi,

Im interested in setting up a auto email feature when a review is added.

here's what i've got so far im my Review.pm - (basically duplicating the mail admin if a review has been posted for validation)

Code:
#Email link owner
if ($CFG->{email_review_comment}) { # Field added to Links Table (Yes, No - 1,0) If the link owner has requested to be kept up to date on reviews
my $to = $CFG->{Contact_Email};
my $from = $CFG->{db_admin_email};
my $subject = "Review posted on your site ". $CFG->{title};
my $cfg = Links::Config::load_vars();
my $msg = GT::Template->parse ( 'review-email-val.txt', { %$input, %$cfg, %$rec}, { compress => 0, root => $CFG->{admin_root_path} . '/templates/admin' } );
require GT::Mail;
$GT::Mail::error ||= ''; # Silence -w
GT::Mail->send (
smtp => $CFG->{db_smtp_server},
sendmail => $CFG->{db_mail_path},
from => $from,
subject => $subject,
to => $to,
msg => $msg,
debug => $Links::DEBUG
) or die "Unable to send mail: $GT::Mail::error";
}


Im struggling to figure how to query the Links table for the Contact_Email and Title values (also the custom column i've added email_review_comment) from within Review.pm - is this possable?



thanks for your help,



Charlie

Edit: I see someone's posted a method for doing this here: http://gossamer-threads.com/perl/gforum/gforum.cgi?post=196993 which seems to be using $input->{Contact_Email}"; # I take it this is using a hidden field within the post review form - if so the posters leaving a route for spam bots to harass there users :(



Comedy Quotes - Glinks 3.3.0, PageBuilder, StaticURLtr, CAPTCHA, User_Edit_Profile

Last edited by:

Chas-a: Sep 8, 2003, 11:32 AM
Quote Reply
Re: [Chas-a] Email link owner - reviewed added (again ;) In reply to
Sorry, I'm not sure about your main question, but regarding;

Quote:
which seems to be using $input->{Contact_Email}"; # I take it this is using a hidden field within the post review form - if so the posters leaving a route for spam bots to harass there users :(

Looks more like it is calling a table reference. A normal CGI.pm input variable calls a submitted value with something like;

$input->param('Contact_Email')

... the code you showed, seem to be a hashref, which was grabbed from the LSQL tables (most likely by reading the Links ID, which was passed along,and then checking for the Contact_Email address through the database).

Sorry I couldn't be of any help on your main question.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Email link owner - reviewed added (again ;) In reply to
Hi Andy,

Quote:


I'm not sure about your main question


What im basically after is setting up the Review.pm script to email the Link owner when a registered user posts a review on one of there links.

I see within the un-edited version of the Review.pm file there a built in function for emailing the sites admin to let them know there's a review waiting for validation, detailed here:

Code:
# Mail the email.
if ($CFG->{admin_email_add}) {
my $to = $CFG->{db_admin_email};
my $from = $USER->{Email} || $to;
my $subject = Links::language ('REVIEW_EMAIL_ADD', $input->{Review_Subject})."\n";
my $cfg = Links::Config::load_vars();
my $msg = GT::Template->parse ( 'review-email-val.txt', { %$input, %$cfg, %$rec}, { compress => 0, root => $CFG->{admin_root_path} . '/templates/admin' } );
require GT::Mail;
$GT::Mail::error ||= ''; # Silence -w
GT::Mail->send (
smtp => $CFG->{db_smtp_server},
sendmail => $CFG->{db_mail_path},
from => $from,
subject => $subject,
to => $to,
msg => $msg,
debug => $Links::DEBUG
) or die "Unable to send mail: $GT::Mail::error";
}


Which if im understanding this correct does the following:

if ($CFG->{admin_email_add}) { # Check if admin_email_add under Setup > Email Options is set to 1 (yes)

if it is, email all the info to $CFG->{db_admin_email}; # admin email address with all the details of the review.

The trouble im having is figuring out how to exchange the $CFG->{db_admin_email}; with the Link owners email address from the Links Table i.e. the Contact_Email value

Quote:


Looks more like it is calling a table reference. A normal CGI.pm input variable calls a submitted value with something like;

$input->param('Contact_Email')

... the code you showed, seem to be a hashref, which was grabbed from the LSQL tables (most likely by reading the Links ID, which was passed along,and then checking for the Contact_Email address through the database).


Hacking the Review.pm file it looks like the link id being called as follows:

my $id = $IN->param('ID');

# Check if we have a valid ID
my $db = $DB->table('Links');
my $rec = $db->get ($id);

and using the time honoured non programmer trial and error method i would have thought using :

my $owner_email = $IN->param('Contact_Email');
my $to = $db->get ($owner_email);

would give me this link owners email.

Any pointers in the right direction?

Thanks!



Comedy Quotes - Glinks 3.3.0, PageBuilder, StaticURLtr, CAPTCHA, User_Edit_Profile

Quote Reply
Re: [Chas-a] Email link owner - reviewed added (again ;) In reply to
You would need to call it with something like this;

Code:
my $Email_Send;
my $table = $DB->table('Links');
my $sth = $table->select( { ID => $input->{ID} } );

while (my $hit = $sth->fetchrow_hashref) {
$Email_Send = $hit->{Contact_Email};
}

# youshould then have the Contact_Email value helf in $Email_Send

The above is untested, but it should give you an idea :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Chas-a] Email link owner - reviewed added (again ;) In reply to
Try changing $CFG to $rec. $rec should hold all the Link information.
Quote Reply
Re: [afinlr] Email link owner - reviewed added (again ;) In reply to
Hi Laura,

Your right, $rec holds all the links table info :-)

cheers for your help both of you.



Comedy Quotes - Glinks 3.3.0, PageBuilder, StaticURLtr, CAPTCHA, User_Edit_Profile