Gossamer Forum
Home : Products : DBMan : Customization :

AUTODELETE RECORDS

Quote Reply
AUTODELETE RECORDS
Where can i change the "Automatically removes entries older than a predetermined date"-mod, to use the Removeby-field as a number-field? I don't need a date-field, because the user add the number of days to the records.

Sorry for my broken english.

Quote Reply
Re: AUTODELETE RECORDS In reply to
You stated:

I don't need a date-field, because the user add the number of days to the records.

Even if the user adds the number of days or duration would it not need a date field to compare that with the current date?

There are several variations of the mod available. But I believe they would all require a date field for comparison reasons.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: AUTODELETE RECORDS In reply to
Hello LoisC,

thank you for the quick answer. Again, sorry for my broken english. I try to explain my problem:

I have a job-database, and the user add a record and say how long will the record be in the database. But i don't want a date-field for removeby, because we have in german another date-format. And if i add the universal-date-translator, i have a bigger problem.

I think it must be possible, to make the removeby-field as a number field. Then can the user say how much days the record will be stay.

today => dateadded (get_date)
days => removeby (number example 3)

delete-day => dateadded + removeby

15. april => 12. april + 3

I hope you understand me. I am not a perl-programmer.

Thanks again for help.

Quote Reply
Re: AUTODELETE RECORDS In reply to
Check the version and instructions that I posted for using Mulitiple databases. For this version I used a duration date for a classified system.

I believe in the instructions I provided all the changes I made when setting up that database. I think that may be what you are looking to do.

http://webmagic.hypermart.net/autodel.htm



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: AUTODELETE RECORDS In reply to
Hello,

now i have this:

DateAdded => [2,'date',4,5,1,&get_date,''], ### rename to match your field
'remove' => [ 14, 'numer', 5, 5, 1, '', '']


and

sub auto_delete {
# ------------------------------------------
# Automatically removes entries older then $remove # days old.
#
my $remove = 14; # remove-Feld.
my $date_field = 2; # Field Position of date field.


my $today = &date_to_unix(&get_date);
my $removeby = $today - ($values[$remove] * 86400);
my (@lines, @values);
open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
if ($removeby > &date_to_unix($values[$date_field])) {
next;
}
print DB $_, "\n";
}
close DB;
}


My problem is now, that all records delete after one day (just when i login). I test it with 1, 10, 100 ... days in the remove-field. Where is the mistake?


Quote Reply
Re: AUTODELETE RECORDS In reply to
Have you also added and configured the others subs needed to make this work?

sub calc_expire_date {
###################
my ($temp_date);
$temp_date = &date_to_unix($in{'ADStart'});
$temp_date = $temp_date + ($in{'duration'}*86400);
$in{'Expires'} = &get_date($temp_date);
}

sub calc_remove_date {
###################
my ($temp_date);
$temp_date = &date_to_unix($in{'Expires'});
$temp_date = $temp_date + ($in{'Expires'}+86400);
$in{'Remove_by'} = &get_date($temp_date);
}

Sometimes you just have to play around with the various autodelete options and test until you get it all working the way you need to.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: AUTODELETE RECORDS In reply to
I asked about this a couple of weeks ago now... Have a look at my thread regarding this: http://www.gossamer-threads.com/...ew=&sb=&vc=1