From fb434a8b3a662fdff1d4c74684456f552937882b Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 25 Jan 2008 01:36:14 +0000 Subject: [PATCH] fix: content handler and redirects --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset.pm | 22 +- lib/WebGUI/Asset/FilePile.pm | 9 +- lib/WebGUI/Asset/RSSCapable.pm | 2 +- lib/WebGUI/Asset/Redirect.pm | 32 +- lib/WebGUI/Asset/Template.pm | 2 +- lib/WebGUI/Asset/Wobject/Dashboard.pm | 4 +- lib/WebGUI/Asset/Wobject/Matrix.pm | 5 +- lib/WebGUI/Asset/Wobject/Navigation.pm | 2 +- lib/WebGUI/Asset/Wobject/WSClient.pm | 1 + lib/WebGUI/Asset/_NewAsset.skeleton | 2 +- lib/WebGUI/AssetBranch.pm | 1 + lib/WebGUI/AssetClipboard.pm | 2 +- lib/WebGUI/AssetPackage.pm | 1 + lib/WebGUI/AssetVersioning.pm | 2 +- lib/WebGUI/Auth.pm | 1 + lib/WebGUI/Content/Asset.pm | 9 +- lib/WebGUI/Content/Prefetch.pm | 5 +- lib/WebGUI/Content/Setup.pm | 1 - lib/WebGUI/Form/HTMLArea.pm | 4 +- lib/WebGUI/Operation/AdSpace.pm | 2 +- lib/WebGUI/Operation/Commerce.pm | 2 +- lib/WebGUI/Operation/FormHelpers.pm | 475 ------------------------- lib/WebGUI/Operation/LDAPLink.pm | 1 + lib/WebGUI/Operation/Subscription.pm | 4 +- lib/WebGUI/URL/Content.pm | 24 +- 26 files changed, 74 insertions(+), 542 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4541680ef..e49c38e0a 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,6 +1,7 @@ 7.5.1 - fix: Friends language error (perlDreamer Consulting, LLC.) http://www.plainblack.com/bugs/tracker/friends-language-error + - fix: content handler and redirects - fix: newByDynamicClass would die if given bad parameters, must return undef - fix: AssetPackage.pm would give an error on importing a package through the web interface, but the package would be imported successfully. diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 833a77416..5c95f09fa 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -297,15 +297,18 @@ sub checkView { if ($conf->get("sslEnabled") && $self->get("encryptPage") && $env->get("HTTPS") ne "on" && !$env->get("SSLPROXY")) { # getUrl already changes url to https if 'encryptPage' $http->setRedirect($self->getUrl); - return "redirect"; + $http->sendHeader; + return "chunked"; } elsif ($var->isAdminOn && $self->get("state") =~ /^trash/) { # show em trash $http->setRedirect($self->getUrl("func=manageTrash")); - return "redirect"; + $http->sendHeader; + return "chunked"; } elsif ($var->isAdminOn && $self->get("state") =~ /^clipboard/) { # show em clipboard $http->setRedirect($self->getUrl("func=manageClipboard")); - return "redirect"; + $http->sendHeader; + return "chunked"; } elsif ($self->get("state") ne "published") { # tell em it doesn't exist anymore $http->setStatus("410"); @@ -2374,10 +2377,8 @@ sub www_changeUrlConfirm { if ($self->session->form->param("proceed") eq "manageAssets") { $self->session->http->setRedirect($self->getUrl('func=manageAssets')); - return 'redirect'; } else { $self->session->http->setRedirect($self->getUrl()); - return 'redirect'; } return undef; @@ -2459,7 +2460,7 @@ sub www_editSave { $self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId) ); } - return "1"; + return undef; } # Handle Auto Request Commit setting @@ -2474,6 +2475,7 @@ sub www_editSave { $self->session->http->setRedirect( $self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId) ); + return undef; } } @@ -2556,12 +2558,18 @@ Returns the view() method of the asset object if the requestor canView. sub www_view { my $self = shift; + + # don't allow viewing of the root asset if ($self->getId eq "PBasset000000000000001") { $self->session->http->setRedirect($self->getDefault($self->session)->getUrl); - return "1"; + return undef; } + + # check view privs my $check = $self->checkView; return $check if (defined $check); + + # if all else fails $self->prepareView; $self->session->output->print($self->view); return undef; diff --git a/lib/WebGUI/Asset/FilePile.pm b/lib/WebGUI/Asset/FilePile.pm index 4f71c9568..38f1ad8ae 100644 --- a/lib/WebGUI/Asset/FilePile.pm +++ b/lib/WebGUI/Asset/FilePile.pm @@ -192,16 +192,19 @@ sub editSave { if ($self->session->form->process("saveAndCommit") ne "") { if ($self->session->setting->get("skipCommitComments")) { $self->session->http->setRedirect($self->getUrl("op=commitVersionTagConfirm;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)); - } else { + } + else { $self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)); } - return "1"; + return undef; } if ($self->session->setting->get("autoRequestCommit")) { if ($self->session->setting->get("skipCommitComments")) { WebGUI::VersionTag->getWorking($self->session)->requestCommit; - } else { + } + else { $self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)); + return undef; } } diff --git a/lib/WebGUI/Asset/RSSCapable.pm b/lib/WebGUI/Asset/RSSCapable.pm index cc43e2019..58709a513 100644 --- a/lib/WebGUI/Asset/RSSCapable.pm +++ b/lib/WebGUI/Asset/RSSCapable.pm @@ -196,7 +196,7 @@ sub www_viewRSS { $session->http->setRedirect($self->getRssUrl); } - return ""; + return undef; } diff --git a/lib/WebGUI/Asset/Redirect.pm b/lib/WebGUI/Asset/Redirect.pm index f908a7718..c9ac9117d 100644 --- a/lib/WebGUI/Asset/Redirect.pm +++ b/lib/WebGUI/Asset/Redirect.pm @@ -115,24 +115,24 @@ A web executable method that redirects the user to the specified page, or displa =cut sub www_view { - my $self = shift; - return $self->session->privilege->noAccess() unless $self->canView; + my $self = shift; + return $self->session->privilege->noAccess() unless $self->canView; my $i18n = WebGUI::International->new($self->session, "Asset_Redirect"); - my $url = $self->get("redirectUrl"); - WebGUI::Macro::process($self->session, \$url); - if ($self->session->var->isAdminOn() && $self->canEdit) { - return $self->getAdminConsole->render($i18n->get("what do you want to do with this redirect").' - ',$i18n->get("assetName")); - } - unless ($url eq $self->get("url")) { - $self->session->http->setRedirect($url); - return 1; + my $url = $self->get("redirectUrl"); + WebGUI::Macro::process($self->session, \$url); + if ($self->session->var->isAdminOn() && $self->canEdit) { + return $self->getAdminConsole->render($i18n->get("what do you want to do with this redirect").' + ',$i18n->get("assetName")); + } + unless ($url eq $self->get("url")) { + $self->session->http->setRedirect($url); + return undef; } - return $i18n->get('self_referential'); + return $i18n->get('self_referential'); } 1; diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 452d365a6..e349b9aee 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -375,7 +375,7 @@ sub www_edit { sub www_goBackToPage { my $self = shift; $self->session->http->setRedirect($self->session->form->get("returnUrl")) if ($self->session->form->get("returnUrl")); - return ""; + return undef; } diff --git a/lib/WebGUI/Asset/Wobject/Dashboard.pm b/lib/WebGUI/Asset/Wobject/Dashboard.pm index 6137f00e3..bcafbf53e 100644 --- a/lib/WebGUI/Asset/Wobject/Dashboard.pm +++ b/lib/WebGUI/Asset/Wobject/Dashboard.pm @@ -348,10 +348,10 @@ sub www_view { 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 ""; + return undef; } elsif ($self->session->var->get("adminOn") && $self->get("state") =~ /^clipboard/) { # show em clipboard $self->session->http->setRedirect($self->getUrl("func=manageClipboard")); - return ""; + return undef; } else { # tell em it doesn't exist anymore $self->session->http->setStatus("410"); return WebGUI::Asset->getNotFound($self->session)->www_view; diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index fada45951..0ab34a047 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -267,10 +267,11 @@ sub www_click { my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId")); if ($self->session->form->process("m")) { $self->session->http->setRedirect($listing->{manufacturerUrl}); - } else { + } + else { $self->session->http->setRedirect($listing->{productUrl}); } - return ""; + return undef; } diff --git a/lib/WebGUI/Asset/Wobject/Navigation.pm b/lib/WebGUI/Asset/Wobject/Navigation.pm index b0b6ba8f2..2e6902fdc 100644 --- a/lib/WebGUI/Asset/Wobject/Navigation.pm +++ b/lib/WebGUI/Asset/Wobject/Navigation.pm @@ -486,7 +486,7 @@ sub view { sub www_goBackToPage { my $self = shift; $self->session->http->setRedirect($self->session->form->process("returnUrl")) if ($self->session->form->process("returnUrl")); - return ""; + return undef; } diff --git a/lib/WebGUI/Asset/Wobject/WSClient.pm b/lib/WebGUI/Asset/Wobject/WSClient.pm index 90643b94c..58e836617 100644 --- a/lib/WebGUI/Asset/Wobject/WSClient.pm +++ b/lib/WebGUI/Asset/Wobject/WSClient.pm @@ -509,6 +509,7 @@ sub view { # webgui flow. This feature currently requires a patched WebGUI.pm file. if ($self->session->form->process('redirectURL')) { $self->session->http->setRedirect($self->session->form->process('redirectURL')); + return undef; } $var{'results'} = \@result; diff --git a/lib/WebGUI/Asset/_NewAsset.skeleton b/lib/WebGUI/Asset/_NewAsset.skeleton index d25b164fd..0fb862628 100644 --- a/lib/WebGUI/Asset/_NewAsset.skeleton +++ b/lib/WebGUI/Asset/_NewAsset.skeleton @@ -259,7 +259,7 @@ sub www_view { return $self->getContainer->www_view; } $self->session->http->setRedirect($self->getFileUrl($self->getValue("showPage"))); - return ""; + return undef; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index f183b468a..f54c5607e 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -311,6 +311,7 @@ sub www_editBranchSave { WebGUI::VersionTag->getWorking($self->session)->requestCommit; } else { $self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)); + return undef; } } delete $self->{_parent}; diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 1ec31eaad..ccb4c8329 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -214,7 +214,7 @@ sub www_copy { $self->session->http->setRedirect($self->getUrl( "op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId )); - return 1; + return undef; } } return $self->session->asset($self->getContainer)->www_view; diff --git a/lib/WebGUI/AssetPackage.pm b/lib/WebGUI/AssetPackage.pm index 9ee86562a..e65250f88 100644 --- a/lib/WebGUI/AssetPackage.pm +++ b/lib/WebGUI/AssetPackage.pm @@ -239,6 +239,7 @@ sub importPackage { } else { $self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)); + return undef; } } diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index 548b736ff..1ddc10bf0 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -551,7 +551,7 @@ sub www_purgeRevision { if ($session->form->process("proceed") eq "manageRevisionsInTag") { my $working = (defined $self) ? $self : $parent; $session->http->setRedirect($working->getUrl("op=manageRevisionsInTag")); - return ""; + return undef; } unless (defined $self) { return $parent->www_view; diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 2b6b8cc58..903aab9a3 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -286,6 +286,7 @@ sub createAccountSave { if ($self->session->scratch->get("redirectAfterLogin")) { my $url = $self->session->scratch->delete("redirectAfterLogin"); $self->session->http->setRedirect($url); + return undef; } else { $self->session->http->setStatus(201,"Account Registration Successful"); } diff --git a/lib/WebGUI/Content/Asset.pm b/lib/WebGUI/Content/Asset.pm index 14b920736..190ded65b 100644 --- a/lib/WebGUI/Content/Asset.pm +++ b/lib/WebGUI/Content/Asset.pm @@ -115,7 +115,7 @@ sub handler { $http->setStatus("304","Content Not Modified"); $http->sendHeader; $session->close; - return "cached"; + return "chunked"; } # return the page. @@ -137,13 +137,6 @@ sub handler { } } - # Uhm... why here and not somewhere else? Do content handlers manage their own content - # or should the URL handlers do it for them? - if ($output eq "redirect") { - $http->sendHeader; - } - - # ... return $output; } diff --git a/lib/WebGUI/Content/Prefetch.pm b/lib/WebGUI/Content/Prefetch.pm index 60d51caf7..39ad08719 100644 --- a/lib/WebGUI/Content/Prefetch.pm +++ b/lib/WebGUI/Content/Prefetch.pm @@ -47,10 +47,7 @@ The content handler for this package. sub handler { my ($session) = @_; if ($session->env->get("HTTP_X_MOZ") eq "prefetch") { # browser prefetch is a bad thing - my $http = $session->http; - $http->setStatus("403","We don't allow prefetch, because it increases bandwidth, hurts stats, and can break web sites."); - $http->sendHeader; - return "none"; + $session->http->setStatus("403","We don't allow prefetch, because it increases bandwidth, hurts stats, and can break web sites."); } return undef; } diff --git a/lib/WebGUI/Content/Setup.pm b/lib/WebGUI/Content/Setup.pm index 8039c4d8c..afc285c37 100644 --- a/lib/WebGUI/Content/Setup.pm +++ b/lib/WebGUI/Content/Setup.pm @@ -560,7 +560,6 @@ return props[propName]; '; $session->http->setMimeType("text/html"); - $session->http->sendHeader; return $page; } diff --git a/lib/WebGUI/Form/HTMLArea.pm b/lib/WebGUI/Form/HTMLArea.pm index bf828bd8b..c975a9d35 100644 --- a/lib/WebGUI/Form/HTMLArea.pm +++ b/lib/WebGUI/Form/HTMLArea.pm @@ -459,7 +459,7 @@ sub www_addFolderSave { #filename => $filename, }); $session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLForm;sub=imageTree')); - return ""; + return undef; } #------------------------------------------------------------------- @@ -544,7 +544,7 @@ sub www_addImageSave { } $session->http->setRedirect($base->getUrl('op=formHelper;class=HTMLArea;sub=imageTree')); $imageObj->delete; - return ""; + return undef; } diff --git a/lib/WebGUI/Operation/AdSpace.pm b/lib/WebGUI/Operation/AdSpace.pm index e2507e295..045d3e329 100644 --- a/lib/WebGUI/Operation/AdSpace.pm +++ b/lib/WebGUI/Operation/AdSpace.pm @@ -57,7 +57,7 @@ sub www_clickAd { return undef unless $id; my $url = WebGUI::AdSpace->countClick($session, $id); $session->http->setRedirect($url); - return "Redirecting to $url"; + return undef; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm index cf2a72d57..4463ac071 100644 --- a/lib/WebGUI/Operation/Commerce.pm +++ b/lib/WebGUI/Operation/Commerce.pm @@ -438,7 +438,7 @@ sub www_checkoutSubmit { # Check if shoppingcart contains any items. If not the user probably clicked reload, so we redirect to the current page. unless (@$normal || @$recurring) { $session->http->setRedirect($session->url->page); - return ''; + return undef; } # check submitted form params diff --git a/lib/WebGUI/Operation/FormHelpers.pm b/lib/WebGUI/Operation/FormHelpers.pm index cc7cf6b9f..05f7949d1 100644 --- a/lib/WebGUI/Operation/FormHelpers.pm +++ b/lib/WebGUI/Operation/FormHelpers.pm @@ -57,480 +57,5 @@ sub www_formHelper { } -#------------------------------------------------------------------- - -=head2 www_formAssetTree ( session ) - -B This function is depricated and will be removed in a future release. - -Returns a list of the all the current Asset's children as form. The children can be filtered via the -form variable C. A crumb trail is provided for navigation. - -=cut - -sub www_formAssetTree { - my $session = shift; - $session->http->setCacheControl("none"); - my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session); - my @crumb; - my $ancestors = $base->getLineage(["self","ancestors"],{returnObjects=>1}); - foreach my $ancestor (@{$ancestors}) { - my $url = $ancestor->getUrl("op=formAssetTree;formId=".$session->form->process("formId")); - $url .= ";classLimiter=".$session->form->process("classLimiter","className") if ($session->form->process("classLimiter","className")); - push(@crumb,''.$ancestor->get("menuTitle").''); - } - my $output = ' - - - - -
-
'.join(" > ", @crumb)."

