From dfd8b046b6fb874a174c91457b5745713d70dd29 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 18 Oct 2003 22:02:22 +0000 Subject: [PATCH] a few more discussion tweaks --- docs/gotcha.txt | 4 ++++ docs/upgrades/upgrade_5.4.4-5.5.0.pl | 7 ++++++- docs/upgrades/upgrade_5.4.4-5.5.0.sql | 3 ++- lib/WebGUI/Forum/Post.pm | 9 ++++++++- lib/WebGUI/Forum/UI.pm | 23 +++++++++++++++-------- lib/WebGUI/Forum/templates.sql | 5 ----- lib/WebGUI/Wobject/MessageBoard.pm | 2 +- lib/WebGUI/Wobject/USS.pm | 9 ++++----- sbin/Hourly/ArchiveOldPosts.pm | 6 +++++- 9 files changed, 45 insertions(+), 23 deletions(-) delete mode 100644 lib/WebGUI/Forum/templates.sql diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 97b57fcf5..fe4e5f4d6 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -19,6 +19,10 @@ save you many hours of grief. these fields no longer exist in the new discussion system due to the complexities of the new system. + * If you have any SQL Reports or custom macros that pull data from + discussions then you'll need to rebuild them because the + discussion data structures have changed significantly. + 5.4.1 -------------------------------------------------------------------- diff --git a/docs/upgrades/upgrade_5.4.4-5.5.0.pl b/docs/upgrades/upgrade_5.4.4-5.5.0.pl index 5356bf6df..11fca359c 100644 --- a/docs/upgrades/upgrade_5.4.4-5.5.0.pl +++ b/docs/upgrades/upgrade_5.4.4-5.5.0.pl @@ -207,7 +207,12 @@ WebGUI::SQL->write("update incrementer set nextValue=$max where incrementerId='f ($max) = WebGUI::SQL->quickArray("select max(forumThreadId) from forumThread"); $max++; WebGUI::SQL->write("update incrementer set nextValue=$max where incrementerId='forumThreadId'"); - +WebGUI::SQL->write("update forumThread set status='approved' where status='Approved'"); +WebGUI::SQL->write("update forumPost set status='approved' where status='Approved'"); +WebGUI::SQL->write("update forumThread set status='denied' where status='Denied'"); +WebGUI::SQL->write("update forumPost set status='denied' where status='Denied'"); +WebGUI::SQL->write("update forumThread set status='pending' where status='Pending'"); +WebGUI::SQL->write("update forumPost set status='pending' where status='Pending'"); #-------------------------------------------- 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 a2fea9627..7c80b3791 100644 --- a/docs/upgrades/upgrade_5.4.4-5.5.0.sql +++ b/docs/upgrades/upgrade_5.4.4-5.5.0.sql @@ -244,7 +244,6 @@ INSERT INTO template VALUES (1,'Default Post Form','

\n\n\n\n\n\n
\n\n\n \n

\n \">\n \n • : [ \">1, \">2, \n \">3, \">4, \">5 ]\n \n \n \n • \">\n • \">\n \n \n • \">\n • \">\n \n\n

\n: @
\n:
\n:
\n:
\n\n :
\n\n : \">
\n
\n
','Forum/Post'); INSERT INTO template VALUES (1,'Default Thread','
\n\n\n
\n
\n\n \n \">\n \n
style=\"border: 4px dotted #aaaaaa; padding: 5px;\">\n \n
style=\"border: 4px dotted #aaaaaa; padding: 5px;\">\n \n \n
\n \n\n\n\n \n \n \n \n \n \n \n \n
         \n \">\n \n
style=\"border: 4px dotted #aaaaaa; padding: 5px;\">\n \n
style=\"border: 4px dotted #aaaaaa; padding: 5px;\">\n \n \n
\n
\n
\n
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
   \">\"> @
\n
\n\n

\n\"> •\n\"> •\n\"> \n\n • \">\n \n •\n \n \">\n \n \">\n \n \n \n •\n \n \">\n \n \">\n \n •\n \n \">\n \n \">\n \n \n\n\n

