added purge

This commit is contained in:
JT Smith 2003-10-12 23:56:56 +00:00
parent 7f53e348f5
commit 998eb9d981
2 changed files with 24 additions and 2 deletions

View file

@ -66,6 +66,27 @@ sub new {
bless {_properties=>$properties}, $self;
}
sub purge {
my ($self);
my $a = WebGUI::SQL->read("select * from forumThread where forumId=".$self->get("forumId"));
while (my ($threadId) = $a->array) {
my $b = WebGUI::SQL->read("select * from forumPost where forumThreadId=".$threadId);
while (my ($postId) = $b->array) {
WebGUI::SQL->write("delete from forumPostAttachment where forumPostId=".$postId);
WebGUI::SQL->write("delete from forumPostRating where forumPostId=".$postId);
WebGUI::SQL->write("delete from forumBookmark where forumPostId=".$postId);
}
$b->finish;
WebGUI::SQL->write("delete from forumThreadSubscription where forumThreadId=".$threadId);
WebGUI::SQL->write("delete from forumRead where forumThreadId=".$threadId);
WebGUI::SQL->write("delete from forumPost where forumThreadId=".$threadId);
}
$a->finish;
WebGUI::SQL->write("delete from forumSubscription where forumId=".$self->get("forumId"));
WebGUI::SQL->write("delete from forumThread where forumId=".$self->get("forumId"));
WebGUI::SQL->write("delete from forum where forumId=".$self->get("forumId"));
}
sub recalculateRating {
my ($self) = @_;
my ($count) = WebGUI::SQL->quickArray("select count(*) from forumThread where forumId=".$self->get("forumId")." and rating>0");

View file

@ -745,10 +745,11 @@ NOTE: This method is meant to be extended by all sub-classes.
=cut
sub purge {
my ($node);
my WebGUI::Forum->new($_[0]->get("forumId"));
$forum->purge;
WebGUI::SQL->write("delete from ".$_[0]->get("namespace")." where wobjectId=".$_[0]->get("wobjectId"));
WebGUI::SQL->write("delete from wobject where wobjectId=".$_[0]->get("wobjectId"));
$node = WebGUI::Node->new($_[0]->get("wobjectId"));
my $node = WebGUI::Node->new($_[0]->get("wobjectId"));
$node->delete;
}