lots of bug fixes

This commit is contained in:
JT Smith 2004-09-06 21:28:55 +00:00
parent fd0413c746
commit b4498138fb
12 changed files with 67 additions and 45 deletions

View file

@ -81,7 +81,7 @@ The unique identifier to check privileges against. Defaults to the current user.
sub canEdit {
my ($self, $userId) = @_;
$userId = $session{user}{userId} unless ($userId);
return ($self->getThread->getForum->isModerator || ($self->get("userId") == $userId && $userId != 1
return ($self->getThread->getForum->isModerator || ($self->get("userId") eq $userId && $userId != 1
&& $self->getThread->getForum->get("editTimeout") > (WebGUI::DateTime::time() - $self->get("dateOfPost"))));
}
@ -108,7 +108,7 @@ sub canView {
return 1;
} elsif ($self->get("status") eq "deleted") {
return 0;
} elsif ($self->get("status") eq "denied" && $userId == $self->get("userId")) {
} elsif ($self->get("status") eq "denied" && $userId eq $self->get("userId")) {
return 1;
} elsif ($self->getThread->getForum->isModerator) {
return 1;
@ -231,7 +231,7 @@ If the user ID equals 1 (visitor) then an IP address is used to distinguish the
sub hasRated {
my ($self, $userId, $ipAddress) = @_;
$userId = $session{user}{userId} unless ($userId);
return 1 if ($userId != 1 && $userId == $self->get("userId")); # is poster
return 1 if ($userId != 1 && $userId eq $self->get("userId")); # is poster
$ipAddress = $session{env}{REMOTE_ADDR} unless ($ipAddress);
my ($flag) = WebGUI::SQL->quickArray("select count(*) from forumPostRating where forumPostId="
.quote($self->get("forumPostId"))." and ((userId=".quote($userId)." and userId<>1) or (userId=1 and
@ -434,7 +434,7 @@ Sets the status of this post to approved.
sub setStatusApproved {
my ($self) = @_;
$self->set({status=>'approved'});
$self->getThread->setStatusApproved if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
$self->getThread->setStatusApproved if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
if ($self->isReply) {
$self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId"));
}
@ -452,7 +452,7 @@ Sets the status of this post to archived.
sub setStatusArchived {
my ($self) = @_;
$self->set({status=>'archived'});
$self->getThread->setStatusArchived if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
$self->getThread->setStatusArchived if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
if ($self->isReply) {
$self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId"));
}
@ -470,7 +470,7 @@ sub setStatusDeleted {
my ($self) = @_;
$self->set({status=>'deleted'});
$self->getThread->decrementReplies;
$self->getThread->setStatusDeleted if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
$self->getThread->setStatusDeleted if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
my ($id, $date) = WebGUI::SQL->quickArray("select forumPostId,dateOfPost from forumPost where forumThreadId="
.quote($self->get("forumThreadId"))." and status='approved'");
$self->getThread->setLastPost($date,$id);
@ -487,7 +487,7 @@ Sets the status of this post to denied.
sub setStatusDenied {
my ($self) = @_;
$self->set({status=>'denied'});
$self->getThread->setStatusDenied if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
$self->getThread->setStatusDenied if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
}
#-------------------------------------------------------------------
@ -501,7 +501,7 @@ Sets the status of this post to pending.
sub setStatusPending {
my ($self) = @_;
$self->set({status=>'pending'});
$self->getThread->setStatusPending if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
$self->getThread->setStatusPending if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
}

View file

@ -1162,7 +1162,7 @@ sub getForumTemplateVars {
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
if ($thread->{rootPostId} eq $thread->{lastPostId}) { #saves the lookup if it's the same id
$last = $root;
} else {
$last = WebGUI::Forum::Post->new($thread->{lastPostId});
@ -1418,12 +1418,12 @@ sub notifySubscribers {
my %subscribers;
my $sth = WebGUI::SQL->read("select userId from forumThreadSubscription where forumThreadId=".quote($thread->get("forumThreadId")));
while (my ($userId) = $sth->array) {
$subscribers{$userId} = $userId unless ($userId == $post->get("userId")); # make sure we don't send unnecessary messages
$subscribers{$userId} = $userId unless ($userId eq $post->get("userId")); # make sure we don't send unnecessary messages
}
$sth->finish;
$sth = WebGUI::SQL->read("select userId from forumSubscription where forumId=".quote($forum->get("forumId")));
while (my ($userId) = $sth->array) {
$subscribers{$userId} = $userId unless ($userId == $post->get("userId")); # make sure we don't send unnecessary messages
$subscribers{$userId} = $userId unless ($userId eq $post->get("userId")); # make sure we don't send unnecessary messages
}
$sth->finish;
my %lang;
@ -1569,7 +1569,7 @@ A post object.
sub setPostApproved {
my ($caller, $post) = @_;
$post->setStatusApproved;
unless ($session{user}{userId} == $post->get("userId")) {
unless ($session{user}{userId} eq $post->get("userId")) {
WebGUI::MessageLog::addInternationalizedEntry($post->get("userId"),'',formatThreadURL($caller->{callback},$post->get("forumPostId")),579);
}
notifySubscribers($post,$post->getThread,$post->getThread->getForum,$caller);
@ -2504,7 +2504,7 @@ sub www_viewThread {
my $post = WebGUI::Forum::Post->new($postId);
return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->canView);
my $var = getThreadTemplateVars($caller, $post);
if ($post->get("forumPostId") == $post->getThread->get("rootPostId") && !$post->canView) {
if ($post->get("forumPostId") eq $post->getThread->get("rootPostId") && !$post->canView) {
return www_viewForum($caller, $post->getThread->getForum->get("forumId"));
} else {
return WebGUI::Template::process($post->getThread->getForum->get("threadTemplateId"),"Forum/Thread", $var);