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 2c9da088a..30867a229 100644 --- a/docs/upgrades/upgrade_5.4.4-5.5.0.sql +++ b/docs/upgrades/upgrade_5.4.4-5.5.0.sql @@ -18,12 +18,6 @@ create table forum ( allowReplacements int not null default 1 ); -create table forumReplacement ( - forumReplacementId int not null primary key, - pattern varchar(255), - replaceWith varchar(255) -); - create table forumPost ( forumPostId int not null primary key, parentId int not null default 0, @@ -149,6 +143,7 @@ delete from international where namespace='WebGUI' and internationalId=238; delete from international where namespace='WebGUI' and internationalId=239; delete from international where namespace='WebGUI' and internationalId=1014; delete from international where namespace='WebGUI' and internationalId=1015; +delete from international where namespace='MessageBoard' and internationalId=4; delete from international where languageId=1 and namespace='WebGUI' and internationalId=512; insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (512,1,'WebGUI','Go to next thread', 1065280309,NULL); delete from international where languageId=1 and namespace='WebGUI' and internationalId=513; @@ -245,4 +240,8 @@ INSERT INTO replacements VALUES (10,'[/b]',''); INSERT INTO replacements VALUES (11,'[i]',''); INSERT INTO replacements VALUES (12,'[/i]',''); INSERT INTO replacements VALUES (0,NULL,NULL); +alter table forum add column masterForumId int; +alter table USS_submission add column forumId int; + + diff --git a/lib/WebGUI/Forum.pm b/lib/WebGUI/Forum.pm index b48b5656b..83b8c9146 100644 --- a/lib/WebGUI/Forum.pm +++ b/lib/WebGUI/Forum.pm @@ -68,6 +68,26 @@ sub isSubscribed { sub new { my ($class, $forumId) = @_; my $properties = WebGUI::SQL->getRow("forum","forumId",$forumId); + if ($properties->{masterForumId}) { + my $master = WebGUI::SQL->getRow("forum","forumId",$properties->{masterForumId}); + $properties->{forumTemplateId} = $master->{forumTemplateId}; + $properties->{threadTemplateId} = $master->{threadTemplateId}; + $properties->{postTemplateId} = $master->{postTemplateId}; + $properties->{searchTemplateId} = $master->{searchTemplateId}; + $properties->{notificationTemplateId} = $master->{notificationTemplateId}; + $properties->{postFormTemplateId} = $master->{postFormTemplateId}; + $properties->{archiveAfter} = $master->{archiveAfter}; + $properties->{allowRichEdit} = $master->{allowRichEdit}; + $properties->{allowReplacements} = $master->{allowReplacements}; + $properties->{filterPosts} = $master->{filterPosts}; + $properties->{karmaPerPost} = $master->{karmaPerPost}; + $properties->{groupToPost} = $master->{groupToPost}; + $properties->{groupToModerate} = $master->{groupToModerate}; + $properties->{moderatePosts} = $master->{moderatePosts}; + $properties->{attachmentsPerPost} = $master->{attachmentsPerPost}; + $properties->{addEditStampToPosts} = $master->{addEditStampsToPost}; + $properties->{postsPerPage} = $master->{postsPerPage}; + } bless {_properties=>$properties}, $class; } diff --git a/lib/WebGUI/Wobject/Article.pm b/lib/WebGUI/Wobject/Article.pm index 59f3b14d0..c9ffb1ec4 100644 --- a/lib/WebGUI/Wobject/Article.pm +++ b/lib/WebGUI/Wobject/Article.pm @@ -193,7 +193,7 @@ sub www_view { $templateId = $_[0]->get("templateId"); } if ($session{form}{forumOp}) { - return WebGUI::Forum::UI::forumOp($callback,$_[0]->get("forumId")); + return WebGUI::Forum::UI::forumOp($callback); } else { return $_[0]->processTemplate($templateId,\%var); } diff --git a/lib/WebGUI/Wobject/MessageBoard.pm b/lib/WebGUI/Wobject/MessageBoard.pm index f14c54d87..b17036c51 100644 --- a/lib/WebGUI/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Wobject/MessageBoard.pm @@ -50,27 +50,11 @@ sub new { my $property = shift; my $self = WebGUI::Wobject->new( -properties=>$property, - -extendedProperties=>{ - messagesPerPage=>{ - defaultValue=>50 - } - }, -useTemplate=>1 ); bless $self, $class; } -#------------------------------------------------------------------- -sub status { - if ($_[0] eq "Approved") { - return WebGUI::International::get(560); - } elsif ($_[0] eq "Denied") { - return WebGUI::International::get(561); - } elsif ($_[0] eq "Pending") { - return WebGUI::International::get(562); - } -} - #------------------------------------------------------------------- sub www_deleteForum { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditWobject($_[0]->get("wobjectId"))); @@ -89,14 +73,7 @@ sub www_deleteForumConfirm { #------------------------------------------------------------------- sub www_edit { my $properties = WebGUI::HTMLForm->new; - my $layout = WebGUI::HTMLForm->new; - $layout->integer( - -name=>"messagesPerPage", - -label=>WebGUI::International::get(4,$_[0]->get("namespace")), - -value=>$_[0]->getValue("messagesPerPage") - ); return $_[0]->SUPER::www_edit( - -layout=>$layout->printRowsOnly, -properties=>$properties->printRowsOnly, -headingId=>6, -helpId=>1 @@ -166,11 +143,6 @@ sub www_moveForumUp { return ""; } -#------------------------------------------------------------------- -sub www_showMessage { - return $_[0]->SUPER::www_showMessage(''.WebGUI::International::get(11,$_[0]->get("namespace")).'
'); -} - #------------------------------------------------------------------- sub www_view { my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")); @@ -210,7 +182,7 @@ sub www_view { 'forum.url' => WebGUI::Forum::UI::formatForumURL($callback,$forum->get("forumId")), 'forum.lastPost.url' => WebGUI::Forum::UI::formatThreadURL($callback,$lastPost->get("forumPostId")), 'forum.lastPost.date' => WebGUI::Forum::UI::formatPostDate($lastPost->get("dateOfPost")), - 'forum.lastPost.time' => WebGUI::Forum::UI::formatPostDate($lastPost->get("dateOfPost")), + 'forum.lastPost.time' => WebGUI::Forum::UI::formatPostTime($lastPost->get("dateOfPost")), 'forum.lastPost.epoch' => $lastPost->get("dateOfPost"), 'forum.lastPost.subject' => WebGUI::Forum::UI::formatSubject($lastPost->get("subject")), 'forum.lastPost.user.id' => $lastPost->get("userId"), diff --git a/lib/WebGUI/Wobject/USS.pm b/lib/WebGUI/Wobject/USS.pm index 9420a666d..3ee1b94b8 100644 --- a/lib/WebGUI/Wobject/USS.pm +++ b/lib/WebGUI/Wobject/USS.pm @@ -14,6 +14,7 @@ use strict; use Tie::CPHash; use WebGUI::Attachment; use WebGUI::DateTime; +use WebGUI::Forum; use WebGUI::Forum::UI; use WebGUI::HTML; use WebGUI::HTMLForm; @@ -314,6 +315,11 @@ sub www_editSubmissionSave { && WebGUI::Privilege::isInGroup($_[0]->get("groupToContribute"))) || WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) { if ($session{form}{sid} eq "new") { + my $forum = WebGUI::Forum->create({ + masterForumId=>$_[0]->get("forumId"), + forumId=>"new" + }); + $hash{forumId} = $forum->get("forumId"); $hash{username} = $session{form}{visitorName} || $session{user}{alias}; $hash{userId} = $session{user}{userId}; $hash{USS_submissionId} = "new"; @@ -382,7 +388,7 @@ sub www_view { $var{"date.label"} = WebGUI::International::get(13,$_[0]->get("namespace")); $var{"by.label"} = WebGUI::International::get(21,$_[0]->get("namespace")); $p = WebGUI::Paginator->new(WebGUI::URL::page('func=view&wid='.$_[0]->get("wobjectId")),[],$numResults); - $p->setDataByQuery("select USS_submissionId, content, title, userId, status, image, dateSubmitted, username + $p->setDataByQuery("select USS_submissionId, content, title, userId, status, image, dateSubmitted, username, forumId from USS_submission where wobjectId=".$_[0]->get("wobjectId")." and $constraints order by dateSubmitted desc"); $page = $p->getPageData; $i = 0; @@ -399,8 +405,8 @@ sub www_view { $thumbnail = ""; $imageURL; } - ($responses) = WebGUI::SQL->quickArray("select count(*) from discussion - where wobjectId=".$_[0]->get("wobjectId")." and subId=".$row->{USS_submissionId}); + ($responses) = WebGUI::SQL->quickArray("select count(*) from forumPost left join forumThread on + forumThread.forumThreadId=forumPost.forumThreadId where forumThread.forumId=".$row->{forumId}); push (@submission,{ "submission.id"=>$page->[$i]->{USS_submissionId}, "submission.url"=>WebGUI::URL::page('wid='.$_[0]->get("wobjectId").'&func=viewSubmission&sid='.$page->[$i]->{USS_submissionId}),