clipboard/trash expiration offset pruning

This commit is contained in:
Ed Van Duinen 2003-05-13 21:41:51 +00:00
parent bcf30faa84
commit 95abe5ea95
3 changed files with 93 additions and 1 deletions

View file

@ -0,0 +1,35 @@
package Hourly::DeleteExpiredClipboard;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::DateTime;
use WebGUI::Session;
use WebGUI::SQL;
#-----------------------------------------
sub process {
if ($session{config}{DeleteExpiredClipboard_offset} ne "") {
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredClipboard_offset}));
WebGUI::ErrorHandler::audit("moving expired clipboard items to trash");
WebGUI::SQL->write("update page set parentId=3, bufferPrevId=2, bufferDate=" .time()
." where parentId=2 and bufferDate < ". $expireDate );
WebGUI::SQL->write("update wobject set pageId=3, bufferPrevId=2, bufferDate=" .time()
." where pageId=2 and bufferDate < ". $expireDate );
}
}
1;

View file

@ -0,0 +1,54 @@
package Hourly::DeleteExpiredTrash;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::DateTime;
use WebGUI::Session;
use WebGUI::SQL;
#-----------------------------------------
sub process {
if ($session{config}{DeleteExpiredTrash_offset} ne "") {
my (%properties, $base, $extended, $b, $w, $cmd, $purgeDate, $a, $pageId);
tie %properties, 'Tie::CPHash';
$purgeDate = (time()-(86400*$session{config}{DeleteExpiredTrash_offset}));
# Delete wobjects
$b = WebGUI::SQL->read("select * from wobject where pageId=3 and bufferDate<" . $purgeDate);
while ($base = $b->hashRef) {
$extended = WebGUI::SQL->quickHashRef("select * from ".$base->{namespace}."
where wobjectId=".$base->{wobjectId});
%properties = (%{$base}, %{$extended});
$cmd = "WebGUI::Wobject::".$properties{namespace};
$w = $cmd->new(\%properties);
WebGUI::ErrorHandler::audit("purging expired wobject ". $base->{wobjectId} ." from trash");
$w->purge;
}
$b->finish;
# Delete pages and all subpages
$a = WebGUI::SQL->read("select pageId from page where parentId=3 and bufferDate<" . $purgeDate);
while (($pageId) = $a->array) {
WebGUI::ErrorHandler::audit("purging expired page ". $pageId ." from trash");
_recursePageTree($pageId);
_purgeWobjects($pageId);
WebGUI::SQL->write("delete from page where pageId=$pageId");
}
$a->finish;
}
}
1;

View file

@ -20,7 +20,10 @@ use WebGUI::SQL;
sub process {
my @date = WebGUI::DateTime::localtime();
if ($date[1] == $session{config}{EmptyTrash_day} && $date[4] == 1) { # only occurs at 1am on the day in question.
WebGUI::Operation::Trash::www_purgeTrashConfirm();
WebGUI::ErrorHandler::audit("emptying system trash");
WebGUI::Operation::Trash::_recursePageTree(3);
WebGUI::Operation::Trash::_purgeWobjects(3);
}
}