\n"; - my $children = $base->getLineage(["children","self"],{returnObjects=>1}); - my $i18n = WebGUI::International->new($session); - my $limit = $session->form->process("classLimiter","className"); - foreach my $child (@{$children}) { - next unless $child->canView; - if ($limit eq "" || $child->get("className") =~ /^$limit/) { - $output .= 'getId.'\';window.opener.document.getElementById(\''. - $session->form->process("formId").'_display\').value=\''.$child->get("title").'\';window.close();">['.$i18n->get("select").'] '; - } else { - $output .= '['.$i18n->get("select").'] '; - } - my $url = $child->getUrl("op=formAssetTree;formId=".$session->form->process("formId")); - $url .= ";classLimiter=".$session->form->process("classLimiter","className") if ($session->form->process("classLimiter","className")); - $output .= ''.$child->get("menuTitle").''."
\n"; - } - $output .= '
'; - $session->style->useEmptyStyle("1"); - return $output; -} - -#------------------------------------------------------------------- - -=head2 www_richEditPageTree ( session ) - -B This function is depricated and will be removed in a future release. - -Asset picker for the rich editor. - -=cut - -sub www_richEditPageTree { - my $session = shift; - $session->http->setCacheControl("none"); - $session->style->setRawHeadTags(q| - |); - $session->style->setScript($session->url->extras('tinymce2/jscripts/tiny_mce/tiny_mce_popup.js'),{type=>"text/javascript"}); - my $i18n = WebGUI::International->new($session); - my $f = WebGUI::HTMLForm->new($session,-action=>"#"); - $f->text( - -name=>"url", - -label=>$i18n->get(104), - -hoverHelp=>$i18n->get('104 description'), - ); - my %options = (); - tie %options, 'Tie::IxHash'; - %options = ("_self"=>$i18n->get('link in same window'), - "_blank"=>$i18n->get('link in new window')); - $f->selectBox( - -name=>"target", - -label=>$i18n->get('target'), - -hoverHelp=>$i18n->get('target description'), - -options=>\%options - ); - $f->button( - -name=>"button", - -value=>$i18n->get('done'), - -extras=>'onclick="createLink()"' - ); - my $output = '
'.$i18n->get('insert a link').''.$f->print.'
'.<<"JS" - -JS - .'
'.$i18n->get('pages').' '; - $output .= '
'; - my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session); - my @crumb; - my $ancestors = $base->getLineage(["self","ancestors"],{returnObjects=>1}); - foreach my $ancestor (@{$ancestors}) { - push(@crumb,''.$ancestor->get("menuTitle").''); - } - $output .= '
'.join(" > ", @crumb)."

