Gossamer Forum
Home : Products : DBMan : Customization :

Auto-expire records?

Quote Reply
Auto-expire records?
I want to set up a "discount directory" for my users where they can search for special offers from merchants. Most merchants want to have a limited time offer, but they won't be all the same ammount of time (some 30 days, some 90 days, etc.)

Is there a way or a hack where I can have the merchant enter an "Expires on:" date in a field and the record will be automagically deleted when that date comes up?

The only other way I can think of doing it is by hand - searching for the current date and deleting each record as it comes due. Too much effort for an ongoing project.

It would be an added bonus to be able to e-mail the merchant letting them know their offer has expired and inviting them back to place another one (or whatever I want to mail them - the e-mail body can be pulled from a text file or an admin area).
Quote Reply
Re: Auto-expire records? In reply to
There is a long discussion about this in the "DBMan Installation" forum. You can go to
http://www.gossamer-threads.com/scripts/forum/resources/Forum5/HTML/000765.html

Scroll down the page and find the message posted by me on March 27 at 8:52 am. This script will delete records that are older than a date which is in a field you designate. It does not send email to the person, however.

The script doesn't exactly delete records automatically, but if you put a line in the auth.pl file, sub auth_check_password, it will delete them whenever someone logs into the database.

After

Code:
open(AUTH, ">$auth_dir/$db_uid") or &cgierr("unable to open auth file:
$auth_dir/$uid. Reason: $!\n");
print AUTH "$uid: $ENV{'REMOTE_HOST'}\n";
close AUTH;

add

Code:
&auto_delete;

Add the entire "auto_delete" subroutine from the forum to db.cgi. You can just paste it onto the end of the script.


------------------
JPD