all wobjects integrated into new discussion system

This commit is contained in:
JT Smith 2003-10-18 15:48:09 +00:00
parent 65a9ecbd34
commit 2302c372fb
6 changed files with 43 additions and 18 deletions

View file

@ -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,

View file

@ -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 '<form action="'.$action.'" enctype="'.$enctype.'" method="'.$method.'" '.$_[0]->{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 '<form action="'.$action.'" enctype="'.$enctype.'" method="'.$method.'" '.$_[0]->{extras}.'>'.$hidden;
}

View file

@ -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);

View file

@ -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"));

View file

@ -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 "";
}
#-------------------------------------------------------------------

View file

@ -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});