\n','Forum/Thread'); INSERT INTO template VALUES (1,'Default Forum Notification','\n\n','Forum/Notification'); -INSERT INTO template VALUES (1000,'phpBB Forum','\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\">^I(phpBB post);   \" class=\"nav\">Forum IndexMark all topics read
\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n
Topics Replies Author Views Last Post
\r\n \r\n ^I(phpBB folder_sticky);\r\n \r\n \r\n ^I(phpBB folder_locked);\r\n \r\n ^I(phpBB folder);\r\n \r\n \r\n \" class=\"topictitle\">
\r\n
\">
\"> \">^I(phpBB icon_latest_reply);
Display topics from previous: \r\n \r\n
\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\">^I(phpBB post); \" class=\"nav\">Forum Index Goto page \r\n
Page of
\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
^I(phpBB folder_new);New posts ^I(phpBB folder);No new posts ^I(phpBB folder_sticky);Sticky
^I(phpBB folder_lock_new);New posts [ Locked ] ^I(phpBB folder_lock);No new posts [ Locked ]
\r\n You cannot post new topics in this forum
\r\n You cannot reply to topics in this forum
\r\n You cannot edit your posts in this forum
\r\n You cannot delete your posts in this forum
\r\n
\r\n\r\n \r\n \r\n \r\n','Forum'); INSERT INTO template VALUES (1,'Default Forum Search','\n\n\n \n
\n

