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 4221841b7..efaba1679 100644 --- a/docs/upgrades/upgrade_5.4.4-5.5.0.sql +++ b/docs/upgrades/upgrade_5.4.4-5.5.0.sql @@ -206,6 +206,14 @@ insert into international (internationalId,languageId,namespace,message,lastUpda 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 (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.'); + diff --git a/lib/WebGUI/Forum/UI.pm b/lib/WebGUI/Forum/UI.pm index 0971be34e..3c3723a50 100644 --- a/lib/WebGUI/Forum/UI.pm +++ b/lib/WebGUI/Forum/UI.pm @@ -87,10 +87,26 @@ sub formatStatus { } } +sub formatThreadLockURL { + return WebGUI::URL::append($_[0],"forumOp=threadLock&forumPostId=".$_[1]); +} + +sub formatThreadUnlockURL { + return WebGUI::URL::append($_[0],"forumOp=threadUnlock&forumPostId=".$_[1]); +} + +sub formatThreadStickURL { + return WebGUI::URL::append($_[0],"forumOp=threadStick&forumPostId=".$_[1]); +} + sub formatThreadSubscribeURL { return WebGUI::URL::append($_[0],"forumOp=threadSubscribe&forumPostId=".$_[1]); } +sub formatThreadUnstickURL { + return WebGUI::URL::append($_[0],"forumOp=threadUnstick&forumPostId=".$_[1]); +} + sub formatThreadUnsubscribeURL { return WebGUI::URL::append($_[0],"forumOp=threadUnsubscribe&forumPostId=".$_[1]); } @@ -243,6 +259,8 @@ sub forumOp { sub getForumTemplateVars { my ($callback, $forum) = @_; my (%var, @thread_loop); + $var{'callback.url'} = $callback; + $var{'callback.label'} = WebGUI::International::get(1039); $var{'user.isVisitor'} = ($session{user}{userId} == 1); $var{'thread.new.url'} = formatNewThreadURL($callback,$forum->get("forumId")); $var{'thread.new.label'} = WebGUI::International::get(1018); @@ -315,6 +333,8 @@ sub getForumTemplateVars { sub getPostTemplateVars { my ($post, $thread, $forum, $callback, $var) = @_; + $var->{'callback.url'} = $callback; + $var->{'callback.label'} = WebGUI::International::get(1039); $var->{'post.subject.label'} = WebGUI::International::get(229); $var->{'post.subject'} = WebGUI::HTML::filter($post->get("subject"),"none"); $var->{'post.message'} = WebGUI::HTML::filter($post->get("message"),$forum->get("filterPosts")); @@ -391,13 +411,26 @@ sub getThreadTemplateVars { my $forum = $thread->getForum; my $var = getPostTemplateVars($post, $thread, $forum, $callback); my $root = WebGUI::Forum::Post->new($thread->get("rootPostId")); + $var->{'callback.url'} = $callback; + $var->{'callback.label'} = WebGUI::International::get(1039); $var->{'user.canPost'} = $forum->canPost; - $var->{'user.isSubscribed'} = $thread->isSubscribed; $var->{'user.isVisitor'} = ($session{user}{userId} == 1); + $var->{'user.isModerator'} = $forum->isModerator; + $var->{'user.isSubscribed'} = $thread->isSubscribed; $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")); $var->{'thread.unsubscribe.label'} = WebGUI::International::get(874); + $var->{'thread.isSticky'} = $thread->isSticky; + $var->{'thread.stick.url'} = formatThreadStickURL($callback,$post->get("forumPostId")); + $var->{'thread.stick.label'} = WebGUI::International::get(1037); + $var->{'thread.unstick.url'} = formatThreadUnstickURL($callback,$post->get("forumPostId")); + $var->{'thread.unstick.label'} = WebGUI::International::get(1038); + $var->{'thread.isLocked'} = $thread->isLocked; + $var->{'thread.lock.url'} = formatThreadLockURL($callback,$post->get("forumPostId")); + $var->{'thread.lock.label'} = WebGUI::International::get(1040); + $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"); @@ -532,7 +565,7 @@ sub www_post { $var->{'newpost.isReply'} = ($session{form}{parentId} ne ""); $var->{'newpost.isEdit'} = ($session{form}{forumPostId} ne ""); $var->{'user.isVisitor'} = ($session{user}{userId} == 1); - $var->{'newpost.isNewMessage'} = ($var->{isNewThread} || $var->{isReply}); + $var->{'newpost.isNewMessage'} = ($var->{'newpost.isNewThread'} || $var->{'newpost.isReply'}); $var->{'form.begin'} = WebGUI::Form::formHeader({ action=>$callback }); @@ -702,6 +735,30 @@ sub www_ratePost { return www_viewThread($callback,$session{form}{forumPostId}); } +sub www_threadLock { + my ($callback) = @_; + my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); + return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator); + $post->getThread->lock; + return www_viewThread($callback, $session{form}{forumPostId}); +} + +sub www_threadUnlock { + my ($callback) = @_; + my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); + return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator); + $post->getThread->unlock; + return www_viewThread($callback, $session{form}{forumPostId}); +} + +sub www_threadStick { + my ($callback) = @_; + my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); + return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator); + $post->getThread->stick; + return www_viewThread($callback, $session{form}{forumPostId}); +} + sub www_threadSubscribe { my ($callback) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); @@ -710,6 +767,14 @@ sub www_threadSubscribe { return www_viewThread($callback, $session{form}{forumPostId}); } +sub www_threadUnstick { + my ($callback) = @_; + my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); + return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator); + $post->getThread->unstick; + return www_viewThread($callback, $session{form}{forumPostId}); +} + sub www_threadUnsubscribe { my ($callback) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});