Fix how Thread determines the "current" Post to be a little more logical,

and fix shortcuts to non-Thread Posts (they weren't doing prepareView on
the thread).
This commit is contained in:
Drake 2006-11-22 15:38:32 +00:00
parent 3ca4bf725a
commit 0903b1011e
3 changed files with 13 additions and 2 deletions

View file

@ -979,10 +979,19 @@ sub update {
}
#-------------------------------------------------------------------
sub prepareView {
my $self = shift;
$self->SUPER::prepareView;
unless ($self->getThread->getId eq $self->getId) {
# Need the unless to avoid infinite recursion.
$self->getThread->prepareView;
}
}
sub view {
my $self = shift;
$self->incrementViews;
return $self->getThread->view;
return $self->getThread->view($self);
}

View file

@ -770,6 +770,7 @@ sub unsubscribe {
#-------------------------------------------------------------------
sub view {
my $self = shift;
my $currentPost = shift || $self;
$self->markRead;
$self->incrementViews unless ($self->session->form->process("func") eq 'rate');
if ($self->session->user->userId eq '1' && !$self->session->form->process("layout")) {
@ -852,7 +853,7 @@ sub view {
my $reply = WebGUI::Asset::Post->new($self->session, $dataSet->{assetId}, $dataSet->{className}, $dataSet->{revisionDate});
$reply->{_thread} = $self; # caching thread for better performance
my %replyVars = %{$reply->getTemplateVars};
$replyVars{isCurrent} = ($reply->get("url") eq $currentPageUrl);
$replyVars{isCurrent} = ($reply->getId eq $currentPost->getId);
$replyVars{isThreadRoot} = $self->getId eq $reply->getId;
$replyVars{depth} = $reply->getLineageLength - $self->getLineageLength;
$replyVars{depthX10} = $replyVars{depth}*10;