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 efaba1679..fca9bc8d9 100644 --- a/docs/upgrades/upgrade_5.4.4-5.5.0.sql +++ b/docs/upgrades/upgrade_5.4.4-5.5.0.sql @@ -150,11 +150,11 @@ 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 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); +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; -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (513,1,'WebGUI','Go to previous thread.', 1065280287,NULL); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1019,1,'WebGUI','Back to thread list.', 1065280160,'Return to the list of threads in a discussion.'); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1018,1,'WebGUI','Start a new thread.', 1065279960,'Add a new line of discussion to a forum.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (513,1,'WebGUI','Go to previous thread', 1065280287,NULL); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1019,1,'WebGUI','Back to thread list', 1065280160,'Return to the list of threads in a discussion.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1018,1,'WebGUI','Start a new thread', 1065279960,'Add a new line of discussion to a forum.'); insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1020,1,'WebGUI','Rating', 1065280882,'How useful/interesting a user thinks another poster\'s post is.'); alter table forumThread add column status varchar(30) not null default 'approved'; create table forumPostRating ( forumPostId int not null, userId int not null, ipAddress varchar(16), dateOfRating int, rating int not null); @@ -163,12 +163,12 @@ insert into international (internationalId,languageId,namespace,message,lastUpda alter table forumThread add column rating int not null; delete from international where languageId=1 and namespace='WebGUI' and internationalId=875; insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (875,1,'WebGUI','A new message has been posted to one of your subscriptions.', 1065874019,NULL); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1023,1,'WebGUI','Unsubscribe from discussion.', 1065875186,'A label for a link that unsubscribes the user from the discussion they are currently viewing.'); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1022,1,'WebGUI','Subscribe to discussion.', 1065875027,'A label for a link that subscribes the user to the discussion they are currently viewing.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1023,1,'WebGUI','Unsubscribe from discussion', 1065875186,'A label for a link that unsubscribes the user from the discussion they are currently viewing.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1022,1,'WebGUI','Subscribe to discussion', 1065875027,'A label for a link that subscribes the user to the discussion they are currently viewing.'); delete from international where languageId=1 and namespace='WebGUI' and internationalId=874; -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (874,1,'WebGUI','Unsubscribe from thread.', 1065876868,NULL); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (874,1,'WebGUI','Unsubscribe from thread', 1065876868,NULL); delete from international where languageId=1 and namespace='WebGUI' and internationalId=873; -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (873,1,'WebGUI','Subscribe to thread.', 1065876827,NULL); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (873,1,'WebGUI','Subscribe to thread', 1065876827,NULL); alter table forum add column views int not null default 0; alter table forum add column replies int not null default 0; alter table forum add column rating int not null default 0; @@ -202,17 +202,26 @@ insert into international (internationalId,languageId,namespace,message,lastUpda insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1033,1,'WebGUI','Post Template', 1066034603,'Tell the admin to select a template for posts in this forum.'); insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1032,1,'WebGUI','Thread Template', 1066034586,'Tell the admin to select a template for threads in this forum.'); insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1031,1,'WebGUI','Forum Template', 1066034528,'Tell the admin to select a template for this forum.'); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (75,1,'MessageBoard','Add a forum.', 1066038194,'A label for a link that allows an admin to add a forum to a message board.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (75,1,'MessageBoard','Add a forum', 1066038194,'A label for a link that allows an admin to add a forum to a message board.'); insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1036,1,'WebGUI','Threads', 1066038155,'A label indicating how many threads there are in a particular forum.'); delete from template where namespace='MessageBoard'; alter table MessageBoard_forums add column sequenceNumber int not null default 1; insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (77,1,'MessageBoard','Edit Forum', 1066061199,'A title for the forum editing page.'); insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (76,1,'MessageBoard','Are you certain you wish to delete this forum and all the posts it contains?', 1066055963,'A question prompting the admin whether they truely want to delete a forum from a message board.'); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1038,1,'WebGUI','Unstick.', 1066065454,'A label for a link that makes the current thread not sticky.'); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1037,1,'WebGUI','Make sticky.', 1066065402,'A label for a link that makes the current thread sticky.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1038,1,'WebGUI','Unstick', 1066065454,'A label for a link that makes the current thread not sticky.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1037,1,'WebGUI','Make sticky', 1066065402,'A label for a link that makes the current thread sticky.'); insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1039,1,'WebGUI','Back', 1066073289,'A generic term meaning to go to a place in history, or more specifically, a page in the user\'s history.'); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1041,1,'WebGUI','Unlock.', 1066073967,'A label for a link that unlocks the current thread.'); -insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1040,1,'WebGUI','Lock.', 1066073923,'A label for a link that locks the current thread.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1041,1,'WebGUI','Unlock', 1066073967,'A label for a link that unlocks the current thread.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1040,1,'WebGUI','Lock', 1066073923,'A label for a link that locks the current thread.'); +alter table template change template template mediumtext; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1044,1,'WebGUI','Search Template', 1066394621,'Tell the admin to select a template for search results.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1043,1,'WebGUI','Archive After', 1066394455,'A label indicating that the administrator needs to enter an interval that specifies how long posts will remain viewable before archiving.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1042,1,'WebGUI','Posts Per Page', 1066394411,'A label indicating that the administrator needs to enter an integer that specifies how many posts will be displayed per page on the discussion.'); +alter table forum add column searchTemplateId int not null default 1; +alter table forum add column archiveAfter int not null default 31536000; +alter table forum add column postsPerPage int not null default 30; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1045,1,'WebGUI','Nested', 1066405110,'A label indicating the layout of a forum thread.'); +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1046,1,'WebGUI','Archived', 1066406723,'A label indicating that the content has a status of archived.'); diff --git a/lib/WebGUI/Forum/UI.pm b/lib/WebGUI/Forum/UI.pm index 3c3723a50..a4a8aa836 100644 --- a/lib/WebGUI/Forum/UI.pm +++ b/lib/WebGUI/Forum/UI.pm @@ -9,6 +9,7 @@ use WebGUI::Forum::Post; use WebGUI::Forum::Thread; use WebGUI::HTML; use WebGUI::MessageLog; +use WebGUI::Search; use WebGUI::Session; use WebGUI::Template; @@ -33,8 +34,12 @@ sub formatEditPostURL { return WebGUI::URL::append($_[0],"forumOp=post&forumPostId=".$_[1]); } -sub formatForumURL { - return WebGUI::URL::append($_[0],"forumOp=viewForum&forumId=".$_[1]); +sub formatForumSearchURL { + return WebGUI::URL::append($_[0],"forumOp=search&forumId=".$_[1]); +} + +sub formatForumSortByURL { + return WebGUI::URL::append($_[0],"forumOp=viewForum&forumId=".$_[1]."&sortBy=".$_[2]); } sub formatForumSubscribeURL { @@ -45,6 +50,10 @@ sub formatForumUnsubscribeURL { return WebGUI::URL::append($_[0],"forumOp=forumUnsubscribe&forumId=".$_[1]); } +sub formatForumURL { + return WebGUI::URL::append($_[0],"forumOp=viewForum&forumId=".$_[1]); +} + sub formatNextThreadURL { return WebGUI::URL::append($_[0],"forumOp=nextThread&forumThreadId=".$_[1]); } @@ -70,7 +79,9 @@ sub formatRatePostURL { } sub formatReplyPostURL { - return WebGUI::URL::append($_[0],"forumOp=post&parentId=".$_[1]); + my $url = WebGUI::URL::append($_[0],"forumOp=post&parentId=".$_[1]); + $url = WebGUI::URL::append($url,"withQuote=1") if ($_[2]); + return $url; } sub formatSubject { @@ -84,9 +95,15 @@ sub formatStatus { return WebGUI::International::get(561); } elsif ($_[0] eq "pending") { return WebGUI::International::get(562); + } elsif ($_[0] eq "archived") { + return WebGUI::International::get(1046); } } +sub formatThreadLayoutURL { + return WebGUI::URL::append($_[0],"forumOp=viewThread&forumPostId=".$_[1]."&layout=".$_[2]); +} + sub formatThreadLockURL { return WebGUI::URL::append($_[0],"forumOp=threadLock&forumPostId=".$_[1]); } @@ -145,6 +162,12 @@ sub forumProperties { -namespace=>"Forum/Post", -uiLevel=>5 ); + $f->template( + -name=>"searchTemplateId", + -label=>WebGUI::International::get(1044), + -namespace=>"Forum/Search", + -uiLevel=>5 + ); $f->template( -name=>"postFormTemplateId", -label=>WebGUI::International::get(1034), @@ -157,6 +180,14 @@ sub forumProperties { -namespace=>"Forum/Notification", -uiLevel=>5 ); + my ($interval, $units) = WebGUI::DateTime::secondsToInterval(($forum->get("archiveAfter") || 31536000)); + $f->interval( + -name=>"archiveAfter", + -label=>WebGUI::International::get(1043), + -intervalValue=>$interval, + -unitsValue=>$units, + -uiLevel=>9 + ); my ($interval, $units) = WebGUI::DateTime::secondsToInterval(($forum->get("editTimeout") || 3600)); $f->interval( -name=>"editTimeout", @@ -189,6 +220,12 @@ sub forumProperties { -label=>WebGUI::International::get(1024), -uiLevel=>7 ); + $f->integer( + -name=>"postsPerPage", + -label=>WebGUI::International::get(1042), + -value=>$forum->get("postsPerPage")||30, + -uiLevel=>7 + ); if ($session{setting}{useKarma}) { $f->integer( -name=>"karmaPerPost", @@ -226,11 +263,19 @@ sub forumProperties { sub forumPropertiesSave { my %data = ( + forumTemplateId=>$session{form}{forumTemplateId}, + threadTemplateId=>$session{form}{threadTemplateId}, + postTemplateId=>$session{form}{postTemplateId}, + searchTemplateId=>$session{form}{searchTemplateId}, + notificationTemplateId=>$session{form}{notificationTemplateId}, + postFormTemplateId=>$session{form}{postFormTemplateId}, editTimeout=>WebGUI::FormProcessor::interval("editTimeout"), + archiveAfter=>WebGUI::FormProcessor::interval("archiveAfter"), addEditStampToPosts=>$session{form}{addEditStampToPosts}, allowRichEdit=>$session{form}{allowRichEdit}, allowReplacements=>$session{form}{allowReplacements}, filterPosts=>$session{form}{filterPosts}, + postsPerPage=>$session{form}{postsPerPage}, karmaPerPost=>$session{form}{karmaPerPost}, groupToPost=>$session{form}{groupToPost}, moderatePosts=>$session{form}{moderatePosts}, @@ -264,12 +309,19 @@ sub getForumTemplateVars { $var{'user.isVisitor'} = ($session{user}{userId} == 1); $var{'thread.new.url'} = formatNewThreadURL($callback,$forum->get("forumId")); $var{'thread.new.label'} = WebGUI::International::get(1018); + $var{'forum.search.label'} = WebGUI::International::get(364); + $var{'forum.search.url'} = formatForumSearchURL($callback,$forum->get("forumId")); $var{'forum.subscribe.label'} = WebGUI::International::get(1022); $var{'forum.subscribe.url'} = formatForumSubscribeURL($callback,$forum->get("forumId")); $var{'forum.unsubscribe.label'} = WebGUI::International::get(1023); $var{'forum.unsubscribe.url'} = formatForumUnsubscribeURL($callback,$forum->get("forumId")); $var{'user.isSubscribed'} = $forum->isSubscribed; $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"); + $var{'thread.sortby.views.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"views"); + $var{'thread.sortby.replies.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"replies"); + $var{'thread.sortby.rating.url'} = formatForumSortByURL($callback,$forum->get("forumId"),"rating"); $var{'thread.subject.label'} = WebGUI::International::get(229); $var{'thread.date.label'} = WebGUI::International::get(245); $var{'thread.user.label'} = WebGUI::International::get(244); @@ -277,14 +329,28 @@ 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 $p = WebGUI::Paginator->new($callback); - $p->setDataByQuery("select * from forumThread where forumId=".$forum->get("forumId")." order by isSticky desc, lastPostDate desc"); + my $query = "select * from forumThread where forumId=".$forum->get("forumId")." order by isSticky desc, "; + if ($session{scratch}{forumSortBy} eq "date") { + $query .= "rootPostId desc"; + } elsif ($session{scratch}{forumSortBy} eq "views") { + $query .= "views desc"; + } elsif ($session{scratch}{forumSortBy} eq "replies") { + $query .= "replies desc"; + } elsif ($session{scratch}{forumSortBy} eq "rating") { + $query .= "rating desc"; + } else { + $query .= "lastPostDate desc"; + } + my $p = WebGUI::Paginator->new($callback,"",$forum->get("postsPerPage")); + $p->setDataByQuery($query); $var{firstPage} = $p->getFirstPageLink; $var{lastPage} = $p->getLastPageLink; $var{nextPage} = $p->getNextPageLink; $var{pageList} = $p->getPageLinks; $var{previousPage} = $p->getPreviousPageLink; $var{multiplePages} = ($p->getNumberOfPages > 1); + $var{numberOfPages} = $p->getNumberOfPages; + $var{pageNumber} = $p->getPageNumber; my $threads = $p->getPageData; foreach my $thread (@$threads) { my $root = WebGUI::Forum::Post->new($thread->{rootPostId}); @@ -392,6 +458,7 @@ sub getPostTemplateVars { $var->{'post.hasRated'} = $post->hasRated; $var->{'post.reply.label'} = WebGUI::International::get(577); $var->{'post.reply.url'} = formatReplyPostURL($callback,$post->get("forumPostId")); + $var->{'post.reply.withquote.url'} = formatReplyPostURL($callback,$post->get("forumPostId"),1); $var->{'post.edit.label'} = WebGUI::International::get(575); $var->{'post.edit.url'} = formatEditPostURL($callback,$post->get("forumPostId")); $var->{'post.delete.label'} = WebGUI::International::get(576); @@ -417,6 +484,16 @@ sub getThreadTemplateVars { $var->{'user.isVisitor'} = ($session{user}{userId} == 1); $var->{'user.isModerator'} = $forum->isModerator; $var->{'user.isSubscribed'} = $thread->isSubscribed; + $var->{'thread.layout.nested.label'} = WebGUI::International::get(1045); + $var->{'thread.layout.nested.url'} = formatThreadLayoutURL($callback,$post->get("forumPostId"),"nested"); + $var->{'thread.layout.flat.label'} = WebGUI::International::get(510); + $var->{'thread.layout.flat.url'} = formatThreadLayoutURL($callback,$post->get("forumPostId"),"flat"); + $var->{'thread.layout.threaded.label'} = WebGUI::International::get(511); + $var->{'thread.layout.threaded.url'} = formatThreadLayoutURL($callback,$post->get("forumPostId"),"threaded"); + my $layout = $session{scratch}{forumThreadLayout} || $session{user}{discussionLayout}; + $var->{'thread.layout.isFlat'} = ($layout eq "flat"); + $var->{'thread.layout.isNested'} = ($layout eq "nested"); + $var->{'thread.layout.isThreaded'} = ($layout eq "threaded" || !($var->{'thread.layout.isNested'} || $var->{'thread.layout.isFlat'})); $var->{'thread.subscribe.url'} = formatThreadSubscribeURL($callback,$post->get("forumPostId")); $var->{'thread.subscribe.label'} = WebGUI::International::get(873); $var->{'thread.unsubscribe.url'} = formatThreadUnsubscribeURL($callback,$post->get("forumPostId")); @@ -432,9 +509,6 @@ sub getThreadTemplateVars { $var->{'thread.unlock.url'} = formatThreadUnlockURL($callback,$post->get("forumPostId")); $var->{'thread.unlock.label'} = WebGUI::International::get(1041); $var->{post_loop} = recurseThread($root, $thread, $forum, 0, $callback, $post->get("forumPostId")); - $var->{'thread.layout.isFlat'} = ($session{user}{discussionLayout} eq "flat"); - $var->{'thread.layout.isNested'} = ($session{user}{discussionLayout} eq "nested"); - $var->{'thread.layout.isThreaded'} = ($session{user}{discussionLayout} eq "threaded" || !($var->{'thread.layout.isNested'} || $var->{'thread.layout.isFlat'})); $var->{'thread.subject.label'} = WebGUI::International::get(229); $var->{'thread.date.label'} = WebGUI::International::get(245); $var->{'thread.user.label'} = WebGUI::International::get(244); @@ -578,6 +652,7 @@ sub www_post { name=>'parentId', value=>$reply->get("forumPostId") }); + $message = "[quote]".$reply->get("message")."[/quote]" if ($session{form}{withQuote}); $forum = $reply->getThread->getForum; $var = getPostTemplateVars($reply, $reply->getThread, $forum, $callback, $var); @@ -735,6 +810,95 @@ sub www_ratePost { return www_viewThread($callback,$session{form}{forumPostId}); } +sub www_search { + my ($callback) = @_; + my $forum = WebGUI::Forum->new($session{form}{forumId}); + WebGUI::Session::setScratch("all",$session{form}{all}); + WebGUI::Session::setScratch("atLeastOne",$session{form}{atLeastOne}); + WebGUI::Session::setScratch("exactPhrase",$session{form}{exactPhrase}); + WebGUI::Session::setScratch("without",$session{form}{without}); + WebGUI::Session::setScratch("numResults",$session{form}{numResults}); + my %var; + $var{'callback.url'} = $callback; + $var{'callback.label'} = WebGUI::International::get(1039); + $var{'form.begin'} = WebGUI::Form::formHeader({action=>$callback}); + $var{'form.begin'} .= WebGUI::Form::hidden({ name=>"forumOp", value=>"search" }); + $var{'form.begin'} .= WebGUI::Form::hidden({ name=>"doit", value=>1 }); + $var{'form.begin'} .= WebGUI::Form::hidden({ name=>"forumId", value=>$session{form}{forumId} }); + $var{'search.label'} = WebGUI::International::get(364); + $var{'all.label'} = WebGUI::International::get(530); + $var{'all.form'} = WebGUI::Form::text({ + name=>'all', + value=>$session{scratch}{all}, + size=>($session{setting}{textBoxSize}-5) + }); + $var{'exactphrase.label'} = WebGUI::International::get(531); + $var{'exactphrase.form'} = WebGUI::Form::text({ + name=>'exactPhrase', + value=>$session{scratch}{exactPhrase}, + size=>($session{setting}{textBoxSize}-5) + }); + $var{'atleastone.label'} = WebGUI::International::get(532); + $var{'atleastone.form'} = WebGUI::Form::text({ + name=>'atLeastOne', + value=>$session{scratch}{atLeastOne}, + size=>($session{setting}{textBoxSize}-5) + }); + $var{'without.label'} = WebGUI::International::get(533); + $var{'without.form'} = WebGUI::Form::text({ + name=>'without', + value=>$session{scratch}{without}, + size=>($session{setting}{textBoxSize}-5) + }); + $var{'results.label'} = WebGUI::International::get(529); + my %results; + tie %results, 'Tie::IxHash'; + %results = (10=>'10', 25=>'25', 50=>'50', 100=>'100'); + my $numResults = $session{scratch}{numResults} || 25; + $var{'results.form'} = WebGUI::Form::selectList({ + name=>"numResults", + options=>\%results, + value=>[$numResults] + }); + $var{'form.search'} = WebGUI::Form::submit({value=>WebGUI::International::get(170)}); + $var{'form.end'} = ''; + $var{'thread.list.url'} = formatForumURL($callback,$forum->get("forumId")); + $var{'thread.list.label'} = WebGUI::International::get(1019); + $var{doit} = $session{form}{doit}; + if ($session{form}{doit}) { + $var{'post.subject.label'} = WebGUI::International::get(229); + $var{'post.date.label'} = WebGUI::International::get(245); + $var{'post.user.label'} = WebGUI::International::get(244); + my $query = "select forumPostId,subject,userId,username,dateOfPost from forumPost where (status='approved' or status='archived') and "; + $query .= WebGUI::Search::buildConstraints([qw(subject username message)]); + my $p = WebGUI::Paginator->new($callback,"", $numResults); + $p->setDataByQuery($query); + my @post_loop; + foreach my $row (@{$p->getPageData}) { + push(@post_loop,{ + 'post.subject'=>formatSubject($row->{subject}), + 'post.url'=>formatThreadURL($callback,$row->{forumPostId}), + 'post.user.name'=>$row->{username}, + 'post.user.id'=>$row->{userId}, + 'post.user.profile'=>formatUserProfileURL($row->{userId}), + 'post.epoch'=>$row->{dateOfPost}, + 'post.date'=>formatPostDate($row->{dateOfPost}), + 'post.time'=>formatPostTime($row->{dateOfPost}) + }); + } + $var{post_loop} = \@post_loop; + $var{firstPage} = $p->getFirstPageLink; + $var{lastPage} = $p->getLastPageLink; + $var{nextPage} = $p->getNextPageLink; + $var{pageList} = $p->getPageLinks; + $var{previousPage} = $p->getPreviousPageLink; + $var{multiplePages} = ($p->getNumberOfPages > 1); + $var{numberOfPages} = $p->getNumberOfPages; + $var{pageNumber} = $p->getPageNumber; + } + return WebGUI::Template::process(WebGUI::Template::get($forum->get("searchTemplateId"),"Forum/Search"), \%var); +} + sub www_threadLock { my ($callback) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); @@ -785,6 +949,7 @@ sub www_threadUnsubscribe { sub www_viewForum { my ($callback, $forumId) = @_; + WebGUI::Session::setScratch("forumSortBy",$session{form}{sortBy}); $forumId = $session{form}{forumId} unless ($forumId); my $forum = WebGUI::Forum->new($forumId); my $var = getForumTemplateVars($callback, $forum); @@ -793,6 +958,7 @@ sub www_viewForum { sub www_viewThread { my ($callback, $postId) = @_; + WebGUI::Session::setScratch("forumThreadLayout",$session{form}{layout}); $postId = $session{form}{forumPostId} unless ($postId); my $post = WebGUI::Forum::Post->new($postId); my $var = getThreadTemplateVars($callback, $post); diff --git a/sbin/Hourly/ArchiveOldPosts.pm b/sbin/Hourly/ArchiveOldPosts.pm new file mode 100644 index 000000000..5fd67c060 --- /dev/null +++ b/sbin/Hourly/ArchiveOldPosts.pm @@ -0,0 +1,36 @@ +package Hourly::ArchiveOldPosts; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2003 Plain Black LLC. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + + +use strict; +use WebGUI::DateTime; +use WebGUI::Session; +use WebGUI::SQL; + +#----------------------------------------- +sub process { + my $epoch = WebGUI::DateTime::time(); + my $a = WebGUI::SQL->read("select forumId,archiveAfter from forum"); + while (my $forum = $a->hashRef) { + 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"); + } + $b->finish; + } + $a->finish; +} + +1; +