From c3556012494804980bb0559f4212d64f965029ab Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 29 Mar 2006 21:49:56 +0000 Subject: [PATCH] fixed bugs with new chunking system --- lib/WebGUI/Asset/Post/Thread.pm | 62 ++++++++++++++++++--------------- lib/WebGUI/Asset/Wobject.pm | 42 ---------------------- 2 files changed, 33 insertions(+), 71 deletions(-) diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 5bafe5726..a7faef35f 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -810,7 +810,6 @@ sub view { $var->{"collaboration.url"} = $self->getThread->getParent->getUrl; $var->{'collaboration.title'} = $self->getParent->get("title"); $var->{'collaboration.description'} = $self->getParent->get("description"); - return $self->processTemplate($var,undef,$self->{_viewTemplate}); } @@ -948,39 +947,44 @@ sub www_unsubscribe { } #------------------------------------------------------------------- + +=head2 www_view ( ) + +Renders self->view based upon current style, subject to timeouts. Returns Privilege::noAccess() if canView is False. + +=cut + sub www_view { - my $self = shift; + my $self = shift; my $postId = shift; return $self->session->privilege->noAccess() unless $self->canView; - my $cache; - my $output; - my $useCache = ( - $self->session->form->process("op") eq "" && - $self->session->form->process("func") eq "" && - $self->session->form->process("layout") eq "" && - ( - ( $self->getParent->get("cacheTimeout") > 10 && $self->session->user->userId ne '1') || - ( $self->getParent->get("cacheTimeoutVisitor") > 10 && $self->session->user->userId eq '1') - ) && - not $self->session->var->get("adminOn") - ); - if ($useCache) { - $cache = WebGUI::Cache->new($self->session,"cspost_".($postId||$self->getId)."_".$self->session->user->userId."_".$self->session->scratch->get("discussionLayout")."_".$self->session->form->process("pn")); - $output = $cache->get; - } - unless ($output) { - $output = $self->getParent->processStyle($self->view); - my $ttl; - if ($self->session->user->userId eq '1') { - $ttl = $self->getParent->get("cacheTimeoutVisitor"); - } else { - $ttl = $self->getParent->get("cacheTimeout"); - } - $cache->set($output, $ttl) if ($useCache); - } - return $output; + unless ($self->canView) { + if ($self->get("state") eq "published") { # no privileges, make em log in + return $self->session->privilege->noAccess(); + } elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^trash/) { # show em trash + $self->session->http->setRedirect($self->getUrl("func=manageTrash")); + return undef; + } elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^clipboard/) { # show em clipboard + $self->session->http->setRedirect($self->getUrl("func=manageClipboard")); + return undef; + } else { # tell em it doesn't exist anymore + $self->session->http->setStatus("410"); + return WebGUI::Asset->getNotFound($self->session)->www_view; + } + } + # must find a way to do this next line better + $self->session->http->setCookie("wgSession",$self->session->var->{_var}{sessionId}) unless $self->session->var->{_var}{sessionId} eq $self->session->http->getCookies->{"wgSession"}; + $self->session->http->getHeader; + $self->prepareView; + my $style = $self->getParent->processStyle("~~~"); + my ($head, $foot) = split("~~~",$style); + $self->session->output->print($head); + $self->session->output->print($self->view); + $self->session->output->print($foot); + return "chunked"; } + 1; diff --git a/lib/WebGUI/Asset/Wobject.pm b/lib/WebGUI/Asset/Wobject.pm index 1a07c9017..ea70d6b0c 100644 --- a/lib/WebGUI/Asset/Wobject.pm +++ b/lib/WebGUI/Asset/Wobject.pm @@ -588,11 +588,6 @@ sub www_view { return WebGUI::Asset->getNotFound($self->session)->www_view; } } -# causes problems with the wre so it's commented out -# if ($self->get("encryptPage") && $self->session->env->get("HTTPS") ne "on") { - # $self->session->http->setRedirect($self->getUrl); - # return ""; - # } $self->logView(); # must find a way to do this next line better $self->session->http->setCookie("wgSession",$self->session->var->{_var}{sessionId}) unless $self->session->var->{_var}{sessionId} eq $self->session->http->getCookies->{"wgSession"}; @@ -606,42 +601,5 @@ sub www_view { return "chunked"; } -#------------------------------------------------------------------- - -=head2 www_view ( [ disableCache ] ) - -Renders self->view based upon current style, subject to timeouts. Returns Privilege::noAccess() if canView is False. - -=cut -sub www_viewOld { - my $self = shift; - my $disableCache = shift; - my $cache; - my $output; - my $useCache = ( - $self->session->form->process("op") eq "" && $self->session->form->process("pn") eq "" - && ( - ( $self->get("cacheTimeout") > 10 && $self->session->user->userId ne '1') - || ( $self->get("cacheTimeoutVisitor") > 10 && $self->session->user->userId eq '1') - ) - && !( $self->session->var->get("adminOn") || $disableCache) - ); - if ($useCache) { - $cache = WebGUI::Cache->new($self->session,"wobject_".$self->getId."_".$self->session->user->userId); - $output = $cache->get; - } - unless ($output) { - $output = $self->processStyle($self->view); - my $ttl; - if ($self->session->user->userId eq '1') { - $ttl = $self->get("cacheTimeoutVisitor"); - } else { - $ttl = $self->get("cacheTimeout"); - } - $cache->set($output, $ttl) if ($useCache && !$self->session->http->isRedirect()); - } - return $output; -} - 1;