\n"; - my $children = $base->getLineage(["children"],{returnObjects=>1}); - foreach my $child (@{$children}) { - next unless $child->canView; - $output .= '['.$i18n->get("select").'] '.$child->get("menuTitle").''."
\n"; - } - $output .= '
'; - return $session->style->process($output, 'PBtmpl0000000000000137'); -} - -#------------------------------------------------------------------- - -=head2 www_richEditImageTree ( session ) - -B This function is depricated and will be removed in a future release. - -Similar to www_formAssetTree, except it is limited to only display assets of class WebGUI::Asset::File::Image. -Each link display a thumbnail of the image via www_richEditViewThumbnail. - -=cut - -sub www_richEditImageTree { - my $session = shift; - $session->http->setCacheControl("none"); - $session->style->setRawHeadTags(q| |); - my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getMedia($session); - my @crumb; - my $ancestors = $base->getLineage(["self","ancestors"],{returnObjects=>1}); - my $media; - my @output; - push(@output, '
'); - my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers'); - foreach my $ancestor (@{$ancestors}) { - push(@crumb,''.$ancestor->get("menuTitle").''); - # check if we are in (a subdirectory of) Media - if ($ancestor->get('assetId') eq 'PBasset000000000000003') { - $media = $ancestor; - } - } - if ($media) { - # if in (a subdirectory of) Media, give user the ability to create folders or upload images - push(@output, '

[ '.$i18n->get('Create new folder').' ]   [ '.$i18n->get('Upload new image').' ]

'); - } else { - $media = WebGUI::Asset->getMedia($session); - # if not in Media, provide a direct link to it - push(@output, '

[ '.$media->get('title').' ]

'); - } - push(@output, '
'.join(" > ", @crumb)."

\n"); - my $children = $base->getLineage(["children"],{returnObjects=>1}); - foreach my $child (@{$children}) { - next unless $child->canView; - if ($child->get("className") =~ /^WebGUI::Asset::File::Image/) { - push(@output, '['.$i18n->get("select","WebGUI").'] '); - } else { - push(@output, ' ['.$i18n->get("select","WebGUI")."] "); - } - push(@output, ''.$child->get("menuTitle").''."
\n"); - } - push(@output, '
'); - return $session->style->process(join('', @output), 'PBtmpl0000000000000137'); -} - -#------------------------------------------------------------------- - -=head2 www_richEditViewThumbnail ( session ) - -B This function is depricated and will be removed in a future release. - -Displays a thumbnail of an Image Asset in the Image manager for the Rich Editor. The current -URL in the session object is used to determine which Image is used. - -=cut - -sub www_richEditViewThumbnail { - my $session = shift; - $session->http->setCacheControl("none"); - my $image = WebGUI::Asset->newByUrl($session); - my $i18n = WebGUI::International->new($session); - my $output; - if ($image->get("className") =~ /WebGUI::Asset::File::Image/) { - $output = '
'; - $output .= ''.$i18n->get('preview').''; - $output .= '
'; - $output .= $image->get("filename"); - $output .= '
'; - $output .= '\n"; - } else { - $output = '
'.$i18n->get('image manager').'
'; - } - return $session->style->process($output, 'PBtmpl0000000000000137'); -} - -#------------------------------------------------------------------- - -=head2 www_richEditAddFolder ( session ) - -B This function is depricated and will be removed in a future release. - -Returns a form to add a folder using the rich editor. The purpose of this feature is to provide a very simple way for end-users to create a folder from within the rich editor, in stead of having to leave the rich editor and use the asset manager. A very minimal set of options is supplied, all other options should be derived from the current asset. - -=cut - -sub www_richEditAddFolder { - my $session = shift; - $session->http->setCacheControl("none"); - my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers'); - my $f = WebGUI::HTMLForm->new($session); - $f->hidden( - name => 'op', - value => 'richEditAddFolderSave', - ); - $f->text( - label => $i18n->get('Folder name'), - name => 'filename', - ); - $f->submit( - value => $i18n->get('Create'), - ); - $f->button( - value => $i18n->get('Cancel'), - extras => 'onclick="history.go(-1);"', - ); - my $html = '

