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 89939d5d9..3fd519bbb 100644
--- a/docs/upgrades/upgrade_5.4.4-5.5.0.sql
+++ b/docs/upgrades/upgrade_5.4.4-5.5.0.sql
@@ -169,5 +169,19 @@ delete from international where languageId=1 and namespace='WebGUI' and internat
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);
+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;
+alter table wobject add column forumId int;
+delete from international where languageId=1 and namespace='WebGUI' and internationalId=567;
+delete from international where languageId=1 and namespace='WebGUI' and internationalId=568;
+delete from international where languageId=1 and namespace='WebGUI' and internationalId=569;
+update international set internationalId=1024, namespace='WebGUI' where internationalId=1 and namespace='Discussion';
+update international set internationalId=1025, namespace='WebGUI' where internationalId=524 and namespace='Discussion';
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1028,1,'WebGUI','Moderate posts?', 1065966284,'Asking the admin whether they wish to moderate the posts in a discussion or just allow all posts to go out.');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1027,1,'WebGUI','Allow replacements?', 1065966244,'Asking the admin whether they wish to allow text replacements in a discussion.');
+insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1026,1,'WebGUI','Allow rich edit?', 1065966219,'Asking the admin whether they wish to allow rich edit in a discussion.');
+update international set internationalId=1029, namespace='WebGUI' where internationalId=525 and namespace='Discussion';
+update international set internationalId=1030, namespace='WebGUI' where internationalId=526 and namespace='Discussion';
diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm
index d4c0ad38a..81a8839b6 100644
--- a/lib/WebGUI.pm
+++ b/lib/WebGUI.pm
@@ -185,9 +185,13 @@ sub _processFunctions {
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
$w = eval{$cmd->new($wobject)};
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wobject: ${$wobject}{namespace}. Root Cause: ".$@) if($@);
- $cmd = "www_".$session{form}{func};
- $output = eval{$w->$cmd};
- WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace} / $session{form}{func}. Root cause: ".$@) if($@);
+ if ($session{form}{func} =~ /^[A-Za-z]+$/) {
+ $cmd = "www_".$session{form}{func};
+ $output = eval{$w->$cmd};
+ WebGUI::ErrorHandler::fatalError("Wobject runtime error: ${$wobject}{namespace} / $session{form}{func}. Root cause: ".$@) if($@);
+ } else {
+ WebGUI::ErrorHandler::security("execute an invalid function: ".$session{form}{func});
+ }
} else {
$output = WebGUI::Privilege::noAccess();
}
diff --git a/lib/WebGUI/Forum.pm b/lib/WebGUI/Forum.pm
index db68c470d..8cfafbb1d 100644
--- a/lib/WebGUI/Forum.pm
+++ b/lib/WebGUI/Forum.pm
@@ -6,7 +6,7 @@ use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
-
+use WebGUI::Utility;
sub canPost {
my ($self, $userId) = @_;
@@ -43,6 +43,16 @@ sub isModerator {
return WebGUI::Privilege::isInGroup($self->get("groupToModerate"), $userId);
}
+sub incrementReplies {
+ my ($self) = @_;
+ WebGUI::SQL->write("update forum set replies=replies+1 where forumId=".$self->get("forumId"));
+}
+
+sub incrementViews {
+ my ($self) = @_;
+ WebGUI::SQL->write("update forum set views=views+1 where forumId=".$self->get("forumId"));
+}
+
sub isSubscribed {
my ($self, $userId) = @_;
$userId = $session{user}{userId} unless ($userId);
@@ -56,6 +66,15 @@ sub new {
bless {_properties=>$properties}, $self;
}
+sub recalculateRating {
+ my ($self) = @_;
+ my ($count) = WebGUI::SQL->quickArray("select count(*) from forumThread where forumId=".$self->get("forumId")." and rating>0");
+ $count = $count || 1;
+ my ($sum) = WebGUI::SQL->quickArray("select sum(rating) from forumThread where forumId=".$self->get("forumId")." and rating>0");
+ my $average = round($sum/$count);
+ $self->set({rating=>$average});
+}
+
sub set {
my ($self, $data) = @_;
$data->{forumId} = $self->get("forumId") unless ($data->{forumId});
diff --git a/lib/WebGUI/Forum/Thread.pm b/lib/WebGUI/Forum/Thread.pm
index c9e6e69e6..a8206c1e1 100644
--- a/lib/WebGUI/Forum/Thread.pm
+++ b/lib/WebGUI/Forum/Thread.pm
@@ -75,11 +75,13 @@ sub incrementReplies {
my ($self, $dateOfReply, $replyId) = @_;
WebGUI::SQL->write("update forumThread set replies=replies+1, lastPostId=$replyId, lastPostDate=$dateOfReply
where forumThreadId=".$self->get("forumThreadId"));
+ $self->getForum->incrementReplies;
}
sub incrementViews {
my ($self) = @_;
WebGUI::SQL->write("update forumThread set views=views+1 where forumThreadId=".$self->get("forumThreadId"));
+ $self->getForum->incrementViews;
}
sub isSticky {
@@ -117,6 +119,7 @@ sub recalculateRating {
my ($sum) = WebGUI::SQL->quickArray("select sum(rating) from forumPost where forumThreadId=".$self->get("forumThreadId")." and rating>0");
my $average = round($sum/$count);
$self->set({rating=>$average});
+ $self->getForum->recalculateRating;
}
sub set {
diff --git a/lib/WebGUI/Forum/UI.pm b/lib/WebGUI/Forum/UI.pm
index a25661f9d..613f6c21f 100644
--- a/lib/WebGUI/Forum/UI.pm
+++ b/lib/WebGUI/Forum/UI.pm
@@ -3,6 +3,7 @@ package WebGUI::Forum::UI;
use strict qw(vars subs);
use WebGUI::DateTime;
use WebGUI::Form;
+use WebGUI::FormProcessor;
use WebGUI::Forum;
use WebGUI::Forum::Post;
use WebGUI::Forum::Thread;
@@ -12,67 +13,71 @@ use WebGUI::Session;
use WebGUI::Template;
-sub _chopSubject {
- return substr(_formatSubject($_[0]),0,30);
+sub chopSubject {
+ return substr(formatSubject($_[0]),0,30);
}
-sub _formatApprovePostURL {
+sub formatApprovePostURL {
return WebGUI::URL::append($_[0],"forumOp=approvePost&forumPostId=".$_[1]."&mlog=".$session{form}{mlog});
}
-sub _formatDeletePostURL {
+sub formatDeletePostURL {
return WebGUI::URL::append($_[0],"forumOp=deletePost&forumPostId=".$_[1]);
}
-sub _formatDenyPostURL {
+sub formatDenyPostURL {
return WebGUI::URL::append($_[0],"forumOp=denyPost&forumPostId=".$_[1]."&mlog=".$session{form}{mlog});
}
-sub _formatEditPostURL {
+sub formatEditPostURL {
return WebGUI::URL::append($_[0],"forumOp=post&forumPostId=".$_[1]);
}
-sub _formatForumSubscribeURL {
+sub formatForumURL {
+ return WebGUI::URL::append($_[0],"forumOp=viewForum&forumId=".$_[1]);
+}
+
+sub formatForumSubscribeURL {
return WebGUI::URL::append($_[0],"forumOp=forumSubscribe&forumId=".$_[1]);
}
-sub _formatForumUnsubscribeURL {
+sub formatForumUnsubscribeURL {
return WebGUI::URL::append($_[0],"forumOp=forumUnsubscribe&forumId=".$_[1]);
}
-sub _formatNextThreadURL {
+sub formatNextThreadURL {
return WebGUI::URL::append($_[0],"forumOp=nextThread&forumThreadId=".$_[1]);
}
-sub _formatNewThreadURL {
+sub formatNewThreadURL {
return WebGUI::URL::append($_[0],"forumOp=post&forumId=".$_[1]);
}
-sub _formatPostDate {
+sub formatPostDate {
return WebGUI::DateTime::epochToHuman($_[0],"%z");
}
-sub _formatPostTime {
+sub formatPostTime {
return WebGUI::DateTime::epochToHuman($_[0],"%Z");
}
-sub _formatPreviousThreadURL {
+sub formatPreviousThreadURL {
return WebGUI::URL::append($_[0],"forumOp=previousThread&forumThreadId=".$_[1]);
}
-sub _formatRatePostURL {
+sub formatRatePostURL {
return WebGUI::URL::append($_[0],"forumOp=ratePost&forumPostId=".$_[1]."&rating=".$_[2]);
}
-sub _formatReplyPostURL {
+sub formatReplyPostURL {
return WebGUI::URL::append($_[0],"forumOp=post&parentId=".$_[1]);
}
-sub _formatSubject {
+sub formatSubject {
return WebGUI::HTML::filter($_[0],"all");
}
-sub _formatStatus {
+sub formatStatus {
if ($_[0] eq "approved") {
return WebGUI::International::get(560);
} elsif ($_[0] eq "denied") {
@@ -82,23 +87,130 @@ sub _formatStatus {
}
}
-sub _formatThreadSubscribeURL {
+sub formatThreadSubscribeURL {
return WebGUI::URL::append($_[0],"forumOp=threadSubscribe&forumPostId=".$_[1]);
}
-sub _formatThreadUnsubscribeURL {
+sub formatThreadUnsubscribeURL {
return WebGUI::URL::append($_[0],"forumOp=threadUnsubscribe&forumPostId=".$_[1]);
}
-sub _formatThreadURL {
+sub formatThreadURL {
return WebGUI::URL::append($_[0],"forumOp=viewThread&forumPostId=".$_[1]."#".$_[1]);
}
-sub _formatUserProfileURL {
+sub formatUserProfileURL {
return WebGUI::URL::page("op=viewProfile&uid=".$_[0]);
}
-sub _getPostTemplateVars {
+sub forumProperties {
+ my ($forumId) = @_;
+ my $forum = WebGUI::Forum->new($forumId);
+ my $f = WebGUI::HTMLForm->new;
+ $f->hidden(
+ -name=>"forumId",
+ -value=>$forumId || "new"
+ );
+ my ($interval, $units) = WebGUI::DateTime::secondsToInterval(($forum->get("editTimeout") || 3600));
+ $f->interval(
+ -name=>"editTimeout",
+ -label=>WebGUI::International::get(566),
+ -intervalValue=>$interval,
+ -unitsValue=>$units,
+ -uiLevel=>9
+ );
+ $f->yesNo(
+ -name=>"addEditStampToPosts",
+ -label=>WebGUI::International::get(1025),
+ -value=>$forum->get("addEditStampToPosts"),
+ -uiLevel=>9
+ );
+ $f->yesNo(
+ -name=>"allowRichEdit",
+ -value=>$forum->get("allowRichEdit"),
+ -uiLevel=>7,
+ -label=>WebGUI::International::get(1026)
+ );
+ $f->yesNo(
+ -name=>"allowReplacements",
+ -value=>$forum->get("allowReplacements"),
+ -uiLevel=>7,
+ -label=>WebGUI::International::get(1027)
+ );
+ $f->filterContent(
+ -name=>"filterPosts",
+ -value=>$forum->get("filterPosts") || "most",
+ -label=>WebGUI::International::get(1024),
+ -uiLevel=>7
+ );
+ if ($session{setting}{useKarma}) {
+ $f->integer(
+ -name=>"karmaPerPost",
+ -label=>WebGUI::International::get(541),
+ -value=>$forum->get("karmaPerPost"),
+ -uiLevel=>7
+ );
+ } else {
+ $f->hidden(
+ -name=>"karmaPerPost",
+ -value=>$forum->get("karmaPerPost")
+ );
+ }
+ $f->group(
+ -name=>"groupToPost",
+ -label=>WebGUI::International::get(564),
+ -value=>[$forum->get("groupToPost")],
+ -uiLevel=>5
+ );
+ $f->yesNo(
+ -name=>"moderatePosts",
+ -label=>WebGUI::International::get(1028),
+ -uiLevel=>5,
+ -value=>$forum->get("moderatePosts")
+ );
+ my $groupToModerate = $forum->get("groupToModerate") || 4;
+ $f->group(
+ -name=>"groupToModerate",
+ -label=>WebGUI::International::get(565),
+ -value=>[$groupToModerate],
+ -uiLevel=>5
+ );
+ return $f->printRowsOnly;
+}
+
+sub forumPropertiesSave {
+ my %data = (
+ editTimeout=>WebGUI::FormProcessor::interval("editTimeout"),
+ addEditStampToPosts=>$session{form}{addEditStampToPosts},
+ allowRichEdit=>$session{form}{allowRichEdit},
+ allowReplacements=>$session{form}{allowReplacements},
+ filterPosts=>$session{form}{filterPosts},
+ karmaPerPost=>$session{form}{karmaPerPost},
+ groupToPost=>$session{form}{groupToPost},
+ moderatePosts=>$session{form}{moderatePosts},
+ groupToModerate=>$session{form}{groupToModerate}
+ );
+ my $forum;
+ if ($session{form}{forumId} eq "new") {
+ $forum = WebGUI::Forum->create(\%data);
+ } else {
+ $forum = WebGUI::Forum->new($session{form}{forumId});
+ $forum->set(\%data);
+ }
+ return $forum->get("forumId");
+}
+
+sub forumOp {
+ my ($callback) = @_;
+ if ($session{form}{forumOp} =~ /^[A-Za-z]+$/) {
+ my $cmd = "www_".$session{form}{forumOp};
+ return &$cmd($callback);
+ } else {
+ WebGUI::ErrorHandler::security("execute an invalid forum operation: ".$session{form}{forumOp});
+ }
+}
+
+sub getPostTemplateVars {
my ($post, $thread, $forum, $callback, $var) = @_;
$var->{'post.subject.label'} = WebGUI::International::get(229);
$var->{'post.subject'} = WebGUI::HTML::filter($post->get("subject"),"none");
@@ -128,15 +240,15 @@ sub _getPostTemplateVars {
$sth->finish;
}
$var->{'user.canPost'} = $forum->canPost;
- $var->{'post.date.value'} = _formatPostDate($post->get("dateOfPost"));
+ $var->{'post.date.value'} = formatPostDate($post->get("dateOfPost"));
$var->{'post.date.label'} = WebGUI::International::get(245);
$var->{'post.date.epoch'} = $post->get("dateOfPost");
- $var->{'post.time.value'} = _formatPostTime($post->get("dateOfPost"));
+ $var->{'post.time.value'} = formatPostTime($post->get("dateOfPost"));
$var->{'post.rating.value'} = $post->get("rating")+0;
$var->{'post.rating.label'} = WebGUI::International::get(1020);
$var->{'post.views.value'} = $post->get("views")+0;
$var->{'post.views.label'} = WebGUI::International::get(514);
- $var->{'post.status.value'} = _formatStatus($post->get("status"));
+ $var->{'post.status.value'} = formatStatus($post->get("status"));
$var->{'post.status.label'} = WebGUI::International::get(553);
$var->{'post.isLocked'} = $thread->isLocked;
$var->{'post.isModerator'} = $forum->isModerator;
@@ -145,55 +257,30 @@ sub _getPostTemplateVars {
$var->{'post.user.label'} = WebGUI::International::get(244);
$var->{'post.user.name'} = $post->get("username");
$var->{'post.user.Id'} = $post->get("userId");
- $var->{'post.user.Profile'} = _formatUserProfileURL($post->get("userId"));
- $var->{'post.url'} = _formatThreadURL($callback,$post->get("forumPostId"));
+ $var->{'post.user.Profile'} = formatUserProfileURL($post->get("userId"));
+ $var->{'post.url'} = formatThreadURL($callback,$post->get("forumPostId"));
$var->{'post.id'} = $post->get("forumPostId");
$var->{'post.rate.label'} = WebGUI::International::get(1021);
- $var->{'post.rate.url.1'} = _formatRatePostURL($callback,$post->get("forumPostId"),1);
- $var->{'post.rate.url.2'} = _formatRatePostURL($callback,$post->get("forumPostId"),2);
- $var->{'post.rate.url.3'} = _formatRatePostURL($callback,$post->get("forumPostId"),3);
- $var->{'post.rate.url.4'} = _formatRatePostURL($callback,$post->get("forumPostId"),4);
- $var->{'post.rate.url.5'} = _formatRatePostURL($callback,$post->get("forumPostId"),5);
+ $var->{'post.rate.url.1'} = formatRatePostURL($callback,$post->get("forumPostId"),1);
+ $var->{'post.rate.url.2'} = formatRatePostURL($callback,$post->get("forumPostId"),2);
+ $var->{'post.rate.url.3'} = formatRatePostURL($callback,$post->get("forumPostId"),3);
+ $var->{'post.rate.url.4'} = formatRatePostURL($callback,$post->get("forumPostId"),4);
+ $var->{'post.rate.url.5'} = formatRatePostURL($callback,$post->get("forumPostId"),5);
$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.url'} = formatReplyPostURL($callback,$post->get("forumPostId"));
$var->{'post.edit.label'} = WebGUI::International::get(575);
- $var->{'post.edit.url'} = _formatEditPostURL($callback,$post->get("forumPostId"));
+ $var->{'post.edit.url'} = formatEditPostURL($callback,$post->get("forumPostId"));
$var->{'post.delete.label'} = WebGUI::International::get(576);
- $var->{'post.delete.url'} = _formatDeletePostURL($callback,$post->get("forumPostId"));
+ $var->{'post.delete.url'} = formatDeletePostURL($callback,$post->get("forumPostId"));
$var->{'post.approve.label'} = WebGUI::International::get(572);
- $var->{'post.approve.url'} = _formatApprovePostURL($callback,$post->get("forumPostId"));
+ $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->{'post.deny.url'} = formatDenyPostURL($callback,$post->get("forumPostId"));
$var->{'post.full'} = WebGUI::Template::process(WebGUI::Template::get(1,"Forum/Post"), $var);
return $var;
}
-sub _recurseThread {
- my ($post, $thread, $forum, $depth, $callback, $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, {
- '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)});
- }
- return \@post_loop;
-}
-
-sub forumOp {
- my ($callback) = @_;
- my $cmd = "www_".$session{form}{forumOp};
- return &$cmd($callback);
-}
-
sub notifySubscribers {
my ($post, $thread, $forum, $callback) = @_;
my %subscribers;
@@ -210,7 +297,7 @@ sub notifySubscribers {
my $var = {
'notify.subscription.message' => WebGUI::International::get(875)
};
- $var = _getPostTemplateVars($post, $thread, $forum, $callback, $var);
+ $var = getPostTemplateVars($post, $thread, $forum, $callback, $var);
my $subject = WebGUI::International::get(523);
my $message = WebGUI::Template::process(WebGUI::Template::get(1,"Forum/Notification"), $var);
foreach my $userId (keys %subscribers) {
@@ -218,80 +305,25 @@ sub notifySubscribers {
}
}
-sub viewForum {
- my ($callback, $forumId) = @_;
- my (%var, @thread_loop);
- my $forum = WebGUI::Forum->new($forumId);
- $var{'user.isVisitor'} = ($session{user}{userId} == 1);
- $var{'thread.new.url'} = _formatNewThreadURL($callback,$forumId);
- $var{'thread.new.label'} = WebGUI::International::get(1018);
- $var{'forum.subscribe.label'} = WebGUI::International::get(1022);
- $var{'forum.subscribe.url'} = _formatForumSubscribeURL($callback,$forumId);
- $var{'forum.unsubscribe.label'} = WebGUI::International::get(1023);
- $var{'forum.unsubscribe.url'} = _formatForumUnsubscribeURL($callback,$forumId);
- $var{'user.isSubscribed'} = $forum->isSubscribed;
- $var{'user.canPost'} = $forum->canPost;
- $var{'thread.subject.label'} = WebGUI::International::get(229);
- $var{'thread.date.label'} = WebGUI::International::get(245);
- $var{'thread.user.label'} = WebGUI::International::get(244);
- $var{"thread.views.label"} = WebGUI::International::get(514);
- $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=".$forumId." order by isSticky desc, lastPostDate desc");
- $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);
- my $threads = $p->getPageData;
- foreach my $thread (@$threads) {
- my $root = WebGUI::Forum::Post->new($thread->{rootPostId});
- my $last;
- if ($thread->{rootPostId} == $thread->{lastPostId}) { #saves the lookup if it's the same id
- $last = $root;
- } else {
- $last = WebGUI::Forum::Post->new($thread->{lastPostId});
- }
- my @rating_loop;
- for (my $i=0;$i<=$thread->{rating};$i++) {
- push(@rating_loop,{'thread.rating_loop.count'=>$i});
- }
- push(@thread_loop,{
- 'thread.views'=>$thread->{views},
- 'thread.replies'=>$thread->{replies},
- 'thread.rating'=>$thread->{rating},
- 'thread.rating_loop'=>\@rating_loop,
- 'thread.isSticky'=>$thread->{isSticky},
- 'thread.isLocked'=>$thread->{isLocked},
- 'thread.root.subject'=>_chopSubject($root->get("subject")),
- 'thread.root.url'=>_formatThreadURL($callback,$root->get("forumPostId")),
- 'thread.root.epoch'=>$root->get("dateOfPost"),
- 'thread.root.date'=>_formatPostDate($root->get("dateOfPost")),
- 'thread.root.time'=>_formatPostTime($root->get("dateOfPost")),
- 'thread.root.user.profile'=>_formatUserProfileURL($root->get("userId")),
- 'thread.root.user.name'=>$root->get("username"),
- 'thread.root.user.id'=>$root->get("userId"),
- 'thread.root.user.isVisitor'=>($root->get("userId") == 1),
- 'thread.root.status'=>_formatStatus($root->get("status")),
- 'thread.last.subject'=>_chopSubject($last->get("subject")),
- 'thread.last.url'=>_formatThreadURL($callback,$last->get("forumPostId")),
- 'thread.last.epoch'=>$last->get("dateOfPost"),
- 'thread.last.date'=>_formatPostDate($last->get("dateOfPost")),
- 'thread.last.time'=>_formatPostTime($last->get("dateOfPost")),
- 'thread.last.user.profile'=>_formatUserProfileURL($last->get("userId")),
- 'thread.last.user.name'=>$last->get("username"),
- 'thread.last.user.id'=>$last->get("userId"),
- 'thread.last.user.isVisitor'=>($root->get("userId") == 1),
- 'thread.last.status'=>_formatStatus($last->get("status"))
- });
- }
- $var{thread_loop} = \@thread_loop;
- return WebGUI::Template::process(WebGUI::Template::get(1,"Forum"), \%var);
-}
-
+sub recurseThread {
+ my ($post, $thread, $forum, $depth, $callback, $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, {
+ '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)});
+ }
+ return \@post_loop;
+}
+
sub www_approvePost {
my ($callback) = @_;
my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});
@@ -317,7 +349,7 @@ sub www_deletePostConfirm {
my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});
return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator);
$post->setStatusDeleted;
- return viewForum($callback,$post->getThread->get("forumId"));
+ return www_viewForum($callback,$post->getThread->get("forumId"));
}
sub www_denyPost {
@@ -333,7 +365,7 @@ sub www_forumSubscribe {
my $forum = WebGUI::Forum->new($session{form}{forumId});
return WebGUI::Privilege::insufficient() unless ($forum->canPost && $session{user}{userId} != 1);
$forum->subscribe;
- return viewForum($callback, $session{form}{forumId});
+ return www_viewForum($callback, $session{form}{forumId});
}
sub www_forumUnsubscribe {
@@ -341,7 +373,7 @@ sub www_forumUnsubscribe {
my $forum = WebGUI::Forum->new($session{form}{forumId});
return WebGUI::Privilege::insufficient() unless ($session{user}{userId} != 1);
$forum->unsubscribe;
- return viewForum($callback, $session{form}{forumId});
+ return www_viewForum($callback, $session{form}{forumId});
}
sub www_nextThread {
@@ -351,7 +383,7 @@ sub www_nextThread {
if (defined $nextThreadRoot) {
return www_viewThread($callback,$nextThreadRoot);
} else {
- return viewForum($callback,$thread->get("forumId"));
+ return www_viewForum($callback,$thread->get("forumId"));
}
}
@@ -378,7 +410,7 @@ sub www_post {
value=>$reply->get("forumPostId")
});
$forum = $reply->getThread->getForum;
- $var = _getPostTemplateVars($reply, $reply->getThread, $forum, $callback, $var);
+ $var = getPostTemplateVars($reply, $reply->getThread, $forum, $callback, $var);
$subject = $reply->get("subject");
$subject = "Re: ".$subject unless ($subject =~ /^Re:/);
@@ -493,6 +525,11 @@ sub www_postSave {
if ($session{form}{forumPostId} > 0) { # edit
my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});
return WebGUI::Privilege::insufficient unless ($post->getThread->getForum->canPost);
+ if ($post->getThread->getForum->get("addEditStampToPosts")) {
+ $postData{message} .= "\n\n --- (".WebGUI::International::get(1029)." "
+ .WebGUI::DateTime::epochToHuman(WebGUI::DateTime::time())." ".WebGUI::International::get(1030)
+ ." $session{user}{username}) --- \n";
+ }
$post->set(\%postData);
return www_viewThread($callback,$post->get("forumPostId"));
}
@@ -506,7 +543,7 @@ sub www_postSave {
isLocked=>$session{form}{isLocked}
}, \%postData);
$thread->subscribe($session{user}{userId}) if ($session{form}{subscribe});
- return viewForum($callback, $forumId);
+ return www_viewForum($callback, $forumId);
}
}
@@ -517,7 +554,7 @@ sub www_previousThread {
if (defined $previousThreadRoot) {
return www_viewThread($callback,$previousThreadRoot);
} else {
- return viewForum($callback,$thread->get("forumId"));
+ return www_viewForum($callback,$thread->get("forumId"));
}
}
@@ -545,6 +582,81 @@ sub www_threadUnsubscribe {
return www_viewThread($callback, $session{form}{forumPostId});
}
+sub www_viewForum {
+ my ($callback, $forumId) = @_;
+ $forumId = $session{form}{forumId} unless ($forumId);
+ my (%var, @thread_loop);
+ my $forum = WebGUI::Forum->new($forumId);
+ $var{'user.isVisitor'} = ($session{user}{userId} == 1);
+ $var{'thread.new.url'} = formatNewThreadURL($callback,$forumId);
+ $var{'thread.new.label'} = WebGUI::International::get(1018);
+ $var{'forum.subscribe.label'} = WebGUI::International::get(1022);
+ $var{'forum.subscribe.url'} = formatForumSubscribeURL($callback,$forumId);
+ $var{'forum.unsubscribe.label'} = WebGUI::International::get(1023);
+ $var{'forum.unsubscribe.url'} = formatForumUnsubscribeURL($callback,$forumId);
+ $var{'user.isSubscribed'} = $forum->isSubscribed;
+ $var{'user.canPost'} = $forum->canPost;
+ $var{'thread.subject.label'} = WebGUI::International::get(229);
+ $var{'thread.date.label'} = WebGUI::International::get(245);
+ $var{'thread.user.label'} = WebGUI::International::get(244);
+ $var{"thread.views.label"} = WebGUI::International::get(514);
+ $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=".$forumId." order by isSticky desc, lastPostDate desc");
+ $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);
+ my $threads = $p->getPageData;
+ foreach my $thread (@$threads) {
+ my $root = WebGUI::Forum::Post->new($thread->{rootPostId});
+ my $last;
+ if ($thread->{rootPostId} == $thread->{lastPostId}) { #saves the lookup if it's the same id
+ $last = $root;
+ } else {
+ $last = WebGUI::Forum::Post->new($thread->{lastPostId});
+ }
+ my @rating_loop;
+ for (my $i=0;$i<=$thread->{rating};$i++) {
+ push(@rating_loop,{'thread.rating_loop.count'=>$i});
+ }
+ push(@thread_loop,{
+ 'thread.views'=>$thread->{views},
+ 'thread.replies'=>$thread->{replies},
+ 'thread.rating'=>$thread->{rating},
+ 'thread.rating_loop'=>\@rating_loop,
+ 'thread.isSticky'=>$thread->{isSticky},
+ 'thread.isLocked'=>$thread->{isLocked},
+ 'thread.root.subject'=>chopSubject($root->get("subject")),
+ 'thread.root.url'=>formatThreadURL($callback,$root->get("forumPostId")),
+ 'thread.root.epoch'=>$root->get("dateOfPost"),
+ 'thread.root.date'=>formatPostDate($root->get("dateOfPost")),
+ 'thread.root.time'=>formatPostTime($root->get("dateOfPost")),
+ 'thread.root.user.profile'=>formatUserProfileURL($root->get("userId")),
+ 'thread.root.user.name'=>$root->get("username"),
+ 'thread.root.user.id'=>$root->get("userId"),
+ 'thread.root.user.isVisitor'=>($root->get("userId") == 1),
+ 'thread.root.status'=>formatStatus($root->get("status")),
+ 'thread.last.subject'=>chopSubject($last->get("subject")),
+ 'thread.last.url'=>formatThreadURL($callback,$last->get("forumPostId")),
+ 'thread.last.epoch'=>$last->get("dateOfPost"),
+ 'thread.last.date'=>formatPostDate($last->get("dateOfPost")),
+ 'thread.last.time'=>formatPostTime($last->get("dateOfPost")),
+ 'thread.last.user.profile'=>formatUserProfileURL($last->get("userId")),
+ 'thread.last.user.name'=>$last->get("username"),
+ 'thread.last.user.id'=>$last->get("userId"),
+ 'thread.last.user.isVisitor'=>($root->get("userId") == 1),
+ 'thread.last.status'=>formatStatus($last->get("status"))
+ });
+ }
+ $var{thread_loop} = \@thread_loop;
+ return WebGUI::Template::process(WebGUI::Template::get(1,"Forum"), \%var);
+}
+
sub www_viewThread {
my ($callback, $postId) = @_;
$postId = $session{form}{forumPostId} unless ($postId);
@@ -552,27 +664,27 @@ sub www_viewThread {
$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, $callback);
my $root = WebGUI::Forum::Post->new($thread->get("rootPostId"));
$var->{'user.canPost'} = $forum->canPost;
$var->{'user.isSubscribed'} = $thread->isSubscribed;
$var->{'user.isVisitor'} = ($session{user}{userId} == 1);
- $var->{'thread.subscribe.url'} = _formatThreadSubscribeURL($callback,$postId);
+ $var->{'thread.subscribe.url'} = formatThreadSubscribeURL($callback,$postId);
$var->{'thread.subscribe.label'} = WebGUI::International::get(873);
- $var->{'thread.unsubscribe.url'} = _formatThreadUnsubscribeURL($callback,$postId);
+ $var->{'thread.unsubscribe.url'} = formatThreadUnsubscribeURL($callback,$postId);
$var->{'thread.unsubscribe.label'} = WebGUI::International::get(874);
- $var->{post_loop} = _recurseThread($root, $thread, $forum, 0, $callback, $postId);
+ $var->{post_loop} = recurseThread($root, $thread, $forum, 0, $callback, $postId);
$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);
- $var->{'thread.new.url'} = _formatNewThreadURL($callback,$thread->get("forumId"));
+ $var->{'thread.new.url'} = formatNewThreadURL($callback,$thread->get("forumId"));
$var->{'thread.new.label'} = WebGUI::International::get(1018);
- $var->{'thread.previous.url'} = _formatPreviousThreadURL($callback,$thread->get("forumThreadId"));
+ $var->{'thread.previous.url'} = formatPreviousThreadURL($callback,$thread->get("forumThreadId"));
$var->{'thread.previous.label'} = WebGUI::International::get(513);
- $var->{'thread.next.url'} = _formatNextThreadURL($callback,$thread->get("forumThreadId"));
+ $var->{'thread.next.url'} = formatNextThreadURL($callback,$thread->get("forumThreadId"));
$var->{'thread.next.label'} = WebGUI::International::get(512);
$var->{'thread.list.url'} = $callback;
$var->{'thread.list.label'} = WebGUI::International::get(1019);
diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm
index 6371b9e90..1dacb92b7 100644
--- a/lib/WebGUI/Wobject.pm
+++ b/lib/WebGUI/Wobject.pm
@@ -19,7 +19,6 @@ use DBI;
use strict qw(subs vars);
use Tie::IxHash;
use WebGUI::DateTime;
-use WebGUI::Discussion;
use WebGUI::FormProcessor;
use WebGUI::HTML;
use WebGUI::HTMLForm;
@@ -158,74 +157,6 @@ sub description {
#-------------------------------------------------------------------
-=head2 discussionProperties ( )
-
-Returns a formRow list of discussion properties, which may be attached to any Wobject.
-
-=cut
-
-sub discussionProperties {
- my ($f,$editTimeout,$interval, $units, $groupToModerate,%moderationType,$moderationType);
- %moderationType = (before=>WebGUI::International::get(567),after=>WebGUI::International::get(568));
- $f = WebGUI::HTMLForm->new;
- if ($_[0]->get("wobjectId") eq "new") {
- $editTimeout = 3600;
- $moderationType = 'after';
- } else {
- $editTimeout = $_[0]->get("editTimeout");
- $moderationType = $_[0]->get("moderationType");
- }
- my $filterPost = $_[0]->get("filterPost") || "most";
- $f->filterContent(
- -name=>"filterPost",
- -value=>$filterPost,
- -label=>WebGUI::International::get(1,"Discussion"),
- -uiLevel=>7
- );
- $groupToModerate = $_[0]->get("groupToModerate") || 4;
- $f->group(
- -name=>"groupToPost",
- -label=>WebGUI::International::get(564),
- -value=>[$_[0]->get("groupToPost")],
- -uiLevel=>7
- );
- ($interval, $units) = WebGUI::DateTime::secondsToInterval($editTimeout);
- $f->interval(
- -name=>"editTimeout",
- -label=>WebGUI::International::get(566),
- -intervalValue=>$interval,
- -unitsValue=>$units,
- -uiLevel=>7
- );
- if ($session{setting}{useKarma} && $session{user}{uiLevel} >= 7) {
- $f->integer("karmaPerPost",WebGUI::International::get(541),$_[0]->get("karmaPerPost"));
- } else {
- $f->hidden("karmaPerPost",$_[0]->get("karmaPerPost"));
- }
- $f->group(
- -name=>"groupToModerate",
- -label=>WebGUI::International::get(565),
- -value=>[$groupToModerate],
- -uiLevel=>7
- );
- $f->selectList(
- -name=>"moderationType",
- -options=>\%moderationType,
- -label=>WebGUI::International::get(569),
- -value=>[$moderationType],
- -uiLevel=>7
- );
- $f->yesNo(
- -name=>"addEditStampToPosts",
- -label=>WebGUI::International::get(524,"Discussion"),
- -value=>$_[0]->get("addEditStampToPosts"),
- -uiLevel=>9
- );
- return $f->printRowsOnly;
-}
-
-#-------------------------------------------------------------------
-
=head2 displayTitle ( )
Returns this instance's title if displayTitle is set to yes.
@@ -280,7 +211,6 @@ sub duplicate {
WebGUI::ErrorHandler::warn("Couldn't duplicate wobject ".$properties{namespace}." because: ".$@);
}
$w->set(\%properties);
- WebGUI::Discussion::duplicate($_[0]->get("wobjectId"),$w->get("wobjectId")) unless ($_[2]);
return $w->get("wobjectId");
}
@@ -678,38 +608,13 @@ sub new {
bufferPrevId=>{
fieldType=>"hidden"
},
+ forumId=>{
+ fieldType=>"hidden"
+ },
allowDiscussion=>{
fieldType=>"yesNo",
defaultValue=>0
},
- moderationType=>{
- fieldType=>"selectList",
- defaultValue=>"after"
- },
- groupToModerate=>{
- fieldType=>"group",
- defaultValue=>4
- },
- groupToPost=>{
- fieldType=>"group",
- defaultValue=>2
- },
- karmaPerPost=>{
- fieldType=>"integer",
- defaultValue=>0
- } ,
- editTimeout=>{
- defaultValue=>1,
- fieldType=>"interval"
- },
- filterPost=>{
- fieldType=>"filter",
- defaultValue=>"javascript",
- },
- addEditStampToPosts=>{
- fieldType=>"yesNo",
- defaultValue=>1,
- },
title=>{
fieldType=>"text",
defaultValue=>$_[0]->get("namespace")
@@ -845,7 +750,6 @@ sub purge {
WebGUI::SQL->write("delete from wobject where wobjectId=".$_[0]->get("wobjectId"));
$node = WebGUI::Node->new($_[0]->get("wobjectId"));
$node->delete;
- WebGUI::Discussion::purge($_[0]->get("wobjectId"));
}
@@ -1073,23 +977,6 @@ sub uiLevel {
return 0;
}
-#-------------------------------------------------------------------
-
-=head2 www_approvePost ( )
-
-Sets the status flag on a discussion message to "approved".
-
-=cut
-
-sub www_approvePost {
- if (WebGUI::Privilege::isInGroup($_[0]->get("groupToModerate"))) {
- return WebGUI::Discussion::approvePost();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-
#-------------------------------------------------------------------
=head2 www_copy ( )
@@ -1235,54 +1122,6 @@ sub www_deleteFileConfirm {
#-------------------------------------------------------------------
-=head2 www_deleteMessage ( )
-
-Displays a message asking for confirmation to delete a message from a discussion.
-
-=cut
-
-sub www_deleteMessage {
- if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) {
- return WebGUI::Discussion::deleteMessage();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_deleteMessageConfirm ( )
-
-Deletes a message from a discussion.
-
-=cut
-
-sub www_deleteMessageConfirm {
- if (WebGUI::Discussion::canEditMessage($_[0],$session{form}{mid})) {
- return WebGUI::Discussion::deleteMessageConfirm();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_denyPost ( )
-
-Sets the status flag on a discussion message to "denied".
-
-=cut
-
-sub www_denyPost {
- if (WebGUI::Privilege::isInGroup($_[0]->get("groupToModerate"))) {
- return WebGUI::Discussion::denyPost();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-
=head2 www_edit ( [ -properties, -layout, -privileges, -helpId, -heading, -headingId ] )
Displays the common properties of any/all wobjects.
@@ -1342,7 +1181,7 @@ sub www_edit {
if ($_[0]->{_useDiscussion}) {
$tabs{discussion} = {
label=>WebGUI::International::get(892),
- uiLevel=>7
+ uiLevel=>5
};
}
$f = WebGUI::TabForm->new(\%tabs);
@@ -1452,7 +1291,7 @@ sub www_edit {
-value=>$_[0]->get("allowDiscussion"),
-uiLevel=>5
);
- $f->getTab("discussion")->raw($_[0]->discussionProperties);
+ $f->getTab("discussion")->raw(WebGUI::Forum::UI::forumProperties($_[0]->get("forumId")));
}
my $output;
$output = helpIcon($helpId,$_[0]->get("namespace")) if ($helpId);
@@ -1500,29 +1339,13 @@ sub www_editSave {
$set{$key} = $temp if (defined $temp);
}
%set = (%set, %{$_[1]});
+ $set{forumId} = WebGUI::Forum::UI::forumPropertiesSave() if ($_[0]->{_useDiscussion});
$_[0]->set(\%set);
return "";
}
#-------------------------------------------------------------------
-=head2 www_lockThread ( )
-
-Locks a discussion thread from the current message down.
-
-=cut
-
-sub www_lockThread {
- if (WebGUI::Privilege::isInGroup($_[0]->get("groupToModerate"))) {
- WebGUI::Discussion::lockThread();
- return $_[0]->www_showMessage;
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-
=head2 www_moveBottom ( )
Moves this instance to the bottom of the page.
@@ -1634,120 +1457,6 @@ sub www_paste {
#-------------------------------------------------------------------
-=head2 www_post ( )
-
-Displays a discussion message post form.
-
-=cut
-
-sub www_post {
- if (WebGUI::Privilege::isInGroup($_[0]->get("groupToPost"))) {
- return WebGUI::Discussion::post($_[0]);
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_post ( )
-
-Saves a message post to a discussion.
-
-=cut
-
-sub www_postSave {
- if (WebGUI::Privilege::isInGroup($_[0]->get("groupToPost"))) {
- WebGUI::Discussion::postSave($_[0]);
- return $_[0]->www_showMessage();
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_search ( )
-
-Searches an attached discussion.
-
-=cut
-
-sub www_search {
- return WebGUI::Discussion::search();
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_showMessage ( [menuItem] )
-
-Shows a message from a discussion.
-
-=over
-
-=item menuItem
-
-You can optionally extend this method by passing in an HTML string of menu items to be added to the menu of this display.
-
-=back
-
-=cut
-
-sub www_showMessage {
- my ($output, $defaultMid);
- ($defaultMid) = WebGUI::SQL->quickArray("select min(messageId) from discussion where wobjectId=".$_[0]->get("wobjectId"));
- $session{form}{mid} = $session{form}{mid} || $defaultMid || 0;
- $output = WebGUI::Discussion::showMessage($_[1],$_[0]);
- $output .= WebGUI::Discussion::showReplyTree($_[0]);
- return $output;
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_subscribeToThread ( )
-
-Subscribes the current user to a specified discussion thread.
-
-=cut
-
-sub www_subscribeToThread {
- WebGUI::Discussion::subscribeToThread();
- return $_[0]->www_showMessage();
-}
-
-
-#-------------------------------------------------------------------
-
-=head2 www_unlockThread ( )
-
-Unlocks a discussion thread from the current message on down.
-
-=cut
-
-sub www_unlockThread {
- if (WebGUI::Privilege::isInGroup($_[0]->get("groupToModerate"))) {
- WebGUI::Discussion::unlockThread();
- return $_[0]->www_showMessage;
- } else {
- return WebGUI::Privilege::insufficient();
- }
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_subscribeToThread ( )
-
-Unsubscribes the current user from a specified discussion thread.
-
-=cut
-
-sub www_unsubscribeFromThread {
- WebGUI::Discussion::unsubscribeFromThread();
- return $_[0]->www_showMessage();
-}
-
-#-------------------------------------------------------------------
-
=head2 www_view ( )
The default display mechanism for any wobject. This web method MUST be overridden.
diff --git a/lib/WebGUI/Wobject/Article.pm b/lib/WebGUI/Wobject/Article.pm
index f20e6cbc0..59f3b14d0 100644
--- a/lib/WebGUI/Wobject/Article.pm
+++ b/lib/WebGUI/Wobject/Article.pm
@@ -14,6 +14,7 @@ use strict;
use Tie::CPHash;
use WebGUI::Attachment;
use WebGUI::DateTime;
+use WebGUI::Forum;
use WebGUI::Forum::UI;
use WebGUI::HTML;
use WebGUI::HTMLForm;
@@ -117,11 +118,6 @@ sub www_editSave {
return $_[0]->SUPER::www_editSave(\%property);
}
-#-------------------------------------------------------------------
-sub www_showMessage {
- return $_[0]->SUPER::www_showMessage(''.WebGUI::International::get(27,$_[0]->get("namespace")).'
');
-}
-
#-------------------------------------------------------------------
sub www_view {
my ($file, %var);
@@ -182,23 +178,24 @@ sub www_view {
$var{"attachment.icon"} = $file->getIcon;
$var{"attachment.url"} = $file->getURL;
$var{"attachment.name"} = $file->getFilename;
- }
+ }
+ my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId"));
if ($_[0]->get("allowDiscussion")) {
- ($var{"replies.count"}) = WebGUI::SQL->quickArray("select count(*) from discussion
- where wobjectId=".$_[0]->get("wobjectId"));
- $var{"replies.URL"} = WebGUI::URL::page('func=showMessage&wid='.$_[0]->get("wobjectId"));
+ my $forum = WebGUI::Forum->new($_[0]->get("forumId"));
+ $var{"replies.count"} = $forum->get("replies");
+ $var{"replies.URL"} = WebGUI::Forum::UI::formatForumURL($callback,$forum->get("forumId"));
$var{"replies.label"} = WebGUI::International::get(28,$_[0]->get("namespace"));
- $var{"post.URL"} = WebGUI::URL::page('func=post&mid=new&wid='.$_[0]->get("wobjectId"));
+ $var{"post.URL"} = WebGUI::Forum::UI::formatNewThreadURL($callback,$forum->get("forumId"));
$var{"post.label"} = WebGUI::International::get(24,$_[0]->get("namespace"));
}
- my $templateId = $_[0]->getValue("templateId");
+ my $templateId = $_[0]->getValue("templateId");
if ($session{form}{func} eq "editSave") {
$templateId = $_[0]->get("templateId");
}
if ($session{form}{forumOp}) {
- return WebGUI::Forum::UI::forumOp(WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")));
+ return WebGUI::Forum::UI::forumOp($callback,$_[0]->get("forumId"));
} else {
- return $_[0]->processTemplate($templateId,\%var).WebGUI::Forum::UI::viewForum(WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")),1);
+ return $_[0]->processTemplate($templateId,\%var);
}
}