fixed a lot o bugs

This commit is contained in:
JT Smith 2003-11-18 06:19:36 +00:00
parent f2584fe07b
commit d150016395
6 changed files with 173 additions and 88 deletions

View file

@ -1,14 +1,13 @@
5.5.2
- Fixed a bug introduced in the last version that only occurs if there was
one forum in a message board.
- Fixed a bug introduced in the last version when replying to USS
submissions.
- Fixed a bug introduced in 5.5.0 because the reply.url variable in the USS
submission template didn't get updated to reflect the new forum system.
- Fixed a whole slew of bugs in the forums introduced in the last version.
- Fixed a bug in the reply.url variable in the USS submission where template didn't get updated to reflect the new forum system.
- Fixed a bug in the forum search system where it would search all messages
regardless of forum.
- Fixed bugs where counters weren't being decremented when a post was
deleted.
- Fixed bug [ 843591 ] Fatal error while creating a new Message Board if
there are no Forums yet.
5.5.1
- Fixed bug #829806 preventing users from updating thier passwords from the updateAccount form.
- Added Apache 2 instructions to install.txt. (Thanks to Andy Grundman.)

View file

@ -39,6 +39,8 @@ Data management class for forums.
$boolean = $forum->isModerator;
$boolean = $forum->isSubscribed;
$forum->decrementReplies;
$forum->decrementThreads;
$forum->incrementReplies($postDate, $postId);
$forum->incrementThreads($postDate, $postId);
$forum->incrementViews;
@ -120,6 +122,32 @@ sub create {
return WebGUI::Forum->new($forumId);
}
#-------------------------------------------------------------------
=head2 decrementReplies ( )
Deccrements this forum's reply counter.
=cut
sub incrementReplies {
my ($self) = @_;
WebGUI::SQL->write("update forum set replies=replies-1 where forumId=".$self->get("forumId"));
}
#-------------------------------------------------------------------
=head2 decrementThreads ( )
Decrements this forum's thread counter.
=cut
sub incrementReplies {
my ($self) = @_;
WebGUI::SQL->write("update forum set threads=threads-1 where forumId=".$self->get("forumId"));
}
#-------------------------------------------------------------------
=head2 get ( [ param ] )

View file

