added purge
This commit is contained in:
parent
7f53e348f5
commit
998eb9d981
2 changed files with 24 additions and 2 deletions
|
|
@ -66,6 +66,27 @@ sub new {
|
||||||
bless {_properties=>$properties}, $self;
|
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 {
|
sub recalculateRating {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my ($count) = WebGUI::SQL->quickArray("select count(*) from forumThread where forumId=".$self->get("forumId")." and rating>0");
|
my ($count) = WebGUI::SQL->quickArray("select count(*) from forumThread where forumId=".$self->get("forumId")." and rating>0");
|
||||||
|
|
|
||||||
|
|
@ -745,10 +745,11 @@ NOTE: This method is meant to be extended by all sub-classes.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub purge {
|
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 ".$_[0]->get("namespace")." where wobjectId=".$_[0]->get("wobjectId"));
|
||||||
WebGUI::SQL->write("delete from wobject 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;
|
$node->delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue