Gossamer Forum
Quote Reply
"activity check"-global
Hi Andy,
just want to remember you on this global idea Whistle

Quote:
Matthias70 wrote:
Is there a way to check the time, when a user added a link or added a review.
Should be used like this:
<%if last_link older 1year and last review older than 1year%>
It's been a long time, what about supporting the community. Write a review or add a new link...
<%endif%>

Andy wrote:
Sure, could be done - but afraid I don't have time to do anything like that at the moment =) Would just need to grab the latest LinkID and ReviewID, and then do a GT::Date::date_diff() to see how many days ago that was :)
Would be great, if you can find some time...
Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] "activity check"-global In reply to
heheh - still a bit busy ;) If you remind me in a weeks time, I may be able to have a look at it.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] "activity check"-global In reply to
Hi Andy, just to remind you Wink

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] "activity check"-global In reply to
haha you don't give up :D

Try this:

get_last_additions_for_user
Code:
sub {

my $last_review_date = $DB->table('Reviews')->select( ['MAX(Review_Date)'], { Review_Owner => $_[0] } )->fetchrow;
my $last_link_date = $DB->table('Links')->select( ['MAX(Add_Date)'], { LinkOwner => $_[0] } )->fetchrow || GT::Date::date_get();

my @last_review_date = split / /, $last_review_date;
$last_review_date = $last_review_date[0] || GT::Date::date_get();

my $date_diff_review = GT::Date::date_diff($last_review_date,GT::Date::date_get());
my $date_diff_link = GT::Date::date_diff($last_link_date,GT::Date::date_get());

return {
days_since_last_review => $date_diff_review,
days_since_last_link => $date_diff_link
}

}

Then call with:

Code:
<%get_last_additions_for_user($LinkOwner)%>

..or if doing it for the logged in user, try:

Code:
<%get_last_additions_for_user($user.Username)%>

Then you should have access to <%days_since_last_review%> and <%days_since_last_link%>

(they hold the number of days since the last link/review was added)

Please note, this is untested - but should work fine Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Jul 1, 2010, 11:02 AM
Quote Reply
Re: [Andy] "activity check"-global In reply to
Hi Andy,
yes I never give up Wink
but now I'm getting this error...
Code:
Unable to compile 'get_last_additions_for_user': Global symbol "@last_review_date" requires explicit package name at (eval 45) line 6.
Global symbol "@last_review_date" requires explicit package name at (eval 45) line 7.
Unknown Tag: 'days_since_last_review'
Unknown Tag: 'days_since_last_link'

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] "activity check"-global In reply to
Oops, try the modified version above ;)

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] "activity check"-global In reply to
Andy wrote:
Oops, try the modified version above ;)

Hi Andy,
great, now I have an output of the days.
I will test and play around with this global.
I think this is a great global for communities...

Thanks a lot

Matthias
gpaed.de
Quote Reply
Re: [Andy] "activity check"-global In reply to
Hi Andy,
there is one problem.
The output is negative!
It shows -365 days since your last review...
Is there a way to get just the number?

Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] "activity check"-global In reply to
you probably need to reverse the variables in date_diff(). I coded it in a bit of a rush :)

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] "activity check"-global In reply to
Andy wrote:
you probably need to reverse the variables in date_diff(). I coded it in a bit of a rush :)

Hi Andy,
did you mean this part.
Did I reverse them right?

Code:
my $date_diff_review = GT::Date::date_diff(GT::Date::date_get(),$last_review_date);
my $date_diff_link = GT::Date::date_diff(GT::Date::date_get(),$last_link_date);
Thanks

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] "activity check"-global In reply to
Looks right to me Cool

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] "activity check"-global In reply to
Andy wrote:
Looks right to me Cool

Yes, and now it's working fine, too Smile
Thanks

Matthias
gpaed.de