\n
\n \n \'\n \n \n \n \n
\n
\n \n
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\">\"> @
\n
\n\n\n
\n · · \n
\n
','Forum/Search'); delete from international where namespace='MessageBoard' and internationalId=8; delete from international where namespace='MessageBoard' and internationalId=9; @@ -261,6 +260,8 @@ delete from international where namespace='WebGUI' and internationalId=228; delete from international where namespace='WebGUI' and internationalId=570; delete from international where namespace='WebGUI' and internationalId=571; delete from international where namespace='WebGUI' and internationalId=402; +delete from international where languageId=1 and namespace='WebGUI' and internationalId=529; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (529,1,'WebGUI','results per page', 1066492301,'A label indicating the number of items per page to return in a list.'); diff --git a/lib/WebGUI/Forum/Post.pm b/lib/WebGUI/Forum/Post.pm index 4d5205c26..3e5647a43 100644 --- a/lib/WebGUI/Forum/Post.pm +++ b/lib/WebGUI/Forum/Post.pm @@ -39,7 +39,14 @@ sub get { sub getReplies { my ($self) = @_; my @replies = (); - my $sth = WebGUI::SQL->read("select forumPostId from forumPost where parentId=".$self->get("forumPostId")." order by forumPostId"); + my $query = "select forumPostId from forumPost where parentId=".$self->get("forumPostId")." and "; + if ($self->getThread->getForum->isModerator) { + $query .= "(status='approved' or status='pending' or status='denied'"; + } else { + $query .= "(status='approved'"; + } + $query .= " or userId=$session{user}{userId}) order by forumPostId"; + my $sth = WebGUI::SQL->read($query); while (my @data = $sth->array) { push(@replies,WebGUI::Forum::Post->new($data[0])); } diff --git a/lib/WebGUI/Forum/UI.pm b/lib/WebGUI/Forum/UI.pm index bfb295ad0..826674645 100644 --- a/lib/WebGUI/Forum/UI.pm +++ b/lib/WebGUI/Forum/UI.pm @@ -75,7 +75,7 @@ sub formatPreviousThreadURL { } sub formatRatePostURL { - return WebGUI::URL::append($_[0],"forumOp=ratePost&forumPostId=".$_[1]."&rating=".$_[2]); + return WebGUI::URL::append($_[0],"forumOp=ratePost&forumPostId=".$_[1]."&rating=".$_[2]."#".$_[1]); } sub formatReplyPostURL { @@ -105,27 +105,27 @@ sub formatThreadLayoutURL { } sub formatThreadLockURL { - return WebGUI::URL::append($_[0],"forumOp=threadLock&forumPostId=".$_[1]); + return WebGUI::URL::append($_[0],"forumOp=threadLock&forumPostId=".$_[1]."#".$_[1]); } sub formatThreadUnlockURL { - return WebGUI::URL::append($_[0],"forumOp=threadUnlock&forumPostId=".$_[1]); + return WebGUI::URL::append($_[0],"forumOp=threadUnlock&forumPostId=".$_[1]."#".$_[1]); } sub formatThreadStickURL { - return WebGUI::URL::append($_[0],"forumOp=threadStick&forumPostId=".$_[1]); + return WebGUI::URL::append($_[0],"forumOp=threadStick&forumPostId=".$_[1]."#".$_[1]); } sub formatThreadSubscribeURL { - return WebGUI::URL::append($_[0],"forumOp=threadSubscribe&forumPostId=".$_[1]); + return WebGUI::URL::append($_[0],"forumOp=threadSubscribe&forumPostId=".$_[1]."#".$_[1]); } sub formatThreadUnstickURL { - return WebGUI::URL::append($_[0],"forumOp=threadUnstick&forumPostId=".$_[1]); + return WebGUI::URL::append($_[0],"forumOp=threadUnstick&forumPostId=".$_[1]."#".$_[1]); } sub formatThreadUnsubscribeURL { - return WebGUI::URL::append($_[0],"forumOp=threadUnsubscribe&forumPostId=".$_[1]); + return WebGUI::URL::append($_[0],"forumOp=threadUnsubscribe&forumPostId=".$_[1]."#".$_[1]); } sub formatThreadURL { @@ -316,6 +316,7 @@ sub getForumTemplateVars { $var{'forum.unsubscribe.label'} = WebGUI::International::get(1023); $var{'forum.unsubscribe.url'} = formatForumUnsubscribeURL($callback,$forum->get("forumId")); $var{'user.isSubscribed'} = $forum->isSubscribed; + $var{'user.isModerator'} = $forum->isModerator; $var{'user.canPost'} = $forum->canPost; $var{'thread.sortby.date.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"date"); $var{'thread.sortby.lastreply.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"lastreply"); @@ -329,7 +330,13 @@ sub getForumTemplateVars { $var{"thread.replies.label"} = WebGUI::International::get(1016); $var{'thread.rating.label'} = WebGUI::International::get(1020); $var{"thread.last.label"} = WebGUI::International::get(1017); - my $query = "select * from forumThread where forumId=".$forum->get("forumId")." order by isSticky desc, "; + my $query = "select * from forumThread where forumId=".$forum->get("forumId")." and "; + if ($forum->isModerator) { + $query .= "(status='approved' or status='pending')"; + } else { + $query .= "status='approved'"; + } + $query .= " order by isSticky desc, "; if ($session{scratch}{forumSortBy} eq "date") { $query .= "rootPostId desc"; } elsif ($session{scratch}{forumSortBy} eq "views") { diff --git a/lib/WebGUI/Forum/templates.sql b/lib/WebGUI/Forum/templates.sql deleted file mode 100644 index f5331bf02..000000000 --- a/lib/WebGUI/Forum/templates.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO template VALUES (1,'Default Forum','\n \">\n

\n\n\n\n\n \n \n \n \n \n \n \n\n\n\n \n \n \n \n \n \n \n \n \n \n \n\n\n
\">\"> @ \n \">\n by \n \n \n \n \">\n \n on @ \n
\n\n\n

\n · · \n
\n
','Forum'); -INSERT INTO template VALUES (1,'Default Post Form','

\n\n\n\n\n\n \n\n\n\n\n\n\n \n \n \n \n \n\n\n\n\n\n
\n\n\n

\n\n

','Forum/PostForm'); -INSERT INTO template VALUES (1,'Default Post','

\n\n\n\n\n\n
\n\n\n \n

\n \">\n \n • : [ \">1, \">2, \n \">3, \">4, \">5 ]\n \n \n \n • \">\n • \">\n \n \n • \">\n • \">\n \n\n

\n: @
\n:
\n:
\n:
\n\n :
\n\n : \">
\n
\n
','Forum/Post'); -INSERT INTO template VALUES (1,'Default Thread','\"> •\n\"> •\n\"> \n\n • \">\n\n

\n\n\n \n \">\n \n

\n \n \n \n \n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n
         \n \">\n \n
\n
\n
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
   \">\"> @
\n
\n\n

\n\"> •\n\"> •\n\"> •\n\">\n','Forum/Thread'); - diff --git a/lib/WebGUI/Wobject/MessageBoard.pm b/lib/WebGUI/Wobject/MessageBoard.pm index fd9c7ab85..1e42e35f7 100644 --- a/lib/WebGUI/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Wobject/MessageBoard.pm @@ -212,7 +212,7 @@ sub www_view { $count++; } $sth->finish; - $var{areMultipleForums} = ($count > 1); + $var{areMultipleForums} = ($count > 2); $var{forum_loop} = \@forum_loop; return $_[0]->processTemplate($_[0]->get("templateId"),\%var); } diff --git a/lib/WebGUI/Wobject/USS.pm b/lib/WebGUI/Wobject/USS.pm index 047604e30..259831f71 100644 --- a/lib/WebGUI/Wobject/USS.pm +++ b/lib/WebGUI/Wobject/USS.pm @@ -516,6 +516,9 @@ sub www_viewSubmission { my $submission = $_[0]->getCollateral("USS_submission","USS_submissionId",$session{form}{sid}); return $_[0]->www_view unless ($submission->{USS_submissionId}); my $callback = WebGUI::URL::page("func=viewSubmission&wid=".$_[0]->get("wobjectId")."&sid=".$submission->{USS_submissionId}); + if ($session{form}{forumOp}) { + return WebGUI::Forum::UI::forumOp($callback); + } WebGUI::SQL->write("update USS_submission set views=views+1 where USS_submissionId=$session{form}{sid}"); $var{title} = $submission->{title}; $var{content} = WebGUI::HTML::filter($submission->{content},$_[0]->get("filterContent")); @@ -579,11 +582,7 @@ sub www_viewSubmission { $var{"attachment.name"} = $file->getFilename; } if ($_[0]->get("allowDiscussion")) { - if ($session{form}{forumOp}) { - $var{"replies"} = WebGUI::Forum::UI::forumOp($callback); - } else { - $var{"replies"} = WebGUI::Forum::UI::www_viewForum($callback,$submission->{forumId}); - } + $var{"replies"} = WebGUI::Forum::UI::www_viewForum($callback,$submission->{forumId}); } return WebGUI::Template::process(WebGUI::Template::get($_[0]->get("submissionTemplateId"),"USS/Submission"), \%var); } diff --git a/sbin/Hourly/ArchiveOldPosts.pm b/sbin/Hourly/ArchiveOldPosts.pm index 5fd67c060..7ac7e4e41 100644 --- a/sbin/Hourly/ArchiveOldPosts.pm +++ b/sbin/Hourly/ArchiveOldPosts.pm @@ -19,13 +19,17 @@ use WebGUI::SQL; #----------------------------------------- sub process { my $epoch = WebGUI::DateTime::time(); - my $a = WebGUI::SQL->read("select forumId,archiveAfter from forum"); + my $a = WebGUI::SQL->read("select forumId,archiveAfter,masterForumId from forum"); while (my $forum = $a->hashRef) { + if ($forum->{masterForumId}) { + ($forum->{archiveAfter}) = WebGUI::SQL->quickArray("select archiveAfter from forum where masterForumId=$forum->{masterForumId}"); + } my $archiveDate = $epoch - $forum->{archiveAfter}; my $b = WebGUI::SQL->read("select forumThreadId from forumThread where forumId=".$forum->{forumId} ." and lastPostDate<$archiveDate"); while (my ($threadId) = $b->array) { WebGUI::SQL->write("update forumPost set status='archived' where status='approved' and forumThreadId=$threadId"); + WebGUI::SQL->write("update forumThread set status='archived' where status='approved' and forumThreadId=$threadId"); } $b->finish; }