'.$i18n->get('Create new folder').'

'.$f->print; - return $session->style->process($html, 'PBtmpl0000000000000137'); -} - -#------------------------------------------------------------------- - -=head2 www_richEditAddFolderSave ( session ) - -B This function is depricated and will be removed in a future release. - -Creates a directory under the current asset. The filename should be specified in the form. The Edit and View rights from the current asset are used if not specified in the form. All other properties are copied from the current asset. - -=cut - -sub www_richEditAddFolderSave { - my $session = shift; - $session->http->setCacheControl("none"); - # get base url - my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session); - # check if user can edit the current asset - return $session->privilege->insufficient('bare') unless $base->canEdit; - - my $filename = $session->form->process('filename') || 'untitled'; - $base->addChild({ - # Asset properties - title => $filename, - menuTitle => $filename, - url => $base->getUrl.'/'.$filename, - groupIdEdit => $session->form->process('groupIdEdit') || $base->get('groupIdEdit'), - groupIdView => $session->form->process('groupIdView') || $base->get('groupIdView'), - ownerUserId => $session->user->userId, - startDate => $base->get('startDate'), - endDate => $base->get('endDate'), - encryptPage => $base->get('encryptPage'), - isHidden => 1, - newWindow => 0, - - # Asset/Wobject properties - displayTitle => 1, - cacheTimeout => $base->get('cacheTimeout'), - cacheTimeoutVisitor => $base->get('cacheTimeoutVisitor'), - styleTemplateId => $base->get('styleTemplateId'), - printableStyleTemplateId => $base->get('printableStyleTemplateId'), - - # Asset/Wobject/Folder properties - templateId => 'PBtmpl0000000000000078', - - # Other properties - #assetId => 'new', - className => 'WebGUI::Asset::Wobject::Folder', - #filename => $filename, - }); - $session->http->setRedirect($base->getUrl('op=richEditImageTree')); - return ""; -} - -#------------------------------------------------------------------- - -=head2 www_richEditAddImage ( session ) - -B This function is depricated and will be removed in a future release. - -Returns a form to add an image using the rich editor. The purpose of this feature is to provide a very simple way for end-users to upload new images from within the rich editor, in stead of having to leave the rich editor and use the asset manager. A very minimal set of options is supplied, all other options should be derived from the current asset. - -=cut - -sub www_richEditAddImage { - my $session = shift; - $session->http->setCacheControl("none"); - my $i18n = WebGUI::International->new($session, 'Operation_FormHelpers'); - my $f = WebGUI::HTMLForm->new($session); - $f->hidden( - name => 'op', - value => 'richEditAddImageSave', - ); - $f->image( - label => $i18n->get('File'), - name => 'filename', - size => 10, - ); - $f->submit( - value => $i18n->get('Upload'), - ); - $f->button( - value => $i18n->get('Cancel'), - extras => 'onclick="history.go(-1);"', - ); - my $html = '