@ -32,6 +32,7 @@ Data management class for forum posts.
$post = WebGUI::Forum::Post->new($postId);
$boolean = $post->canEdit;
$boolean = $post->canView;
$scalar = $post->get("forumPostId");
$arrayRef = $post->getReplies;
$obj = $post->getThread;
@ -82,6 +83,36 @@ sub canEdit {
#-------------------------------------------------------------------
=head2 canView ( [ userId ] )
Returns a boolean indicating whether the user can view the current post.
=over
=item userId
The unique identifier to check privileges against. Defaults to the current user.
=back
=cut
sub canView {
my ($self, $userId) = @_;
$userId = $session{user}{userId} unless ($userId);
if ($self->get("status") eq "deleted") {
return 0;
} elsif ($self->get("status") eq "denied" && $userId == $self->get("userId")) {
return 1;
} elsif ($self->getThread->getForum->isModerator) {
return 1;
} else {
return 0;
}
}
#-------------------------------------------------------------------
=head2 create ( [ data ] )
Creates a new post.
@ -432,6 +463,7 @@ Sets the status of this post to deleted.
sub setStatusDeleted {
my ($self) = @_;
$self->set({status=>'deleted'});
$self->getThread->decrementReplies;
$self->getThread->setStatusDeleted if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
if ($self->getThread->get("lastPostId") == $self->get("forumPostId")) {
my ($id, $date) = WebGUI::SQL->quickArray("select forumPostId,dateOfPost from forumPost where forumThreadId="

View file

@ -41,6 +41,7 @@ Data management class for forum threads.
$boolean = $thread->isSticky;
$boolean = $thread->isSubscribed;
$thread->decrementReplies;
$thread->incrementReplies($postDate, $postId);
$thread->incrementViews;
$thread->lock;
@ -103,6 +104,20 @@ sub create {
#-------------------------------------------------------------------
=head2 decrementReplies ( )
Decrements the replies counter for this thread.
=cut
sub deccrementReplies {
my ($self) = @_;
WebGUI::SQL->write("update forumThread set replies=replies-1 where forumThreadId=".$self->get("forumThreadId"));
$self->getForum->decrementReplies;
}
#-------------------------------------------------------------------
=head2 get ( [ param ] )
Returns a hash reference containing all the properties of this thread.
@ -439,6 +454,7 @@ Sets the status of this thread to deleted.
sub setStatusDeleted {
my ($self) = @_;
$self->set({status=>'deleted'});
$self->getForum->decrementThreads;
}
#-------------------------------------------------------------------

View file

@ -26,6 +26,7 @@ use WebGUI::MessageLog;
use WebGUI::Search;
use WebGUI::Session;
use WebGUI::Template;
use WebGUI::User;
=head1 DESCRIPTION
@ -1273,7 +1274,7 @@ sub getThreadTemplateVars {
my $callback = $caller->{callback};
$post->markRead($session{user}{userId});
my $thread = $post->getThread;
if (($post->get("status") eq "denied" && $session{user}{userId} != $post->get("userId")) || $post->get("status") eq "deleted") {
unless ($post->canView) {
$post = $thread->getPost($thread->get("rootPostId"));
}
my $forum = $thread->getForum;
@ -1370,16 +1371,16 @@ sub notifySubscribers {
my %lang;
foreach my $userId (keys %subscribers) {
my $u = WebGUI::User->new($userId);
unless (exists $lang{$u->get("language")}) {
$lang{$u->get("language")}{var} = {
'notify.subscription.message' => WebGUI::International::get(875,$u->get("language"))
unless (exists $lang{$u->profileField("language")}) {
$lang{$u->profileField("language")}{var} = {
'notify.subscription.message' => WebGUI::International::get(875,$u->profileField("language"))
};
$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});
$lang{$u->profileField("language")}{var} = getPostTemplateVars($post, $thread, $forum, $caller, $lang{$u->profileField("language")}{var});
$lang{$u->profileField("language")}{subject} = WebGUI::International::get(523,$u->profileField("language"));
$lang{$u->profileField("language")}{message} = WebGUI::Template::process(WebGUI::Template::get($forum->get("notificationTemplateId"),"Forum/Notification"),
$lang{$u->profileField("language")}{var});
}
WebGUI::MessageLog::addEntry($userId,"",$lang{$u->get("language")}{subject},$lang{$u->get("language")}{message});
WebGUI::MessageLog::addEntry($userId,"",$lang{$u->profileField("language")}{subject},$lang{$u->profileField("language")}{message});
}
}
@ -1426,15 +1427,17 @@ sub recurseThread {
push(@depth_loop,{depth=>$i});
}
my @post_loop;
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, $caller, $currentPost)});
}
if ($post->canView) {
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, $caller, $currentPost)});
}
}
return \@post_loop;
}
@ -2071,9 +2074,12 @@ sub www_search {
$var{'post.subject.label'} = WebGUI::International::get(229);
$var{'post.date.label'} = WebGUI::International::get(245);
$var{'post.user.label'} = WebGUI::International::get(244);
my $query = "select forumPostId,subject,userId,username,dateOfPost from forumPost where (status='approved' or status='archived') and ";
$query .= WebGUI::Search::buildConstraints([qw(subject username message)]);
my $p = WebGUI::Paginator->new(WebGUI::URL::append($caller->{callback},"forumOp=search&doit=1&forumId=".$forum->get("forumId")),"", $numResults);
my $query = "select a.forumPostId, a.subject, a.userId, a.username, a.dateOfPost from forumPost a left join forumThread b
on a.forumThreadId=b.forumThreadId where b.forumId=".$forum->get("forumId")." and
(a.status='approved' or a.status='archived') and ".WebGUI::Search::buildConstraints([qw(a.subject a.username a.message)])
." order by a.dateOfPost desc";
my $p = WebGUI::Paginator->new(WebGUI::URL::append($caller->{callback},"forumOp=search&doit=1&forumId=".$forum->get("forumId")),
"", $numResults);
$p->setDataByQuery($query);
my @post_loop;
foreach my $row (@{$p->getPageData}) {
@ -2299,7 +2305,7 @@ sub www_viewThread {
$postId = $session{form}{forumPostId} unless ($postId);
my $post = WebGUI::Forum::Post->new($postId);
my $var = getThreadTemplateVars($caller, $post);
if (($post->get("forumPostId") == $post->getThread->get("rootPostId") && $post->get("status") eq "denied" && $session{user}{userId} != $post->get("userId")) || $post->get("status") eq "deleted") {
if ($post->get("forumPostId") == $post->getThread->get("rootPostId") && !$post->canView) {
return www_viewForum($caller, $post->getThread->getForum->get("forumId"));
} else {
return WebGUI::Template::process(WebGUI::Template::get($post->getThread->getForum->get("threadTemplateId"),"Forum/Thread"), $var);

View file

@ -164,73 +164,77 @@ sub www_moveForumUp {
#-------------------------------------------------------------------
sub www_view {
my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId"));
if ($session{form}{forumId} eq "" || $session{form}{forumId} eq "new") {
($session{form}{forumId}) = WebGUI::SQL->quickArray("select forumId from MessageBoard_forums
where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
}
my ($forumId, $title, $description) = WebGUI::SQL->quickArray("select forumId, title, description from MessageBoard_forums
where wobjectId=".$_[0]->get("wobjectId")." and forumId=".quote($session{form}{forumId}));
my $forumParam = "forumId=".$forumId;
$callback = WebGUI::URL::append($callback,$forumParam);
my $caller = {
callback=>$callback,
title=>$title,
description=>$description,
forumId=>$forumId
};
if ($session{form}{forumOp}) {
return WebGUI::Forum::UI::forumOp($caller);
}
my %var;
$var{title} = $_[0]->get("title");
$var{description} = $_[0]->get("description");
$var{'forum.add.url'} = WebGUI::URL::page("func=editForum&forumId=new&wid=".$_[0]->get("wobjectId"));
$var{'forum.add.label'} = WebGUI::International::get(75,$_[0]->get("namespace"));
$var{'title.label'} = WebGUI::International::get(99);
$var{'views.label'} = WebGUI::International::get(514);
$var{'rating.label'} = WebGUI::International::get(1020);
$var{'threads.label'} = WebGUI::International::get(1036);
$var{'replies.label'} = WebGUI::International::get(1016);
$var{'lastpost.label'} = WebGUI::International::get(1017);
my $count = 1;
my @forum_loop;
my $caller;
my $sth = WebGUI::SQL->read("select * from MessageBoard_forums where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
while (my $forumMeta = $sth->hashRef) {
my $forum = WebGUI::Forum->new($forumMeta->{forumId});
if ($count == 1) {
$var{'default.listing'} = WebGUI::Forum::UI::www_viewForum($caller,$forumMeta->{forumId});
$var{'default.description'} = $forumMeta->{description};
$var{'default.title'} = $forumMeta->{title};
$var{'default.controls'} = $_[0]->_formatControls($forum->get("forumId"));
my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")."&forumId=".$forumMeta->{forumId});
if ($session{form}{forumOp}) {
if ($session{form}{forumId} == $forumMeta->{forumId}) {
$caller = {
callback=>$callback,
title=>$forumMeta->{title},
description=>$forumMeta->{description},
forumId=>$forumMeta->{forumId}
};
}
} else {
my $forum = WebGUI::Forum->new($forumMeta->{forumId});
if ($count == 1) {
$var{'default.listing'} = WebGUI::Forum::UI::www_viewForum({
callback=>$callback,
title=>$forumMeta->{title},
description=>$forumMeta->{description},
forumId=>$forumMeta->{forumId}
},$forumMeta->{forumId});
$var{'default.description'} = $forumMeta->{description};
$var{'default.title'} = $forumMeta->{title};
$var{'default.controls'} = $_[0]->_formatControls($forum->get("forumId"));
}
my $lastPost = WebGUI::Forum::Post->new($forum->get("lastPostId"));
push(@forum_loop, {
'forum.controls' => $_[0]->_formatControls($forum->get("forumId")),
'forum.count' => $count,
'forum.title' => $forumMeta->{title},
'forum.description' => $forumMeta->{description},
'forum.replies' => $forum->get("replies"),
'forum.rating' => $forum->get("rating"),
'forum.views' => $forum->get("views"),
'forum.threads' => $forum->get("threads"),
'forum.url' => WebGUI::Forum::UI::formatForumURL($callback,$forum->get("forumId")),
'forum.lastPost.url' => WebGUI::Forum::UI::formatThreadURL($callback,$lastPost->get("forumPostId")),
'forum.lastPost.date' => WebGUI::Forum::UI::formatPostDate($lastPost->get("dateOfPost")),
'forum.lastPost.time' => WebGUI::Forum::UI::formatPostTime($lastPost->get("dateOfPost")),
'forum.lastPost.epoch' => $lastPost->get("dateOfPost"),
'forum.lastPost.subject' => WebGUI::Forum::UI::formatSubject($lastPost->get("subject")),
'forum.lastPost.user.id' => $lastPost->get("userId"),
'forum.lastPost.user.name' => $lastPost->get("username"),
'forum.lastPost.user.profile' => WebGUI::Forum::UI::formatUserProfileURL($lastPost->get("userId")),
'forum.lastPost.user.isVisitor' => ($lastPost->get("userId") == 1)
});
$count++;
}
my $lastPost = WebGUI::Forum::Post->new($forum->get("lastPostId"));
push(@forum_loop, {
'forum.controls' => $_[0]->_formatControls($forum->get("forumId")),
'forum.count' => $count,
'forum.title' => $forumMeta->{title},
'forum.description' => $forumMeta->{description},
'forum.replies' => $forum->get("replies"),
'forum.rating' => $forum->get("rating"),
'forum.views' => $forum->get("views"),
'forum.threads' => $forum->get("threads"),
'forum.url' => WebGUI::Forum::UI::formatForumURL($callback,$forum->get("forumId")),
'forum.lastPost.url' => WebGUI::Forum::UI::formatThreadURL($callback,$lastPost->get("forumPostId")),
'forum.lastPost.date' => WebGUI::Forum::UI::formatPostDate($lastPost->get("dateOfPost")),
'forum.lastPost.time' => WebGUI::Forum::UI::formatPostTime($lastPost->get("dateOfPost")),
'forum.lastPost.epoch' => $lastPost->get("dateOfPost"),
'forum.lastPost.subject' => WebGUI::Forum::UI::formatSubject($lastPost->get("subject")),
'forum.lastPost.user.id' => $lastPost->get("userId"),
'forum.lastPost.user.name' => $lastPost->get("username"),
'forum.lastPost.user.profile' => WebGUI::Forum::UI::formatUserProfileURL($lastPost->get("userId")),
'forum.lastPost.user.isVisitor' => ($lastPost->get("userId") == 1)
});
$count++;
}
$sth->finish;
$var{areMultipleForums} = ($count > 2);
$var{forum_loop} = \@forum_loop;
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
if ($session{form}{forumOp}) {
return WebGUI::Forum::UI::forumOp($caller);
} else {
$var{title} = $_[0]->get("title");
$var{description} = $_[0]->get("description");
$var{'forum.add.url'} = WebGUI::URL::page("func=editForum&forumId=new&wid=".$_[0]->get("wobjectId"));
$var{'forum.add.label'} = WebGUI::International::get(75,$_[0]->get("namespace"));
$var{'title.label'} = WebGUI::International::get(99);
$var{'views.label'} = WebGUI::International::get(514);
$var{'rating.label'} = WebGUI::International::get(1020);
$var{'threads.label'} = WebGUI::International::get(1036);
$var{'replies.label'} = WebGUI::International::get(1016);
$var{'lastpost.label'} = WebGUI::International::get(1017);
$var{areMultipleForums} = ($count > 2);
$var{forum_loop} = \@forum_loop;
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
}
}
1;