diff --git a/sbin/Hourly/DeleteExpiredClipboard.pm b/sbin/Hourly/DeleteExpiredClipboard.pm new file mode 100644 index 000000000..5b5427a94 --- /dev/null +++ b/sbin/Hourly/DeleteExpiredClipboard.pm @@ -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; + diff --git a/sbin/Hourly/DeleteExpiredTrash.pm b/sbin/Hourly/DeleteExpiredTrash.pm new file mode 100644 index 000000000..e99376657 --- /dev/null +++ b/sbin/Hourly/DeleteExpiredTrash.pm @@ -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; + diff --git a/sbin/Hourly/EmptyTrash.pm b/sbin/Hourly/EmptyTrash.pm index b9be99c7e..952415c7a 100644 --- a/sbin/Hourly/EmptyTrash.pm +++ b/sbin/Hourly/EmptyTrash.pm @@ -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); + } }