Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[NEW PLUGIN] RNotifier

(Page 2 of 2)
> >
Quote Reply
Re: [Matthias70] [NEW PLUGIN] RNotifier In reply to
NOW this is interesting!

It looks like this hook gets called 3 times!

Code:
'hooks' => [
[
'validate_review',
'POST',
'Plugins::RNotifier::add_review',
'1'
]
],
I add this code in:

Code:
sub add_review {

my @args = @_;

print $IN->header if $DEBUG > 0;

my $args = $IN->get_hash();
my @ids;
while (my ($key, $param) = each %$args) {
if ($key =~ /^(\d+)-ReviewID/) {
push @ids, $1;
}
}


#tools_validate_reviews.html
print "FOO: " . $IN->param('do') . "<br />";

..and it prints out the following:
Code:
FOO: page
FOO: page
FOO: page

Very weird! Gonna email GT, to see if this is a bug they have fixed up (or are unaware of)

Will let you know once I hear something back.

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] [NEW PLUGIN] RNotifier In reply to
I'm glad that you found the problem. Just thought it's only my problem Frown

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [NEW PLUGIN] RNotifier In reply to
Yeah

I'm wondering if its maybe due to being the wrong hook (although not sure what the right one would be) ... as I think when someone "adds" (or a review is validated), that review_add hook gets called - could be wrong though.

Will keep you posted once I hear back from GT

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] [NEW PLUGIN] RNotifier In reply to
Hi Andy,
do you have any updates on this problem?
My user are posting more and more reviews and I have still this problem?

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [NEW PLUGIN] RNotifier In reply to
The only way I've managed to come up with since then, is to add a new field to the "Reviews" table called ReviewEmailBeenSent = 1/0

Then, when the review has been procesed, we set it to 1, and then have some code that stops it being run again

However, this was on a modified version - so dont think that would work on your install :(

Would be nice if GT could come up with a specific hook, for the "overall" review validation system , instead of just 1 that gets run for every single review (i.e you validate 6 reviews, and it gets run 6 times :()

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] [NEW PLUGIN] RNotifier In reply to
Hi Andy,
I thought Adrian posted already a fix for this.
I was waiting for a GT Links Update and now I even can't find the fix anymore...

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [NEW PLUGIN] RNotifier In reply to
Hi,

If you find it, let me know - and I'll have another look (pretty busy atm, so not sure when I will have time to look at it :()

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] [NEW PLUGIN] RNotifier In reply to
Andy wrote:
NOW this is interesting!

It looks like this hook gets called 3 times!

Code:
'hooks' => [
[
'validate_review',
'POST',
'Plugins::RNotifier::add_review',
'1'
]
],

Why is this weird? The validate_review hook is used for both the admin as well as the browser interfaces, where one validates multiple reviews and the other validates a single review. The hook is supposed to run for each review, not once for all reviews.

Adrian
Quote Reply
Re: [Matthias70] [NEW PLUGIN] RNotifier In reply to
Matthias70 wrote:
Hi Andy,
I thought Adrian posted already a fix for this.
I was waiting for a GT Links Update and now I even can't find the fix anymore...

I looked through the recent commits and don't see anything. I also don't recall looking into this issue before.

Adrian
Quote Reply
Re: [brewt] [NEW PLUGIN] RNotifier In reply to
Right ok, so how exactly are you meant to get the values from that hook?

Cos I just changed that function to:

Code:
sub add_review {

my @args = @_;

use Data::Dumper;
print $IN->header;
print Dumper(@_) . "\n\n\n\n";;


return @_;

}

..and then validated 2 reviews - yet nothing was outputted.

If its run every single time a review is validated, there must be a way to grab the data? Wink

TIA

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] [NEW PLUGIN] RNotifier In reply to
Well, just like any POST hook, you only get the return of the function as input to your hooked function. For validate_review, it doesn't actually return anything, so you get undef. Either you parse $IN for the info you need (won't work in this situation), or you set up a PRE hook to grab the input you need.

Adrian
Quote Reply
Re: [brewt] [NEW PLUGIN] RNotifier In reply to
Ah ok - so using a PRE hook should pass in the data from JUST 1 review? (and then it gets run every review that is validated/rejected) .. or am I mis-understanding?

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] [NEW PLUGIN] RNotifier In reply to
Hm, I don't understand what you are talking about Whistle
but it sounds, that you are close to a solution...

Matthias
gpaed.de
Quote Reply
Re: [Andy] [NEW PLUGIN] RNotifier In reply to
For the validate_review hook, the review_id is what gets passed to the function. Save that in a PRE hook, and then in the POST hook, grab that review and check its status to see what was done to it.

Adrian
> >