Gossamer Forum
Quote Reply
Addin Expiration Date
I am trying to make a plugin for adding/calculating an expiration date for links. Therefore, when you are adding your link, based on the date_posted and the duration you select, expiration date field is calculated and updated.
So, I started from the 'user_link_add' hook, and decided to have a PRE hook on 'user_link_add' that takes looks like:
use strict;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$IN $DB $USER $CFG $TPL/;
use GT::Date;

sub set_expiration {

my $input = $IN->get_hash;
my $duration = $input->{'AdDuration'};
my $today = GT::Date::date_get();
$input->{Add_Date} = $today;
$input->{Exp_Date} = add_date($today, $duration);
$input->{AdRenew} = 0;

return $input;

Guess what - it does not work - and I figured that I'm not getting/passing the right arguments/hash...what now?

Thanks - any help very appreciated.

Masamoda :)

Quote Reply
Re: Addin Expiration Date In reply to
I had a problem with this before too. Without going into your code, since I'm still not awake, the 'add' routines do some real harsh processing on the input data (so does modify).

To avoid that, your changes to the add/modify routines should be done as a POST hook. Do an UPDATE to the database on the ID number of the new record, which is passed to the posthook. It's an extra database query, but with persistent connections it's not terrible performance hit. In the modify routines, you need to actually read/modify/update the Changes table.

PUGDOGŪ Enterprises, Inc.
FAQ: http://LinkSQL.com/FAQ

Quote Reply
Re: Addin Expiration Date In reply to

The user_add_link takes nothing as input, and pulls it's record it will add from $IN. So you should make your changes directly:

$IN->param('Add_Date', $today);
$IN->param('Exp_Date', GT::Date::date_add($today, $duration));

So now when the user_add_link hook runs, it will pull from $IN the values you just set.

Let me know if you are still stuck.



Gossamer Threads Inc.
Quote Reply
Re: Addin Expiration Date In reply to
Thanks Alex - it worked like a charm...

Masamoda :)

Quote Reply
Re: Addin Expiration Date In reply to
thanks for your help, Pugdog...I was thinking to do that as well - but following Alex's advice worked for PRE hook with no problems.

Quote Reply
Re: Addin Expiration Date In reply to
Hi masamoda,

I'm interested in knowing more about your expire plugin. What happens to the link after it has been expired? Is it deleted from the system or does it just not show up in builds anymore? I'm interested in something similar, where the user can choose a time in months, 1 2 3 etc and when that time runs out it turns the link off in the build process but it keeps it in the database so I can go in and turn it back on again at any stage for a new amount of time.
I was also wondering what happens when a link is turned off in the final page output? IE. does the number of links on that page fall by 1 if a link is turned off, or does it compensate and replace it with an active link?

Hope thats clear!?

Quote Reply
Re: Addin Expiration Date In reply to
Expire and Delete links by a user should almost be the same thing. Each is just a field in the database, and a brief set of routines to set/access it.

I'm not back up to speed yet after a disasterous week of a bunch of things, but I am taking requests, and looking at the small "features" I can add into the plug-in system while I work on the big ones.

The 01.01.xx version of the graphic upload is pretty nearly complete. It will probably get some enhancements as I finish the logic for the 02.01.xx version of the file upload system.

Should have the "final" stable release of the 01.01.xx version out, and will probably bump the release number up to 01.01.50 just to make it clear it's a real big change.

PUGDOGŪ Enterprises, Inc.
Quote Reply
Re: Addin Expiration Date In reply to
You could also show "soon to expire" links on a new template possibly?

Paul Wilson.
new - http://www.wiredon.net
Post deleted by Evoir In reply to