a few more discussion tweaks

This commit is contained in:
JT Smith 2003-10-18 22:02:22 +00:00
parent 0281564473
commit dfd8b046b6
9 changed files with 45 additions and 23 deletions

View file

@ -19,6 +19,10 @@ save you many hours of grief.
these fields no longer exist in the new discussion system these fields no longer exist in the new discussion system
due to the complexities of the new 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 5.4.1
-------------------------------------------------------------------- --------------------------------------------------------------------

View file

@ -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->quickArray("select max(forumThreadId) from forumThread");
$max++; $max++;
WebGUI::SQL->write("update incrementer set nextValue=$max where incrementerId='forumThreadId'"); 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'");
#-------------------------------------------- #--------------------------------------------

File diff suppressed because one or more lines are too long

View file

@ -39,7 +39,14 @@ sub get {
sub getReplies { sub getReplies {
my ($self) = @_; my ($self) = @_;
my @replies = (); 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) { while (my @data = $sth->array) {
push(@replies,WebGUI::Forum::Post->new($data[0])); push(@replies,WebGUI::Forum::Post->new($data[0]));
} }

View file

@ -75,7 +75,7 @@ sub formatPreviousThreadURL {
} }
sub formatRatePostURL { 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 { sub formatReplyPostURL {
@ -105,27 +105,27 @@ sub formatThreadLayoutURL {
} }
sub formatThreadLockURL { sub formatThreadLockURL {
return WebGUI::URL::append($_[0],"forumOp=threadLock&forumPostId=".$_[1]); return WebGUI::URL::append($_[0],"forumOp=threadLock&forumPostId=".$_[1]."#".$_[1]);
} }
sub formatThreadUnlockURL { sub formatThreadUnlockURL {
return WebGUI::URL::append($_[0],"forumOp=threadUnlock&forumPostId=".$_[1]); return WebGUI::URL::append($_[0],"forumOp=threadUnlock&forumPostId=".$_[1]."#".$_[1]);
} }
sub formatThreadStickURL { sub formatThreadStickURL {
return WebGUI::URL::append($_[0],"forumOp=threadStick&forumPostId=".$_[1]); return WebGUI::URL::append($_[0],"forumOp=threadStick&forumPostId=".$_[1]."#".$_[1]);
} }
sub formatThreadSubscribeURL { sub formatThreadSubscribeURL {
return WebGUI::URL::append($_[0],"forumOp=threadSubscribe&forumPostId=".$_[1]); return WebGUI::URL::append($_[0],"forumOp=threadSubscribe&forumPostId=".$_[1]."#".$_[1]);
} }
sub formatThreadUnstickURL { sub formatThreadUnstickURL {
return WebGUI::URL::append($_[0],"forumOp=threadUnstick&forumPostId=".$_[1]); return WebGUI::URL::append($_[0],"forumOp=threadUnstick&forumPostId=".$_[1]."#".$_[1]);
} }
sub formatThreadUnsubscribeURL { sub formatThreadUnsubscribeURL {
return WebGUI::URL::append($_[0],"forumOp=threadUnsubscribe&forumPostId=".$_[1]); return WebGUI::URL::append($_[0],"forumOp=threadUnsubscribe&forumPostId=".$_[1]."#".$_[1]);
} }
sub formatThreadURL { sub formatThreadURL {
@ -316,6 +316,7 @@ sub getForumTemplateVars {
$var{'forum.unsubscribe.label'} = WebGUI::International::get(1023); $var{'forum.unsubscribe.label'} = WebGUI::International::get(1023);
$var{'forum.unsubscribe.url'} = formatForumUnsubscribeURL($callback,$forum->get("forumId")); $var{'forum.unsubscribe.url'} = formatForumUnsubscribeURL($callback,$forum->get("forumId"));
$var{'user.isSubscribed'} = $forum->isSubscribed; $var{'user.isSubscribed'} = $forum->isSubscribed;
$var{'user.isModerator'} = $forum->isModerator;
$var{'user.canPost'} = $forum->canPost; $var{'user.canPost'} = $forum->canPost;
$var{'thread.sortby.date.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"date"); $var{'thread.sortby.date.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"date");
$var{'thread.sortby.lastreply.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"lastreply"); $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.replies.label"} = WebGUI::International::get(1016);
$var{'thread.rating.label'} = WebGUI::International::get(1020); $var{'thread.rating.label'} = WebGUI::International::get(1020);
$var{"thread.last.label"} = WebGUI::International::get(1017); $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") { if ($session{scratch}{forumSortBy} eq "date") {
$query .= "rootPostId desc"; $query .= "rootPostId desc";
} elsif ($session{scratch}{forumSortBy} eq "views") { } elsif ($session{scratch}{forumSortBy} eq "views") {

View file

@ -1,5 +0,0 @@
INSERT INTO template VALUES (1,'Default Forum','<tmpl_if canPost>\n <a href=\"<tmpl_var thread.new.url>\"><tmpl_var thread.new.label></a>\n <p />\n</tmpl_if>\n\n<table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\">\n<tr>\n <td class=\"tableHeader\"><tmpl_var thread.subject.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.user.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.views.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.replies.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.rating.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.date.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.last.label></td>\n</tr>\n<tmpl_loop thread_loop>\n<tr>\n <td class=\"tableData\"><a href=\"<tmpl_var thread.root.url>\"><tmpl_var thread.root.subject></a></td>\n <tmpl_if thread.root.user.isVisitor>\n <td class=\"tableData\"><tmpl_var thread.root.user.name></td>\n <tmpl_else>\n <td class=\"tableData\"><a href=\"<tmpl_var thread.root.user.profile>\"><tmpl_var thread.root.user.name></a></td>\n </tmpl_if>\n <td class=\"tableData\"><tmpl_var thread.views></td>\n <td class=\"tableData\"><tmpl_var thread.replies></td>\n <td class=\"tableData\"><tmpl_var thread.rating></td>\n <td class=\"tableData\"><tmpl_var thread.root.date> @ <tmpl_var thread.root.time></td>\n <td class=\"tableData\" style=\"font-size: 11px;\">\n <a href=\"<tmpl_var thread.last.url>\"><tmpl_var thread.last.subject></a>\n by \n <tmpl_if thread.last.user.isVisitor>\n <tmpl_var thread.last.user.name>\n <tmpl_else>\n <a href=\"<tmpl_var thread.last.user.profile>\"><tmpl_var thread.last.user.name></a>\n </tmpl_if>\n on <tmpl_var thread.last.date> @ <tmpl_var thread.last.time>\n </td>\n</tr>\n</tmpl_loop>\n</table>\n\n<tmpl_if multiplePages>\n <div class=\"pagination\">\n <tmpl_var previousPage> &middot; <tmpl_var pageList> &middot; <tmpl_var nextPage>\n </div>\n</tmpl_if>','Forum');
INSERT INTO template VALUES (1,'Default Post Form','<h1><tmpl_var header></h1>\n\n<tmpl_var form.begin>\n<table>\n\n<tmpl_if isVisitor>\n <tr><td><tmpl_var visitorName.label></td><td><tmpl_var visitorName.form></td></tr>\n</tmpl_if>\n\n<tr><td><tmpl_var subject.label></td><td><tmpl_var subject.form></td></tr>\n<tr><td><tmpl_var message.label></td><td><tmpl_var message.form></td></tr>\n\n<tmpl_if isNewMessage>\n <tr><td><tmpl_var subscribe.label></td><td><tmpl_var subscribe.form></td></tr>\n <tmpl_if isModerator>\n <tr><td><tmpl_var lock.label></td><td><tmpl_var lock.form></td></tr>\n <tr><td><tmpl_var sticky.label></td><td><tmpl_var sticky.form></td></tr>\n </tmpl_if>\n</tmpl_if>\n\n<tr><td><tmpl_var contentType.label></td><td><tmpl_var contentType.form></td></tr>\n<tr><td></td><td><tmpl_var form.submit></td></tr>\n\n</table>\n<tmpl_var form.end>\n\n<p>\n<tmpl_var post.full>\n</p>','Forum/PostForm');
INSERT INTO template VALUES (1,'Default Post','<h1><tmpl_var post.subject></h1>\n\n<table width=\"100%\">\n<tr>\n<td class=\"content\" valign=\"top\">\n<tmpl_var post.message>\n<tmpl_unless post.isLocked>\n <tmpl_if canPost>\n <p />\n <a href=\"<tmpl_var post.reply.url>\"><tmpl_var post.reply.label></a>\n <tmpl_unless post.hasRated>\n &bull; <tmpl_var post.rate.label>: [ <a href=\"<tmpl_var post.rate.url.1>\">1</a>, <a href=\"<tmpl_var post.rate.url.2>\">2</a>, \n <a href=\"<tmpl_var post.rate.url.3>\">3</a>, <a href=\"<tmpl_var post.rate.url.4>\">4</a>, <a href=\"<tmpl_var post.rate.url.5>\">5</a> ]\n </tmpl_unless>\n </tmpl_if>\n <tmpl_if post.canEdit>\n &bull; <a href=\"<tmpl_var post.edit.url>\"><tmpl_var post.edit.label></a>\n &bull; <a href=\"<tmpl_var post.delete.url>\"><tmpl_var post.delete.label></a>\n </tmpl_if>\n <tmpl_if post.isModerator>\n &bull; <a href=\"<tmpl_var post.approve.url>\"><tmpl_var post.approve.label></a>\n &bull; <a href=\"<tmpl_var post.deny.url>\"><tmpl_var post.deny.label></a>\n </tmpl_if>\n</tmpl_unless>\n</td><td valign=\"top\" class=\"tableHeader\" width=\"170\" nowrap=\"1\">\n<b><tmpl_var post.date.label>:</b> <tmpl_var post.date.value> @ <tmpl_var post.time.value><br />\n<b><tmpl_var post.rating.label>:</b> <tmpl_var post.rating.value><br />\n<b><tmpl_var post.views.label>:</b> <tmpl_var post.views.value><br />\n<b><tmpl_var post.status.label>:</b> <tmpl_var post.status.value><br />\n<tmpl_if post.user.isVisitor>\n <b><tmpl_var post.user.label>:</b> <tmpl_var post.user.name><br />\n<tmpl_else>\n <b><tmpl_var post.user.label>:</b> <a href=\"<tmpl_var post.user.profile>\"><tmpl_var post.user.name></a><br />\n</tmpl_if>\n</td>\n</tr>\n</table>','Forum/Post');
INSERT INTO template VALUES (1,'Default Thread','<a href=\"<tmpl_var thread.list.url>\"><tmpl_var thread.list.label></a> &bull;\n<a href=\"<tmpl_var thread.previous.url>\"><tmpl_var thread.previous.label></a> &bull;\n<a href=\"<tmpl_var thread.next.url>\"><tmpl_var thread.next.label></a> \n<tmpl_if canPost>\n &bull; <a href=\"<tmpl_var thread.new.url>\"><tmpl_var thread.new.label></a>\n</tmpl_if>\n<p />\n\n<tmpl_if thread.layout.isFlat>\n <tmpl_loop post_loop>\n <a name=\"<tmpl_var post.id>\"></a>\n <tmpl_if post.isCurrent>\n <div class=\"highlight\"><tmpl_var post.full></div>\n <tmpl_else>\n <tmpl_var post.full>\n </tmpl_if>\n </tmpl_loop>\n</tmpl_if>\n\n<tmpl_if thread.layout.isNested>\n <tmpl_loop post_loop>\n <table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\">\n <tmpl_if post.isCurrent>\n <tr class=\"highlight\">\n <tmpl_else>\n <tr>\n </tmpl_if>\n <tmpl_loop post.indent_loop>\n <td width=\"20\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>\n </tmpl_loop>\n <td>\n <a name=\"<tmpl_var post.id>\"></a>\n <tmpl_var post.full>\n </td>\n </tr>\n </table>\n </tmpl_loop>\n</tmpl_if>\n\n<tmpl_if thread.layout.isThreaded>\n <tmpl_var post.full>\n <table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0\">\n <tr>\n <td class=\"tableHeader\"><tmpl_var thread.subject.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.user.label></td>\n <td class=\"tableHeader\"><tmpl_var thread.date.label></td>\n </tr>\n <tmpl_loop post_loop>\n <tmpl_if post.isCurrent>\n <tr class=\"highlight\">\n <tmpl_else>\n <tr>\n </tmpl_if>\n <td class=\"tableData\"><tmpl_loop post.indent_loop>&nbsp;&nbsp;&nbsp;</tmpl_loop><a href=\"<tmpl_var post.url>\"><tmpl_var post.subject></a></td>\n <tmpl_if thread.root.user.isVisitor>\n <td class=\"tableData\"><tmpl_var post.user.name></td>\n <tmpl_else>\n <td class=\"tableData\"><a href=\"<tmpl_var post.user.profile>\"><tmpl_var post.user.name></a></td>\n </tmpl_if>\n <td class=\"tableData\"><tmpl_var post.date.value> @ <tmpl_var post.time.value></td>\n </tr>\n </tmpl_loop>\n </table>\n</tmpl_if>\n\n<p />\n<a href=\"<tmpl_var thread.list.url>\"><tmpl_var thread.list.label></a> &bull;\n<a href=\"<tmpl_var thread.previous.url>\"><tmpl_var thread.previous.label></a> &bull;\n<a href=\"<tmpl_var thread.next.url>\"><tmpl_var thread.next.label></a> &bull;\n<a href=\"<tmpl_var thread.new.url>\"><tmpl_var thread.new.label></a>\n','Forum/Thread');

View file

@ -212,7 +212,7 @@ sub www_view {
$count++; $count++;
} }
$sth->finish; $sth->finish;
$var{areMultipleForums} = ($count > 1); $var{areMultipleForums} = ($count > 2);
$var{forum_loop} = \@forum_loop; $var{forum_loop} = \@forum_loop;
return $_[0]->processTemplate($_[0]->get("templateId"),\%var); return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
} }

View file

@ -516,6 +516,9 @@ sub www_viewSubmission {
my $submission = $_[0]->getCollateral("USS_submission","USS_submissionId",$session{form}{sid}); my $submission = $_[0]->getCollateral("USS_submission","USS_submissionId",$session{form}{sid});
return $_[0]->www_view unless ($submission->{USS_submissionId}); return $_[0]->www_view unless ($submission->{USS_submissionId});
my $callback = WebGUI::URL::page("func=viewSubmission&amp;wid=".$_[0]->get("wobjectId")."&amp;sid=".$submission->{USS_submissionId}); my $callback = WebGUI::URL::page("func=viewSubmission&amp;wid=".$_[0]->get("wobjectId")."&amp;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}"); WebGUI::SQL->write("update USS_submission set views=views+1 where USS_submissionId=$session{form}{sid}");
$var{title} = $submission->{title}; $var{title} = $submission->{title};
$var{content} = WebGUI::HTML::filter($submission->{content},$_[0]->get("filterContent")); $var{content} = WebGUI::HTML::filter($submission->{content},$_[0]->get("filterContent"));
@ -579,11 +582,7 @@ sub www_viewSubmission {
$var{"attachment.name"} = $file->getFilename; $var{"attachment.name"} = $file->getFilename;
} }
if ($_[0]->get("allowDiscussion")) { if ($_[0]->get("allowDiscussion")) {
if ($session{form}{forumOp}) { $var{"replies"} = WebGUI::Forum::UI::www_viewForum($callback,$submission->{forumId});
$var{"replies"} = WebGUI::Forum::UI::forumOp($callback);
} else {
$var{"replies"} = WebGUI::Forum::UI::www_viewForum($callback,$submission->{forumId});
}
} }
return WebGUI::Template::process(WebGUI::Template::get($_[0]->get("submissionTemplateId"),"USS/Submission"), \%var); return WebGUI::Template::process(WebGUI::Template::get($_[0]->get("submissionTemplateId"),"USS/Submission"), \%var);
} }

View file

@ -19,13 +19,17 @@ use WebGUI::SQL;
#----------------------------------------- #-----------------------------------------
sub process { sub process {
my $epoch = WebGUI::DateTime::time(); 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) { 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 $archiveDate = $epoch - $forum->{archiveAfter};
my $b = WebGUI::SQL->read("select forumThreadId from forumThread where forumId=".$forum->{forumId} my $b = WebGUI::SQL->read("select forumThreadId from forumThread where forumId=".$forum->{forumId}
." and lastPostDate<$archiveDate"); ." and lastPostDate<$archiveDate");
while (my ($threadId) = $b->array) { while (my ($threadId) = $b->array) {
WebGUI::SQL->write("update forumPost set status='archived' where status='approved' and forumThreadId=$threadId"); 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; $b->finish;
} }