diff --git a/docs/changelog/5.x.x.txt b/docs/changelog/5.x.x.txt index eb273d1a0..9e228dcb8 100644 --- a/docs/changelog/5.x.x.txt +++ b/docs/changelog/5.x.x.txt @@ -4,6 +4,8 @@ - Fixed bug [ 831628 ] Subscription notifications sent in wrong language. - Fixed bug [ 828071 ] USS doubles the number of replies - Fixed bug [ 831784 ] Pagination in Messeboard with multiple boards + - Fixed bug [ 836133 ] forum title and description are not template variables + 5.5.0 - Rewrote the discussion system and added many new features in the process. diff --git a/docs/upgrades/upgrade_5.5.0-5.5.1.sql b/docs/upgrades/upgrade_5.5.0-5.5.1.sql index ef7d715e3..215417771 100644 --- a/docs/upgrades/upgrade_5.5.0-5.5.1.sql +++ b/docs/upgrades/upgrade_5.5.0-5.5.1.sql @@ -5,4 +5,10 @@ INSERT INTO international VALUES (71,'USS',1,'User Submission Systems are a grea DELETE FROM international WHERE internationalId=1055 and namespace='WebGUI' and languageId = 1; INSERT INTO international VALUES (1055,'WebGUI',1,'WebGUI has a very powerful built-in discussion system. It can be attached to anything and is attached to many wobjects.\r\n

\r\nForums (aka Discussions) have many settable properties. The following is a comprehensive list:\r\n

\r\n\r\nForum Template
\r\nA template that controls the layout of the forum view.\r\n

\r\n\r\nThread Template
\r\nA template that controls the layout of the thread view.\r\n

\r\n\r\nPost Template
\r\nA template that controls the layout of the post view.\r\n

\r\n\r\nSearch Template
\r\nA template that controls the layout of the search engine interface and search results.\r\n

\r\n\r\nPost Form Template
\r\nA template that controls the form that users see when posting a new message.\r\n

\r\n\r\nNotification Template
\r\nA template that controls the layout of subscription notification messages sent to users.\r\n

\r\n\r\nArchive After
\r\nIf a thread hasn\'t had a new message after this interval has expired then it will be flagged as \"archived\" and will only be accessible via the search engine.\r\n

\r\n\r\nEdit Timeout
\r\nThe interval of time that the user has to edit their message after their inital post.\r\n

\r\nNOTE: Don\'t set this limit too high. One of the great things about discussions is that they are an accurate record of who said what. If you allow editing for a long time, then a user has a chance to go back and change his/her mind a long time after the original statement was made.\r\n

\r\n\r\nAdd edit stamp to posts?
\r\nIf set to yes then a string will be added to the bottom of a post each time its edited.\r\n

\r\n\r\nAllow rich edit?
\r\nIf set to yes then users will be able to use a rich editor when writing their posts.\r\n

\r\n\r\nAllow replacements?
\r\nIf set to yes then users will be able to use replacements in thier posts. Replacements can be managed from the settings.\r\n

\r\n\r\nFilter Post
\r\nSelect what types of content you will filter from a user\'s post.\r\n

\r\n\r\nPosts Per Page
\r\nThe number of posts to display on a single page.\r\n

\r\n\r\nKarma Per Post
\r\nHow much karma should be given to a user when they post a message?\r\n

\r\n\r\nWho can post?
\r\nA group that is allowed to post new messages.\r\n

\r\n\r\nModerate posts?
\r\nIf set to yes then posts will be set to pending by default and will not be displayed until a moderator approves the message.\r\n

\r\n\r\nWho can moderate?
\r\nA group that is allowed to moderate messages.\r\n

\r\n',1068708617,NULL); INSERT INTO international VALUES (82,'Survey',1,'Terminate Survey',1068901816,''); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=1061; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1061,1,'WebGUI','These are the template variables for the thread template.\r\n

\r\n\r\ncallback.url
\r\nThe url to the calling object such as an article or a user submission.\r\n

\r\n\r\ncallback.label
\r\nThe default label for callback.url\r\n

\r\n\r\nuser.canpost
\r\nA condition indicating whether the current user can post a new message.\r\n

\r\n\r\nuser.isVisitor
\r\nA condition indicating whether the current user is a visitor.\r\n

\r\n\r\nuser.isModerator
\r\nA condition indicating whether the current user is a moderator.\r\n

\r\n\r\nuser.isSubscribed
\r\nA condition indicating whether the current user is subscribed to this thread.\r\n

\r\n\r\nthread.layout.nested.label
\r\nThe default label for thread.layout.nested.url.\r\n

\r\n\r\nthread.layout.nested.url
\r\nA url that will change the layout of the thread to nested.\r\n

\r\n\r\nthread.layout.flat.url
\r\nA url that will change the layout of the thread to flat.\r\n

\r\n\r\nthread.layout.flat.label
\r\nThe default label for thread.layout.flat.url.\r\n

\r\n\r\nthread.layout.threaded.label
\r\nThe default label for thread.layout.threaded.url.\r\n

\r\n\r\nthread.layout.threaded.url
\r\nA url that will change the layout of the thread to threaded.\r\n

\r\n\r\nthread.layout.isThreaded
\r\nA condition indicating whether the thread layout is threaded.\r\n

\r\n\r\nthread.layout.isNested
\r\nA condition indicationg whether the thread layout is nested.\r\n

\r\n\r\nthread.layout.isFlat
\r\nA condition indicationg whether the thread layout is flat.\r\n

\r\n\r\nthread.subscribe.url
\r\nA url that will subscribe the current user to this thread.\r\n

\r\n\r\nthread.subscribe.label
\r\nThe default label for thread.subscribe.url.\r\n

\r\n\r\nthread.unsubscribe.url
\r\nA url that will unsubscribe the current user from this thread.\r\n

\r\n\r\nthread.unsubscribe.label
\r\nThe default label for thread.unsubscribe.url.\r\n

\r\n\r\nthread.isSticky
\r\nA condition indicating whether the thread is sticky.\r\n

\r\n\r\nthread.stick.url
\r\nA url that will make this thread sticky.\r\n

\r\n\r\nthread.stick.label
\r\nThe default label for thread.stick.url.\r\n

\r\n\r\nthread.unstick.url
\r\nA url that will make a sticky thread unstick.\r\n

\r\n\r\nthread.unstick.label
\r\nThe default label for thread.unstick.url.\r\n

\r\n\r\nthread.isLocked
\r\nA condition indicating whether this thread is locked.\r\n

\r\n\r\nthread.lock.url
\r\nA url that will lock this thread.\r\n

\r\n\r\nthread.lock.label
\r\nThe default label for thread.lock.url.\r\n

\r\n\r\nthread.unlock.url
\r\nA url that will unlock this thread.\r\n

\r\n\r\nthread.unlock.label
\r\nThe default label for thread.unlock.url.\r\n

\r\n\r\npost_loop
\r\nA loop containing all the posts in this thread.\r\n

\r\n\r\n

\r\n\r\npost.indent_loop
\r\nA loop to be used for indenting.\r\n

\r\n

\r\ndepth
\r\nAn integer indicating the depth. Not really useful, just hear to fill out the loop.\r\n
\r\n

\r\n\r\npost.indent.depth
\r\nAn integer indicating how many levels deep this post is.\r\n

\r\n\r\npost.isCurrent
\r\nA condition indicating whether this post is the one selected for viewing by the user.\r\n

\r\n\r\nNOTE: All of the variables from the post template are also available here.\r\n\r\n

\r\n\r\n

\r\n\r\nthread.subject.label
\r\nThe default label for subjects.\r\n

\r\n\r\nthread.date.label
\r\nThe default label for dates.\r\n

\r\n\r\nthread.user.label
\r\nThe default label for authors.\r\n

\r\n\r\nthread.new.url
\r\nA url to create a new url.\r\n

\r\n\r\nthread.new.label
\r\nThe default label for thread.new.url.\r\n

\r\n\r\nthread.previous.url
\r\nA url that will display the previous thread.\r\n

\r\n\r\nthread.previous.label
\r\nThe default label for thread.previous.url.\r\n

\r\n\r\nthread.next.url
\r\nA url that will display the next thread.\r\n

\r\n\r\nthread.next.label
\r\nThe default label for thread.next.url.\r\n

\r\n\r\nthread.list.url\r\nA url to take the user back to the thread list (aka the forum).\r\n

\r\n\r\nthread.list.label
\r\nThe default label for thread.list.url.\r\n

\r\n\r\nforum.title
\r\nThe title of this forum as passed by the calling object.\r\n

\r\n\r\nforum.description
\r\nThe description of this forum as passed by the calling object.\r\n

\r\n\r\n', 1068919471,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=1057; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1057,1,'WebGUI','The following template variables are available in forum templates.\r\n

\r\n\r\ncallback.url
\r\nA url that points to the calling object, such as an article or user submission.\r\n

\r\n\r\ncallback.label
\r\nThe default label for callback.url.\r\n

\r\n\r\nuser.isVisitor
\r\nA condition indicating whether the user is a visitor.\r\n

\r\n\r\nthread.new.url
\r\nThe url to start a new thread.\r\n

\r\n\r\nthread.new.label
\r\nThe default label for thread.new.url.\r\n

\r\n\r\nforum.search.label
\r\nThe default label for forum.search.url.\r\n

\r\n\r\nforum.search.url
\r\nThe url to access the forum search engine.\r\n

\r\n\r\n\r\nforum.subscribe.label
\r\nThe default label for forum.subscribe.url.\r\n

\r\n\r\nforum.subscribe.url
\r\nThe url to subscribe to this forum.\r\n

\r\n\r\nforum.unsubscribe.label
\r\nThe default label for forum.subscribe.url.\r\n

\r\n\r\nforum.unsubscribe.url
\r\nThe url to unsubscribe from this forum.\r\n

\r\n\r\nuser.isSubscribed
\r\nA condition indicating whether the current user is subscribed to this forum.\r\n

\r\n\r\nuser.isModerator
\r\nA condition indicating whether the current user is a moderator for this forum.\r\n

\r\n\r\nuser.canPost
\r\nA condition indicating whether the current user has the privileges necessary to post to this forum.\r\n

\r\n\r\nthread.sortby.date.url
\r\nA url that will change the sorting options to be sorted by date.\r\n

\r\n\r\nthread.sortby.lastreply.url
\r\nA url that will change the sorting options to be sorted by the date of the last reply to the thread.\r\n

\r\n\r\nthread.sortby.views.url
\r\nA url that will change the sorting options to be sorted by the number of views each thread has.\r\n

\r\n\r\nthread.sortby.replies.url
\r\nA url that will change the sorting options to be sorted by the number of replies a thread has.\r\n

\r\n\r\nthread.sortby.rating.url
\r\nA url that will change the sorting options to be sorted by the average rating of each thread.\r\n

\r\n\r\nthread.subject.label
\r\nA label for the subject column.\r\n

\r\n\r\nthread.date.label
\r\nA label for the date column.\r\n

\r\n\r\nthread.user.label
\r\nA label for the author column.\r\n

\r\n\r\nthread.views.label
\r\nA label for the views column.\r\n

\r\n\r\nthread.replies.label
\r\nA label for the replies column.\r\n

\r\n\r\nthread.rating.label
\r\nA label for the rating column.\r\n

\r\n\r\nthread.last.label
\r\nA label for the last reply column.\r\n

\r\n\r\nfirstpage
\r\nA link to the first page in a multi-page listing.\r\n

\r\n\r\nlastpage
\r\nA link to the last page in a multi-page listing.\r\n

\r\n\r\nnextpage
\r\nA link to the next page in a multi-page listing.\r\n

\r\n\r\npagelist
\r\nA series of links to every page in a multi-page listing.\r\n

\r\n\r\npreviouspage
\r\nA link to the previous page in a multi-page listing.\r\n

\r\n\r\nmultiplepages
\r\nA condition indicating whether there are multiple pages or not.\r\n

\r\n\r\nnumberOfPages
\r\nThe number of pages in a multiple page listing.\r\n

\r\n\r\npageNumber
\r\nThe number of the current page in a multi-page listing.\r\n

\r\n\r\nthread_loop
\r\nA loop containing all of the thread data.\r\n

\r\n\r\n

\r\n\r\nthread.views
\r\nThe number of views this thread has had.\r\n

\r\n\r\nthread.replies
\r\nThe number of replies this thread has had.\r\n

\r\n\r\nthread.rating
\r\nThe average rating of all the posts in this thread.\r\n

\r\n\r\nthread.rating_loop
\r\n

\r\n

\r\nthread.rating_loop.count
\r\nA counter for the rating. This can be used to \"draw\" a rating, such as adding a star for each rating, or some other visual approach.\r\n

\r\n

\r\n\r\nthread.isSticky
\r\nA condition indicating whether the thread is sticky and hence will appear at the top of the forum listing.\r\n

\r\n\r\nthread.isLocked
\r\nA condition indicating whether the thread is locked from new posts.\r\n

\r\n\r\nthread.root.subject
\r\nThe subject of the root post in this thread.\r\n

\r\n\r\nthread.root.url
\r\nThe url to view the root post.\r\n

\r\n\r\nthread.root.epoch
\r\nAn epoch date of the root post.\r\n

\r\n\r\nthread.root.date
\r\nA human readable date for the root post.\r\n

\r\n\r\nthread.root.time
\r\nA human readable time for the root post.\r\n

\r\n\r\nthread.root.user.id
\r\nThe root poster\'s user id.\r\n

\r\n\r\nthread.root.user.name
\r\nThe username of the root poster.\r\n

\r\n\r\nthread.root.user.profile
\r\nThe url of the root poster\'s profile.\r\n

\r\n\r\nthread.root.user.isVisitor
\r\nA condition indicating whether the root poster was a visitor.\r\n

\r\n\r\nthread.root.status
\r\nThe status of the root post.\r\n

\r\n\r\nthread.last.subject
\r\nThe subject of the last post made to this thread.\r\n

\r\n\r\nthread.last.url
\r\nThe url to the last post.\r\n

\r\n\r\nthread.last.epoch
\r\nThe post time of the last post represented as an epoch.\r\n

\r\n\r\nthread.last.date
\r\nThe human readable date of the last post.\r\n

\r\n\r\nthread.last.time
\r\nThe human readable time of the last post.\r\n

\r\n\r\nthread.last.user.profile
\r\nThe url of the last posters profile.\r\n

\r\n\r\nthread.last.user.id
\r\nThe userId of the last poster.\r\n

\r\n\r\nthread.last.user.name
\r\nThe username of the last poster.\r\n

\r\n\r\nthread.last.user.isVisitor
\r\nA condition indicating whether the last poster was a visitor.\r\n

\r\n\r\nthread.last.status
\r\nThe status of the last post.\r\n

\r\n\r\nforum.title
\r\nThe title of this forum as passed by the calling object.\r\n

\r\n\r\nforum.description
\r\nThe description of this forum as passed by the calling object.\r\n

\r\n\r\n\r\n\r\n

\r\n', 1068919452,NULL); +delete from international where languageId=1 and namespace='WebGUI' and internationalId=1059; +insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1059,1,'WebGUI','The following are the template variables available in the post template.\r\n

\r\n\r\ncallback.url
\r\nThe url back to the calling object such as an article or user submission.\r\n

\r\n\r\ncallback.label
\r\nThe default label for callback.url.\r\n

\r\n\r\npost.subject.label
\r\nThe default label for post.subject\r\n

\r\n\r\npost.subject
\r\nThe subject of this post.\r\n

\r\n\r\npost.message
\r\nThe message of this post.\r\n

\r\n\r\nuser.canPost
\r\nA condition indicating whether the current user can post a new message.\r\n

\r\n\r\npost.date.value
\r\nA human readable date for this post.\r\n

\r\n\r\npost.date.epoch
\r\nThe epoch date for this post.\r\n

\r\n\r\npost.time.value
\r\nThe human readable time for this post.\r\n

\r\n\r\npost.date.label
\r\nThe default label for post.date.value.\r\n

\r\n\r\npost.rating.value
\r\nThe average rating of this post.\r\n

\r\n\r\npost.rating.label
\r\nThe default label for post.date.value.\r\n

\r\n\r\npost.views.value
\r\nThe number of views for this post.\r\n

\r\n\r\npost.views.label
\r\nThe default label for post.views.value.\r\n

\r\n\r\npost.status.value
\r\nthe status of this post.\r\n

\r\n\r\npost.status.label
\r\nThe default label for post.status.value.\r\n

\r\n\r\npost.isLocked
\r\nA condition indicating whether the thread this post is in is locked.\r\n

\r\n\r\npost.isModerator
\r\nA condition indicating whether the current user is a moderator.\r\n

\r\n\r\npost.canEdit
\r\nA condition indicating whether the current user can edit this post.\r\n

\r\n\r\npost.user.isVisitor
\r\nA condition indicating whether the poster was a visitor.\r\n

\r\n\r\npost.user.id
\r\nThe userId of the poster.\r\n

\r\n\r\npost.user.name
\r\nThe poster\'s username.\r\n

\r\n\r\npost.user.profile
\r\nThe url to the poster\'s profile.\r\n

\r\n\r\npost.url
\r\nThe url to display this post.\r\n

\r\n\r\npost.id
\r\nThe unique id of this post.\r\n

\r\n\r\npost.rate.label
\r\nThe default label for post.rate.url.1.\r\n

\r\n\r\npost.rate.url.1
\r\nThe url to give this post a rating of 1.\r\n

\r\n\r\npost.rate.url.2
\r\nThe url to give this post a rating of 2.\r\n

\r\n\r\n\r\npost.rate.url.3
\r\nThe url to give this post a rating of 3.\r\n

\r\n\r\n\r\npost.rate.url.4
\r\nThe url to give this post a rating of 4.\r\n

\r\n\r\n\r\npost.rate.url.5
\r\nThe url to give this post a rating of 5.\r\n

\r\n\r\npost.hasRated
\r\nA condition indicating whether the current user has already rated this post.\r\n

\r\n\r\npost.reply.label
\r\nThe default label for post.reply.url.\r\n

\r\n\r\npost.reply.url
\r\nThe url to reply to this post.\r\n

\r\n\r\npost.reply.withquote.url
\r\nThe url to reply to this post and quote this post in doing so.\r\n

\r\n\r\npost.edit.label
\r\nThe default label for post.edit.url.\r\n

\r\n\r\npost.edit.url
\r\nThe url to edit this post.\r\n

\r\n\r\npost.delete.url
\r\nThe url to delete this post.\r\n

\r\n\r\npost.delete.label
\r\nThe default label for post.delete.url.\r\n

\r\n\r\npost.approve.label
\r\nThe default label for post.approve.url.\r\n

\r\n\r\npost.approve.url
\r\nThe url to approve this post.\r\n

\r\n\r\npost.deny.url
\r\nThe url to deny this post.\r\n

\r\n\r\npost.deny.label
\r\nThe default label for post.deny.url.\r\n

\r\n\r\npost.full
\r\nThe full post rendered using the post template. This would never be used in the post template directly, but is often used in other templates that embed the post template\'s variables.\r\n

\r\n\r\nforum.title
\r\nThe title of this forum as passed by the calling object.\r\n

\r\n\r\nforum.description
\r\nThe description of this forum as passed by the calling object.\r\n

\r\n\r\n\r\n\r\n', 1068919407,NULL); diff --git a/lib/WebGUI/Forum/UI.pm b/lib/WebGUI/Forum/UI.pm index dc4dda3e9..07b795793 100644 --- a/lib/WebGUI/Forum/UI.pm +++ b/lib/WebGUI/Forum/UI.pm @@ -68,17 +68,17 @@ User interface package for forums. $html = WebGUI::Forum::UI::forumProperties($forumId); WebGUI::Forum::UI::forumPropertiesSave(); - $hashRef = WebGUI::Forum::UI::getForumTemplateVars($callack, $forum); - $hashRef = WebGUI::Forum::UI::getPostTemplateVars($post, $thread, $forum, $callack); - $hashRef = WebGUI::Forum::UI::getThreadTemplateVars($callack, $post); - $arrayRef = WebGUI::Forum::UI::recurseThread($post, $thread, $forum, $depth, $callback, $postId); + $hashRef = WebGUI::Forum::UI::getForumTemplateVars($caller, $forum); + $hashRef = WebGUI::Forum::UI::getPostTemplateVars($post, $thread, $forum, $caller); + $hashRef = WebGUI::Forum::UI::getThreadTemplateVars($caller, $post); + $arrayRef = WebGUI::Forum::UI::recurseThread($post, $thread, $forum, $depth, $caller, $postId); - WebGUI::Forum::UI::notifySubscribers($post, $thread, $forum, $callback); - WebGUI::Forum::UI::setPostApproved($callback, $post); - WebGUI::Forum::UI::setPostDeleted($callback, $post); - WebGUI::Forum::UI::setPostDenied($callback, $post); - WebGUI::Forum::UI::setPostPending($callback, $post); - WebGUI::Forum::UI::setPostStatus($callback, $post); + WebGUI::Forum::UI::notifySubscribers($post, $thread, $forum, $caller); + WebGUI::Forum::UI::setPostApproved($caller, $post); + WebGUI::Forum::UI::setPostDeleted($caller, $post); + WebGUI::Forum::UI::setPostDenied($caller, $post); + WebGUI::Forum::UI::setPostPending($caller, $post); + WebGUI::Forum::UI::setPostStatus($caller, $post); $html = WebGUI::Forum::UI::forumOp($callback); $html = WebGUI::Forum::UI::www_approvePost($callback); @@ -963,7 +963,7 @@ sub forumPropertiesSave { #------------------------------------------------------------------- -=head2 forumOp ( callback ) +=head2 forumOp ( callback, title, description ) Returns the output of the various www_ subroutines. @@ -973,15 +973,28 @@ Returns the output of the various www_ subroutines. The URL to get back to the calling object. +=item title + +The title of the parent object for display in the forum templates. + +=item description + +The description of the parent object for display in the fourm templates. + =back =cut sub forumOp { - my ($callback) = @_; + my ($callback, $title, $description) = @_; + my $caller = { + callback=>$callback, + title=>$title, + description=>$description + }; if ($session{form}{forumOp} =~ /^[A-Za-z]+$/) { my $cmd = "www_".$session{form}{forumOp}; - return &$cmd($callback); + return &$cmd($caller); } else { WebGUI::ErrorHandler::security("execute an invalid forum operation: ".$session{form}{forumOp}); } @@ -989,15 +1002,15 @@ sub forumOp { #------------------------------------------------------------------- -=head2 getForumTemplateVars ( callback, forum ) +=head2 getForumTemplateVars ( caller, forum ) Returns a hash reference compatible with WebGUI's templating system. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item forum @@ -1008,13 +1021,16 @@ The unique id for the forum. =cut sub getForumTemplateVars { - my ($callback, $forum) = @_; + my ($caller, $forum) = @_; + my $callback = $caller->{callback}; 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); + $var{'forum.description'} = $caller->{description}; + $var{'forum.title'} = $caller->{title}; $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); @@ -1112,7 +1128,7 @@ sub getForumTemplateVars { #------------------------------------------------------------------- -=head2 getPostTemplateVars ( post, thread, forum, callback [, var ] ) +=head2 getPostTemplateVars ( post, thread, forum, caller [, var ] ) Returns a hash reference compatible with WebGUI's templating system containing the template variables for a post. @@ -1130,9 +1146,9 @@ A thread object. A forum object. -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item var @@ -1143,7 +1159,8 @@ A hash reference to be prepended to the hashref being returned. =cut sub getPostTemplateVars { - my ($post, $thread, $forum, $callback, $var) = @_; + my ($post, $thread, $forum, $caller, $var) = @_; + my $callback = $caller->{callback}; $var->{'callback.url'} = $callback; $var->{'callback.label'} = WebGUI::International::get(1039); $var->{'post.subject.label'} = WebGUI::International::get(229); @@ -1212,21 +1229,23 @@ sub getPostTemplateVars { $var->{'post.approve.url'} = formatApprovePostURL($callback,$post->get("forumPostId")); $var->{'post.deny.label'} = WebGUI::International::get(574); $var->{'post.deny.url'} = formatDenyPostURL($callback,$post->get("forumPostId")); + $var->{'forum.title'} = $callback->{title}; + $var->{'forum.description'} = $callback->{description}; $var->{'post.full'} = WebGUI::Template::process(WebGUI::Template::get($forum->get("postTemplateId"),"Forum/Post"), $var); return $var; } #------------------------------------------------------------------- -=head2 getThreadTemplateVars ( callback, post ) +=head2 getThreadTemplateVars ( caller, post ) Returns a hash reference compatible with WebGUI's template system containing the template variables for the thread. =over -=item callback +=item caller -The URL to get back to the calling object. +A hash reference containing information passed from the calling object. =item post @@ -1237,11 +1256,12 @@ A post object. =cut sub getThreadTemplateVars { - my ($callback, $post) = @_; + my ($caller, $post) = @_; + my $callback = $caller->{callback}; $post->markRead($session{user}{userId}); my $thread = $post->getThread; my $forum = $thread->getForum; - my $var = getPostTemplateVars($post, $thread, $forum, $callback); + my $var = getPostTemplateVars($post, $thread, $forum, $caller); my $root = WebGUI::Forum::Post->new($thread->get("rootPostId")); $var->{'callback.url'} = $callback; $var->{'callback.label'} = WebGUI::International::get(1039); @@ -1273,7 +1293,7 @@ sub getThreadTemplateVars { $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->{post_loop} = recurseThread($root, $thread, $forum, 0, $caller, $post->get("forumPostId")); $var->{'thread.subject.label'} = WebGUI::International::get(229); $var->{'thread.date.label'} = WebGUI::International::get(245); $var->{'thread.user.label'} = WebGUI::International::get(244); @@ -1285,12 +1305,14 @@ sub getThreadTemplateVars { $var->{'thread.next.label'} = WebGUI::International::get(512); $var->{'thread.list.url'} = formatForumURL($callback,$forum->get("forumId")); $var->{'thread.list.label'} = WebGUI::International::get(1019); + $var->{'forum.title'} = $caller->{title}; + $var->{'forum.description'} = $caller->{description}; return $var; } #------------------------------------------------------------------- -=head2 notifySubscribers ( post, thread, forum, callback ) +=head2 notifySubscribers ( post, thread, forum, caller ) Send notifications to the thread and forum subscribers that a new post has been made. @@ -1308,16 +1330,16 @@ A thread object. A forum object. -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub notifySubscribers { - my ($post, $thread, $forum, $callback) = @_; + my ($post, $thread, $forum, $caller) = @_; my %subscribers; my $sth = WebGUI::SQL->read("select userId from forumThreadSubscription where forumThreadId=".$thread->get("forumThreadId")); while (my ($userId) = $sth->array) { @@ -1336,7 +1358,7 @@ sub notifySubscribers { $lang{$u->get("language")}{var} = { 'notify.subscription.message' => WebGUI::International::get(875,$u->get("language")) }; - $lang{$u->get("language")}{var} = getPostTemplateVars($post, $thread, $forum, $callback, $lang{$u->get("language")}{var}); + $lang{$u->get("language")}{var} = getPostTemplateVars($post, $thread, $forum, $caller, $lang{$u->get("language")}{var}); $lang{$u->get("language")}{subject} = WebGUI::International::get(523,$u->get("language")); $lang{$u->get("language")}{message} = WebGUI::Template::process(WebGUI::Template::get($forum->get("notificationTemplateId"),"Forum/Notification"), $lang{$u->get("language")}{var}); @@ -1347,7 +1369,7 @@ sub notifySubscribers { #------------------------------------------------------------------- -=head2 recurseThread ( post, thread, forum, depth, callback, currentPost ) +=head2 recurseThread ( post, thread, forum, depth, caller, currentPost ) Returns an array reference with the template variables from all the posts in a thread. @@ -1369,9 +1391,9 @@ A forum object. An integer representing the depth of the current recurrsion. Starts at 0. -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item currentPost @@ -1382,35 +1404,35 @@ The unique id of the post that was selected by the user in this thread. =cut sub recurseThread { - my ($post, $thread, $forum, $depth, $callback, $currentPost) = @_; + my ($post, $thread, $forum, $depth, $caller, $currentPost) = @_; my @depth_loop; for (my $i=0; $i<$depth; $i++) { push(@depth_loop,{depth=>$i}); } my @post_loop; - push (@post_loop, getPostTemplateVars($post, $thread, $forum, $callback, { + push (@post_loop, getPostTemplateVars($post, $thread, $forum, $caller, { 'post.indent_loop'=>\@depth_loop, 'post.indent.depth'=>$depth, 'post.isCurrent'=>($currentPost == $post->get("forumPostId")) })); my $replies = $post->getReplies; foreach my $reply (@{$replies}) { - @post_loop = (@post_loop,@{recurseThread($reply, $thread, $forum, $depth+1, $callback, $currentPost)}); + @post_loop = (@post_loop,@{recurseThread($reply, $thread, $forum, $depth+1, $caller, $currentPost)}); } return \@post_loop; } #------------------------------------------------------------------- -=head2 setPostApproved ( callback, post ) +=head2 setPostApproved ( caller, post ) Sets the post to approved and sends any necessary notifications. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item post @@ -1421,25 +1443,25 @@ A post object. =cut sub setPostApproved { - my ($callback, $post) = @_; + my ($caller, $post) = @_; $post->setStatusApproved; unless ($session{user}{userId} == $post->get("userId")) { - WebGUI::MessageLog::addInternationalizedEntry($post->get("userId"),'',formatThreadURL($callback,$post->get("forumPostId")),579); + WebGUI::MessageLog::addInternationalizedEntry($post->get("userId"),'',formatThreadURL($caller->{callback},$post->get("forumPostId")),579); } - notifySubscribers($post,$post->getThread,$post->getThread->getForum,$callback); + notifySubscribers($post,$post->getThread,$post->getThread->getForum,$caller); } #------------------------------------------------------------------- -=head2 setPostDeleted ( callback, post ) +=head2 setPostDeleted ( caller, post ) Sets the post to deleted and sends any necessary notifications. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item post @@ -1450,21 +1472,21 @@ A post object. =cut sub setPostDeleted { - my ($callback, $post) = @_; + my ($caller, $post) = @_; $post->setStatusDeleted; } #------------------------------------------------------------------- -=head2 setPostDenied ( callback, post ) +=head2 setPostDenied ( caller, post ) Sets the post to denied and sends any necessary notifications. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item post @@ -1475,22 +1497,22 @@ A post object. =cut sub setPostDenied { - my ($callback, $post) = @_; + my ($caller, $post) = @_; $post->setStatusDenied; - WebGUI::MessageLog::addInternationalizedEntry($post->get("userId"),'',formatThreadURL($callback,$post->get("forumPostId")),580); + WebGUI::MessageLog::addInternationalizedEntry($post->get("userId"),'',formatThreadURL($caller->{callback},$post->get("forumPostId")),580); } #------------------------------------------------------------------- -=head2 setPostPending ( callback, post ) +=head2 setPostPending ( caller, post ) Sets the post to pending and sends any necessary notifications. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item post @@ -1501,23 +1523,23 @@ A post object. =cut sub setPostPending { - my ($callback, $post) = @_; + my ($caller, $post) = @_; $post->setStatusPending; WebGUI::MessageLog::addInternationalizedEntry('',$post->getThread->getForum->get("groupToModerate"), - formatThreadURL($callback,$post->get("forumPostId")),578,'WebGUI','pending'); + formatThreadURL($caller->{callback},$post->get("forumPostId")),578,'WebGUI','pending'); } #------------------------------------------------------------------- -=head2 setPostStatus ( callback, post ) +=head2 setPostStatus ( caller, post ) Sets a new post's status based upon forum settings. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item post @@ -1528,207 +1550,207 @@ A post object. =cut sub setPostStatus { - my ($callback, $post) = @_; + my ($caller, $post) = @_; if ($post->getThread->getForum->get("moderatePosts")) { - setPostPending($callback,$post); + setPostPending($caller,$post); } else { - setPostApproved($callback,$post); + setPostApproved($caller,$post); } } #------------------------------------------------------------------- -=head2 www_approvePost ( callback ) +=head2 www_approvePost ( caller ) The web method to approve a post. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_approvePost { - my ($callback) = @_; + my ($caller) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator); - setPostApproved($callback,$post); - return www_viewThread($callback); + setPostApproved($caller,$post); + return www_viewThread($caller); } #------------------------------------------------------------------- -=head2 www_deletePost ( callback ) +=head2 www_deletePost ( caller ) The web method to prompt a user as to whether they actually want to delete a post. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_deletePost { - my ($callback) = @_; + my ($caller) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); return WebGUI::Privilege::insufficient() unless ($post->canEdit); my $output = '

'.WebGUI::International::get(42).'

'; $output .= WebGUI::International::get(401).'

'; - $output .= '

{callback},"forumOp=deletePostConfirm&forumPostId=" .$session{form}{forumPostId}).'">'.WebGUI::International::get(44).''; - $output .= '   '.WebGUI::International::get(45).'
'; + $output .= '   '.WebGUI::International::get(45).''; return $output; } #------------------------------------------------------------------- -=head2 www_deletePostConfirm ( callback ) +=head2 www_deletePostConfirm ( caller ) The web method to delete a post. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_deletePostConfirm { - my ($callback) = @_; + my ($caller) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator); $post->setStatusDeleted; - return www_viewForum($callback,$post->getThread->get("forumId")); + return www_viewForum($caller,$post->getThread->get("forumId")); } #------------------------------------------------------------------- -=head2 www_denyPost ( callback ) +=head2 www_denyPost ( caller ) The web method to deny a post. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_denyPost { - my ($callback) = @_; + my ($caller) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); return WebGUI::Privilege::insufficient() unless ($post->canEdit($session{user}{userId})); - setPostDenied($callback,$post); - return www_viewThread($callback); + setPostDenied($caller,$post); + return www_viewThread($caller); } #------------------------------------------------------------------- -=head2 www_forumSubscribe ( callback ) +=head2 www_forumSubscribe ( caller ) The web method to subscribe to a forum. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_forumSubscribe { - my ($callback) = @_; + my ($caller) = @_; my $forum = WebGUI::Forum->new($session{form}{forumId}); return WebGUI::Privilege::insufficient() unless ($forum->canPost && $session{user}{userId} != 1); $forum->subscribe; - return www_viewForum($callback, $session{form}{forumId}); + return www_viewForum($caller, $session{form}{forumId}); } #------------------------------------------------------------------- -=head2 www_forumUnsubscribe ( callback ) +=head2 www_forumUnsubscribe ( caller ) The web method to unsubscribe from a forum. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_forumUnsubscribe { - my ($callback) = @_; + my ($caller) = @_; my $forum = WebGUI::Forum->new($session{form}{forumId}); return WebGUI::Privilege::insufficient() unless ($session{user}{userId} != 1); $forum->unsubscribe; - return www_viewForum($callback, $session{form}{forumId}); + return www_viewForum($caller, $session{form}{forumId}); } #------------------------------------------------------------------- -=head2 www_nextThread ( callback ) +=head2 www_nextThread ( caller ) The web method to display the next thread in the forum. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_nextThread { - my ($callback) = @_; + my ($caller) = @_; my $thread = WebGUI::Forum::Thread->new($session{form}{forumThreadId}); my $nextThreadRoot = $thread->getNextThread->get("rootPostId"); if (defined $nextThreadRoot) { - return www_viewThread($callback,$nextThreadRoot); + return www_viewThread($caller,$nextThreadRoot); } else { - return www_viewForum($callback,$thread->get("forumId")); + return www_viewForum($caller,$thread->get("forumId")); } } #------------------------------------------------------------------- -=head2 www_post ( callback ) +=head2 www_post ( caller ) The web method to display the post form. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_post { - my ($callback) = @_; + my ($caller) = @_; my ($subject, $message, $forum); my $var; $var->{'newpost.header'} = WebGUI::International::get(1064); @@ -1738,7 +1760,7 @@ sub www_post { $var->{'user.isVisitor'} = ($session{user}{userId} == 1); $var->{'newpost.isNewMessage'} = ($var->{'newpost.isNewThread'} || $var->{'newpost.isReply'}); $var->{'form.begin'} = WebGUI::Form::formHeader({ - action=>$callback + action=>$caller->{callback} }); my $defaultSubscribeValue = 0; my $contentType = "mixed"; @@ -1751,7 +1773,7 @@ sub www_post { }); $message = "[quote]".$reply->get("message")."[/quote]" if ($session{form}{withQuote}); $forum = $reply->getThread->getForum; - $var = getPostTemplateVars($reply, $reply->getThread, $forum, $callback, $var); + $var = getPostTemplateVars($reply, $reply->getThread, $forum, $caller, $var); $subject = $reply->get("subject"); $subject = "Re: ".$subject unless ($subject =~ /^Re:/); @@ -1839,22 +1861,22 @@ sub www_post { #------------------------------------------------------------------- -=head2 www_postSave ( callback ) +=head2 www_postSave ( caller ) The web method to save the data from the post form. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_postSave { - my ($callback) = @_; + my ($caller) = @_; my $forumId = $session{form}{forumId}; my $threadId = $session{form}{forumThreadId}; my $postId = $session{form}{forumPostId}; @@ -1878,8 +1900,8 @@ sub www_postSave { $postData{forumThreadId} = $parentPost->getThread->get("forumThreadId"); $postData{parentId} = $session{form}{parentId}; my $post = WebGUI::Forum::Post->create(\%postData); - setPostStatus($callback,$post); - return www_viewThread($callback,$post->get("forumPostId")); + setPostStatus($caller,$post); + return www_viewThread($caller,$post->get("forumPostId")); } if ($session{form}{forumPostId} > 0) { # edit my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); @@ -1890,7 +1912,7 @@ sub www_postSave { ." $session{user}{username}) --- \n"; } $post->set(\%postData); - return www_viewThread($callback,$post->get("forumPostId")); + return www_viewThread($caller,$post->get("forumPostId")); } if ($forumId) { # new post %postData = (%postData, %postDataNew); @@ -1902,80 +1924,80 @@ sub www_postSave { isLocked=>$session{form}{isLocked} }, \%postData); $thread->subscribe($session{user}{userId}) if ($session{form}{subscribe}); - setPostStatus($callback,$thread->getPost($thread->get("rootPostId"))); - return www_viewForum($callback, $forumId); + setPostStatus($caller,$thread->getPost($thread->get("rootPostId"))); + return www_viewForum($caller, $forumId); } } #------------------------------------------------------------------- -=head2 www_previousThread ( callback ) +=head2 www_previousThread ( caller ) The web method to view the previous thread in this forum. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_previousThread { - my ($callback) = @_; + my ($caller) = @_; my $thread = WebGUI::Forum::Thread->new($session{form}{forumThreadId}); my $previousThreadRoot = $thread->getPreviousThread->get("rootPostId"); if (defined $previousThreadRoot) { - return www_viewThread($callback,$previousThreadRoot); + return www_viewThread($caller,$previousThreadRoot); } else { - return www_viewForum($callback,$thread->get("forumId")); + return www_viewForum($caller,$thread->get("forumId")); } } #------------------------------------------------------------------- -=head2 www_ratePost ( callback ) +=head2 www_ratePost ( caller ) The web method to rate a post. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_ratePost { - my ($callback) = @_; + my ($caller) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->canPost); $post->rate($session{form}{rating}) unless ($post->hasRated); - return www_viewThread($callback,$session{form}{forumPostId}); + return www_viewThread($caller,$session{form}{forumPostId}); } #------------------------------------------------------------------- -=head2 www_search ( callback ) +=head2 www_search ( caller ) The web method to display and use the forum search interface. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_search { - my ($callback) = @_; + my ($caller) = @_; my $forum = WebGUI::Forum->new($session{form}{forumId}); WebGUI::Session::setScratch("all",$session{form}{all}); WebGUI::Session::setScratch("atLeastOne",$session{form}{atLeastOne}); @@ -1983,9 +2005,9 @@ sub www_search { WebGUI::Session::setScratch("without",$session{form}{without}); WebGUI::Session::setScratch("numResults",$session{form}{numResults}); my %var; - $var{'callback.url'} = $callback; + $var{'callback.url'} = $caller->{callback}; $var{'callback.label'} = WebGUI::International::get(1039); - $var{'form.begin'} = WebGUI::Form::formHeader({action=>$callback}); + $var{'form.begin'} = WebGUI::Form::formHeader({action=>$caller->{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} }); @@ -2026,7 +2048,7 @@ sub www_search { }); $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.url'} = formatForumURL($caller->{callback},$forum->get("forumId")); $var{'thread.list.label'} = WebGUI::International::get(1019); $var{doit} = $session{form}{doit}; if ($session{form}{doit}) { @@ -2035,13 +2057,13 @@ sub www_search { $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); + my $p = WebGUI::Paginator->new(WebGUI::URL::append($caller->{callback},"forumOp=search&forumId=".$forum->get("forumId")),"", $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.url'=>formatThreadURL($caller->{callback},$row->{forumPostId}), 'post.user.name'=>$row->{username}, 'post.user.id'=>$row->{userId}, 'post.user.profile'=>formatUserProfileURL($row->{userId}), @@ -2065,157 +2087,156 @@ sub www_search { #------------------------------------------------------------------- -=head2 www_threadLock ( callback ) +=head2 www_threadLock ( caller ) The web method to lock a thread. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_threadLock { - my ($callback) = @_; + my ($caller) = @_; 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}); + return www_viewThread($caller, $session{form}{forumPostId}); } #------------------------------------------------------------------- -=head2 www_threadStick ( callback ) +=head2 www_threadStick ( caller ) The web method to make a thread sticky. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_threadStick { - my ($callback) = @_; + my ($caller) = @_; 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}); + return www_viewThread($caller, $session{form}{forumPostId}); } #------------------------------------------------------------------- -=head2 www_threadSubscribe ( callback ) +=head2 www_threadSubscribe ( caller ) The web method to subscribe to a thread. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_threadSubscribe { - my ($callback) = @_; + my ($caller) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); return WebGUI::Privilege::insufficient() unless ($session{user}{userId} != 1 && $post->getThread->getForum->canPost); $post->getThread->subscribe; - return www_viewThread($callback, $session{form}{forumPostId}); + return www_viewThread($caller, $session{form}{forumPostId}); } #------------------------------------------------------------------- -=head2 www_threadUnlock ( callback ) +=head2 www_threadUnlock ( caller ) The web method to unlock a thread. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_threadUnlock { - my ($callback) = @_; + my ($caller) = @_; 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}); + return www_viewThread($caller, $session{form}{forumPostId}); } #------------------------------------------------------------------- -=head2 www_threadUnstick ( callback ) +=head2 www_threadUnstick ( caller ) The web method to make a sticky thread normal again. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =back =cut sub www_threadUnstick { - my ($callback) = @_; + my ($caller) = @_; 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}); + return www_viewThread($caller, $session{form}{forumPostId}); } #------------------------------------------------------------------- -=head2 www_threadUnsubscribe ( callback ) +=head2 www_threadUnsubscribe ( caller ) The web method to unsubscribe from a thread. =over -=item callback - -The url to get back to the calling object. +=item caller +A hash reference containing information passed from the calling object. =back =cut sub www_threadUnsubscribe { - my ($callback) = @_; + my ($caller) = @_; my $post = WebGUI::Forum::Post->new($session{form}{forumPostId}); return WebGUI::Privilege::insufficient() unless ($session{user}{userId} != 1); $post->getThread->unsubscribe; - return www_viewThread($callback, $session{form}{forumPostId}); + return www_viewThread($caller, $session{form}{forumPostId}); } #------------------------------------------------------------------- -=head2 www_viewForum ( callback [ , forumId ] ) +=head2 www_viewForum ( caller [ , forumId ] ) The web method to display a forum. =over -=item callback +=item caller The url to get back to the calling object. @@ -2228,25 +2249,25 @@ Specify a forumId and call this method directly, rather than over the web. =cut sub www_viewForum { - my ($callback, $forumId) = @_; + my ($caller, $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); + my $var = getForumTemplateVars($caller, $forum); return WebGUI::Template::process(WebGUI::Template::get($forum->get("forumTemplateId"),"Forum"), $var); } #------------------------------------------------------------------- -=head2 www_viewThread ( callback [ , postId ] ) +=head2 www_viewThread ( caller [ , postId ] ) The web method to display a thread. =over -=item callback +=item caller -The url to get back to the calling object. +A hash reference containing information passed from the calling object. =item postId @@ -2257,11 +2278,11 @@ Specify a postId and call this method directly, rather than over the web. =cut sub www_viewThread { - my ($callback, $postId) = @_; + my ($caller, $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); + my $var = getThreadTemplateVars($caller, $post); return WebGUI::Template::process(WebGUI::Template::get($post->getThread->getForum->get("threadTemplateId"),"Forum/Thread"), $var); } diff --git a/lib/WebGUI/Wobject/Article.pm b/lib/WebGUI/Wobject/Article.pm index c9ffb1ec4..aa38d1653 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); + return WebGUI::Forum::UI::forumOp($callback,$_[0]->get("title"),$_[0]->get("description")); } else { return $_[0]->processTemplate($templateId,\%var); } diff --git a/lib/WebGUI/Wobject/MessageBoard.pm b/lib/WebGUI/Wobject/MessageBoard.pm index 273391fd6..b33b229d5 100644 --- a/lib/WebGUI/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Wobject/MessageBoard.pm @@ -165,7 +165,14 @@ sub www_moveForumUp { #------------------------------------------------------------------- sub www_view { my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")); - return WebGUI::Forum::UI::forumOp($callback) if ($session{form}{forumOp}); + if ($session{form}{forumOp}) { + my ($title, $description); + if ($session{form}{forumId} ne "") { + ($title,$description) = WebGUI::SQL->quickArray("select title,description from MessageBoard_forums where forumId=".$session{form}{forumId}); + $callback = WebGUI::URL::append("forumId=".$session{form}{forumId}); + } + return WebGUI::Forum::UI::forumOp($callback,$title,$description); + } my %var; $var{title} = $_[0]->get("title"); $var{description} = $_[0]->get("description"); diff --git a/lib/WebGUI/Wobject/USS.pm b/lib/WebGUI/Wobject/USS.pm index ae37169d6..d01a724c4 100644 --- a/lib/WebGUI/Wobject/USS.pm +++ b/lib/WebGUI/Wobject/USS.pm @@ -545,7 +545,7 @@ sub www_viewSubmission { 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); + return WebGUI::Forum::UI::forumOp($callback,$submission->{title}); } WebGUI::SQL->write("update USS_submission set views=views+1 where USS_submissionId=$session{form}{sid}"); $var{title} = $submission->{title};