'.$i18n->get('Upload new image').'

'.$f->print; - return $session->style->process($html, 'PBtmpl0000000000000137'); -} - -#------------------------------------------------------------------- - -=head2 www_richEditAddImageSave ( session ) - -B This function is depricated and will be removed in a future release. - -Creates an Image asset under the current asset. The filename should be specified in the form. The Edit and View rights from the current asset are used if not specified in the form. All other properties are copied from the current asset. - -=cut - -sub www_richEditAddImageSave { - my $session = shift; - $session->http->setCacheControl("none"); - # get base url - my $base = WebGUI::Asset->newByUrl($session) || WebGUI::Asset->getRoot($session); - #my $base = $session->asset; - my $url = $base->getUrl; - # check if user can edit the current asset - return $session->privilege->insufficient('bare') unless $base->canEdit; - - #my $imageId = WebGUI::Form::Image->create($session); - my $imageId = WebGUI::Form::Image->new($session,{name => 'filename'})->getValueFromPost; - my $imageObj = WebGUI::Storage::Image->get($session, $imageId); - ##This is a hack. It should use the WebGUI::Form::File API to insulate - ##us from future form name changes. - my $filename = $imageObj->getFiles->[0]; - if ($filename) { - $base->addChild({ - assetId => 'new', - className => 'WebGUI::Asset::File::Image', - storageId => $imageObj->getId, - filename => $filename, - title => $filename, - menuTitle => $filename, - templateId => 'PBtmpl0000000000000088', - url => $url.'/'.$filename, - groupIdEdit => $session->form->process('groupIdEdit') || $base->get('groupIdEdit'), - groupIdView => $session->form->process('groupIdView') || $base->get('groupIdView'), - ownerUserId => $session->var->get('userId'), - isHidden => 1, - }); - } - $session->http->setRedirect($url.'?op=richEditImageTree'); - $imageObj->delete; - return ""; -} - - 1; diff --git a/lib/WebGUI/Operation/LDAPLink.pm b/lib/WebGUI/Operation/LDAPLink.pm index 30ae6134a..9310a37b3 100644 --- a/lib/WebGUI/Operation/LDAPLink.pm +++ b/lib/WebGUI/Operation/LDAPLink.pm @@ -337,6 +337,7 @@ sub www_editLDAPLinkSave { $session->db->setRow("ldapLink","ldapLinkId",$properties); if($session->form->process("returnUrl")) { $session->http->setRedirect($session->form->process("returnUrl")); + return undef; } return www_listLDAPLinks($session); } diff --git a/lib/WebGUI/Operation/Subscription.pm b/lib/WebGUI/Operation/Subscription.pm index 7db00fe2d..af966688a 100644 --- a/lib/WebGUI/Operation/Subscription.pm +++ b/lib/WebGUI/Operation/Subscription.pm @@ -604,8 +604,8 @@ The current WebGUI session object. sub www_purchaseSubscription { my $session = shift; WebGUI::Commerce::ShoppingCart->new($session)->add($session->form->process("sid"), 'Subscription'); - - return $session->http->setRedirect($session->url->page('op=checkout')); + $session->http->setRedirect($session->url->page('op=checkout')); + return undef; } =head2 www_redeemSubscriptionCode ( $session ) diff --git a/lib/WebGUI/URL/Content.pm b/lib/WebGUI/URL/Content.pm index fad8d911f..a98fbc624 100644 --- a/lib/WebGUI/URL/Content.pm +++ b/lib/WebGUI/URL/Content.pm @@ -57,21 +57,21 @@ sub handler { $session->errorHandler->error($@); } else { - if ($output) { - if ($output eq "cached") { - return Apache2::Const::OK; - } - unless ($output eq "none" || $output eq "redirect") { - unless ($output eq "chunked") { - $session->http->sendHeader(); - $session->output->print($output) - } - if ($session->errorHandler->canShowDebug()) { - $session->output->print($session->errorHandler->showDebug(),1); - } + if ($output eq "chunked") { + last; + } + elsif (defined $output && $output ne "") { + $session->http->sendHeader; + $session->output->print($output); + if ($session->errorHandler->canShowDebug()) { + $session->output->print($session->errorHandler->showDebug(),1); } last; } + elsif ($session->http->getStatus ne "200") { + $session->http->sendHeader; + last; + } } } WebGUI::Affiliate::grabReferral($session); # process affiliate tracking request