From 2302c372fb60fe37c4ad2dd3d34e2ac7700593c7 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 18 Oct 2003 15:48:09 +0000 Subject: [PATCH] all wobjects integrated into new discussion system --- docs/upgrades/upgrade_5.4.4-5.5.0.sql | 6 ------ lib/WebGUI/Form.pm | 21 +++++++++++++++------ lib/WebGUI/Forum.pm | 3 +-- lib/WebGUI/Wobject.pm | 6 ++++-- lib/WebGUI/Wobject/MessageBoard.pm | 13 +++++++++++++ lib/WebGUI/Wobject/USS.pm | 12 ++++++++++-- 6 files changed, 43 insertions(+), 18 deletions(-) diff --git a/docs/upgrades/upgrade_5.4.4-5.5.0.sql b/docs/upgrades/upgrade_5.4.4-5.5.0.sql index 30867a229..021fc7fd6 100644 --- a/docs/upgrades/upgrade_5.4.4-5.5.0.sql +++ b/docs/upgrades/upgrade_5.4.4-5.5.0.sql @@ -58,12 +58,6 @@ create table forumRead ( primary key (userId, forumPostId) ); -create table forumBookmark ( - userId int not null, - forumPostId int not null, - primary key (userId, forumPostId) -); - create table forumThreadSubscription ( forumThreadId int not null, userId int not null, diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index 3b398768e..42484be84 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -660,12 +660,21 @@ If you want to add anything special to the form header like javascript actions o =cut sub formHeader { - my ($action, $method, $enctype); - $action = $_[0]->{action} || WebGUI::URL::page(); - $method = $_[0]->{method} || "POST"; - $enctype = $_[0]->{enctype} || "multipart/form-data"; - return '
{extras}.'>'; - + my $action = $_[0]->{action} || WebGUI::URL::page(); + my $hidden; + if ($action =~ /\?/) { + my ($path,$query) = split(/\?/,$action); + $action = $path; + my @params = split(/\&/,$query); + foreach my $param (@params) { + $param =~ s/amp;(.*)/$1/; + my ($name,$value) = split(/\=/,$param); + $hidden .= hidden({name=>$name,value=>$value}); + } + } + my $method = $_[0]->{method} || "POST"; + my $enctype = $_[0]->{enctype} || "multipart/form-data"; + return '{extras}.'>'.$hidden; } diff --git a/lib/WebGUI/Forum.pm b/lib/WebGUI/Forum.pm index 83b8c9146..967ce96d9 100644 --- a/lib/WebGUI/Forum.pm +++ b/lib/WebGUI/Forum.pm @@ -92,14 +92,13 @@ sub new { } sub purge { - my ($self); + 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); diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm index 0ce114ce2..ab4505f66 100644 --- a/lib/WebGUI/Wobject.pm +++ b/lib/WebGUI/Wobject.pm @@ -745,8 +745,10 @@ NOTE: This method is meant to be extended by all sub-classes. =cut sub purge { - my $forum = WebGUI::Forum->new($_[0]->get("forumId")); - $forum->purge; + if ($_[0]->get("forumId")) { + my $forum = 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")); my $node = WebGUI::Node->new($_[0]->get("wobjectId")); diff --git a/lib/WebGUI/Wobject/MessageBoard.pm b/lib/WebGUI/Wobject/MessageBoard.pm index b17036c51..f8725ab74 100644 --- a/lib/WebGUI/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Wobject/MessageBoard.pm @@ -55,6 +55,18 @@ sub new { bless $self, $class; } +#------------------------------------------------------------------- +sub purge { + my $sth = WebGUI::SQL->read("select forumId from MessageBoard_forums where wobjectId=".$_[0]->get("wobjectId")); + while (my ($forumId) = $sth->array) { + my $forum = WebGUI::Forum->new($forumId); + $forum->purge; + } + $sth->finish; + WebGUI::SQL->write("delete from MessageBoard_forums where wobjectId=".$_[0]->get("wobjectId")); + $_[0]->SUPER::purge(); +} + #------------------------------------------------------------------- sub www_deleteForum { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId"))); @@ -68,6 +80,7 @@ sub www_deleteForumConfirm { my $forum = WebGUI::Forum->new($session{form}{forumId}); $forum->purge; WebGUI::SQL->write("delete from MessageBoard_forums where forumId=".$session{form}{forumId}); + return ""; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Wobject/USS.pm b/lib/WebGUI/Wobject/USS.pm index 3ee1b94b8..dea034b97 100644 --- a/lib/WebGUI/Wobject/USS.pm +++ b/lib/WebGUI/Wobject/USS.pm @@ -120,6 +120,12 @@ sub new { #------------------------------------------------------------------- sub purge { + my $sth = WebGUI::SQL->read("select forumId from USS_submission where wobjectId=".$_[0]->get("wobjectId")); + while (my ($forumId) = $sth->array) { + my $forum = WebGUI::Forum->new($forumId); + $forum->purge; + } + $sth->finish; WebGUI::SQL->write("delete from USS_submission where wobjectId=".$_[0]->get("wobjectId")); $_[0]->SUPER::purge(); } @@ -178,8 +184,10 @@ sub www_deleteSubmission { #------------------------------------------------------------------- sub www_deleteSubmissionConfirm { - my ($owner) = WebGUI::SQL->quickArray("select userId from USS_submission where USS_submissionId=$session{form}{sid}"); + my ($owner, $forumId) = WebGUI::SQL->quickArray("select userId,forumId from USS_submission where USS_submissionId=$session{form}{sid}"); if ($owner == $session{user}{userId} || WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) { + my $forum = WebGUI::Forum->new($forumId); + $forum->purge; $_[0]->deleteCollateral("USS_submission","USS_submissionId",$session{form}{sid}); my $file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid}); $file->deleteNode; @@ -566,7 +574,7 @@ sub www_viewSubmission { $var{"attachment.name"} = $file->getFilename; } if ($_[0]->get("allowDiscussion")) { - if ($session{form}{forumOp}) { + if ($session{form}{forumOp}) { $var{"replies"} = WebGUI::Forum::UI::forumOp($callback); } else { $var{"replies"} = WebGUI::Forum::UI::www_viewForum($callback,$submission->{forumId});