From 95ea885cdc0303ff91e8eba23c88c148e9890d4d Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Mon, 15 Sep 2008 21:51:26 +0000 Subject: [PATCH] fixed: AssetProxy allows proxying content in the trash or clipboard --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Macro/AssetProxy.pm | 51 +++++++++++++-------- lib/WebGUI/i18n/English/Macro_AssetProxy.pm | 12 ++++- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6d0745645..6b57933cf 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.6.0 - Made the charset metatag the highest thing in the head block. + - fixed: AssetProxy allows proxying content in the trash or clipboard - fixed: Textarea resizer has a gap between textbox and resizer initially - added: getLineageIterator method to simplify working on large sets of assets - fixed: Syndicated Content doesn't decode alternate character sets diff --git a/lib/WebGUI/Macro/AssetProxy.pm b/lib/WebGUI/Macro/AssetProxy.pm index 8eb921fdc..ad6ad38df 100644 --- a/lib/WebGUI/Macro/AssetProxy.pm +++ b/lib/WebGUI/Macro/AssetProxy.pm @@ -42,36 +42,47 @@ Defaults to 'url'. But if you want to use an assetId as the first parameter, the #------------------------------------------------------------------- sub process { my ($session, $identifier, $type) = @_; - my $t = ($session->errorHandler->canShowPerformanceIndicators()) ? [Time::HiRes::gettimeofday()] : undef; - my $asset; + my $t = ($session->errorHandler->canShowPerformanceIndicators()) ? [Time::HiRes::gettimeofday()] : undef; + my $asset; if ($type eq 'assetId') { $asset = WebGUI::Asset->newByDynamicClass($session, $identifier); } else { $asset = WebGUI::Asset->newByUrl($session,$identifier); } - #Sorry, you cannot proxy the notfound page. - if (defined $asset && $asset->getId ne $session->setting->get("notFoundPage")) { - if ($asset->canView) { - $asset->toggleToolbar; - $asset->prepareView; - my $output = $asset->view; - $output .= "AssetProxy:".Time::HiRes::tv_interval($t) if ($session->errorHandler->canShowPerformanceIndicators()); - return $output; - } - return undef; - } - else { + if (!defined $asset) { $session->errorHandler->warn('AssetProxy macro called invalid asset: '.$identifier .'. The macro was called through this url: '.$session->asset->get('url')); - if ($session->var->get("adminOn")){ - my $i18n = WebGUI::International->new($session, 'Macro_AssetProxy'); - return $i18n->get('invalid url'); + if ($session->var->isAdminOn) { + my $i18n = WebGUI::International->new($session, 'Macro_AssetProxy'); + return $i18n->get('invalid url'); } - else{ - return ''; + } + elsif ($asset->get('state') =~ /^trash/) { + $session->errorHandler->warn('AssetProxy macro called on asset in trash: '.$identifier + .'. The macro was called through this url: '.$session->asset->get('url')); + if ($session->var->isAdminOn) { + my $i18n = WebGUI::International->new($session, 'Macro_AssetProxy'); + return $i18n->get('asset in trash'); } - } + } + elsif ($asset->get('state') =~ /^clipboard/) { + $session->errorHandler->warn('AssetProxy macro called on asset in clipboard: '.$identifier + .'. The macro was called through this url: '.$session->asset->get('url')); + if ($session->var->isAdminOn) { + my $i18n = WebGUI::International->new($session, 'Macro_AssetProxy'); + return $i18n->get('asset in clipboard'); + } + } + elsif ($asset->canView) { + $asset->toggleToolbar; + $asset->prepareView; + my $output = $asset->view; + $output .= "AssetProxy:" . Time::HiRes::tv_interval($t) + if $t; + return $output; + } + return ''; } diff --git a/lib/WebGUI/i18n/English/Macro_AssetProxy.pm b/lib/WebGUI/i18n/English/Macro_AssetProxy.pm index 0e06b192f..2b2761d91 100644 --- a/lib/WebGUI/i18n/English/Macro_AssetProxy.pm +++ b/lib/WebGUI/i18n/English/Macro_AssetProxy.pm @@ -4,8 +4,16 @@ use strict; our $I18N = { 'invalid url' => { - message => q|Invalid Asset URL|, - lastUpdated => 1134769012, + message => q|AssetProxy: Invalid Asset URL|, + lastUpdated => 1221160383, + }, + + 'asset in trash' => { + message => q|AssetProxy: Asset in trash|, + }, + + 'asset in clipboard' => { + message => q|AssetProxy: Asset in clipboard|, }, };