Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Review.pm suggestion

Quote Reply
Review.pm suggestion
Hi,

just wanted to add this for the remaining visitors and at least to say hello to Andy.
I started to work a little with reviews and have a suggestion addon for the code.
In "sub _add_this_review" I added:

Code:
if (not $CFG->{user_review_required} and not $USER) {
$input->{Review_GuestName} or return { error => Links::language('REVIEW_GUEST_NAME_REQUIRED') };
$input->{Review_GuestEmail} or return { error => Links::language('REVIEW_GUEST_EMAIL_REQUIRED') };
#start ++
unless ($input->{Review_GuestEmail} =~ /.\@.+\../) {
return {error => Links::language('USER_INVALIDEMAIL', $input->{Review_GuestEmail})};
}
my $rc = $reviews->count({ Review_LinkID => $id, Review_GuestEmail => $input->{Review_GuestEmail} });
if ($CFG->{review_max_reviews} and $rc + 1 > $CFG->{review_max_reviews}) {
my $mtl = Links::Build::build('title', Links::language('LINKS_REVIEW_ADD'), "$CFG->{db_cgi_url}/review.cgi");
print Links::SiteHTML::display('error', { error => Links::language('REVIEW_MAX_REVIEWS', $CFG->{review_max_reviews}), main_title_loop => $mtl });
return;
}
#end ++
}

I thought it makes sense to validate the E-Mail as much as for user registration and restrict the nubers of reviews for the same E-Mail as well.
Still a lot to improve but I like the basic work.

Regards

niko

Last edited by:

el noe: Dec 9, 2016, 5:58 AM
Quote Reply
Re: [el noe] Review.pm suggestion In reply to
Thanks. What exactly is this mean't to do though? I'm confused :) The way I'm reading it, it will stop them from adding more than the maximum allowed reviews for a link (if they are a guest). Is that correct?

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] Review.pm suggestion In reply to
Hey Andy,

Right, there is a routine which prevents logged in users from adding more than $CFG->{review_max_reviews} reviews.
I wanted to add this restriction for guest users based on their E-Mail address as well.
Furthermore the E-Mail Validation in Login.pm is very basic but I wanted to add at least the same to the reviews which resulted in
Code:
$input->{Review_GuestEmail} =~ /.\@.+\../
rather than having none.

Regards

Niko
Quote Reply
Re: [el noe] Review.pm suggestion In reply to
Ah ok Angelic Thanks for sharing

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!