From 92815bb75d7dd5e47250bc17ef36a4302a31e75b Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 14 Aug 2009 19:43:14 +0000 Subject: [PATCH] Change www_delete and www_cut to use either the container, or the parent as the asset to return the user to after their actions. Subclass getContainer in the Story, and alias it to getArchive. Fixes bug 10657. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Story.pm | 9 +++++++++ lib/WebGUI/AssetClipboard.pm | 13 ++++++++++--- lib/WebGUI/AssetTrash.pm | 11 ++++++++--- t/Asset/Story.t | 10 +++++++++- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4626f7588..bc159af72 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -2,6 +2,7 @@ - fixed #10776: i18n AuthLDAP::7 description - fixed #10775: i18n AuthLDAP::6 description - fixed #10774: i18n Asset::Storyarchive tag asset url + - fixed #10657: Story Topic: delete story displays failsafe 7.7.17 - fixed #10697: Story: Image crowds text diff --git a/lib/WebGUI/Asset/Story.pm b/lib/WebGUI/Asset/Story.pm index 2679eb28b..8f38f9151 100644 --- a/lib/WebGUI/Asset/Story.pm +++ b/lib/WebGUI/Asset/Story.pm @@ -311,6 +311,15 @@ sub getAutoCommitWorkflowId { return undef; } +#------------------------------------------------------------------- + +=head2 getContainer ( ) + +Returns the archive for this story, instead of the folder. + +=cut + +BEGIN { *getContainer = *getArchive } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 05fdc13a8..4819f6ffd 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -336,7 +336,8 @@ sub www_createShortcut { =head2 www_cut ( ) -Cuts (removes to clipboard) self, returns the www_view of the Parent if canEdit. Otherwise returns AdminConsole rendered insufficient privilege. +If the current user canEdit, it puts $self into the clipboard and calls www_view on it's container. +Otherwise returns AdminConsole rendered insufficient privilege. =cut @@ -346,8 +347,14 @@ sub www_cut { return $self->session->privilege->vitalComponent if $self->get('isSystem'); $self->cut; - $self->session->asset($self->getParent); - return $self->getParent->www_view; + my $asset = $self->getContainer; + if ($self->getId eq $asset->getId) { + $asset = $self->getParent; + } + $self->session->asset($asset); + return $asset->www_view; + + } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm index a8fd9baef..d7860f737 100644 --- a/lib/WebGUI/AssetTrash.pm +++ b/lib/WebGUI/AssetTrash.pm @@ -303,7 +303,8 @@ sub _invokeWorkflowOnExportedFiles { =head2 www_delete -Moves self to trash, returns www_view() method of Parent if canEdit. Otherwise returns AdminConsole rendered insufficient privilege. +Moves self to trash, returns www_view() method of Container or Parent if canEdit. +Otherwise returns AdminConsole rendered insufficient privilege. =cut @@ -313,8 +314,12 @@ sub www_delete { return $self->session->privilege->vitalComponent() if $self->get('isSystem'); return $self->session->privilege->vitalComponent() if (isIn($self->getId, $self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage"))); $self->trash; - $self->session->asset($self->getParent); - return $self->getParent->www_view; + my $asset = $self->getContainer; + if ($self->getId eq $asset->getId) { + $asset = $self->getParent; + } + $self->session->asset($asset); + return $asset->www_view; } #------------------------------------------------------------------- diff --git a/t/Asset/Story.t b/t/Asset/Story.t index a24745c7d..bec081e02 100644 --- a/t/Asset/Story.t +++ b/t/Asset/Story.t @@ -81,7 +81,7 @@ WebGUI::Test->storagesToDelete($storage1, $storage2); # ############################################################ -my $tests = 44; +my $tests = 45; plan tests => 1 + $tests + $canEditMaker->plan @@ -148,6 +148,14 @@ $story->requestAutoCommit; is($story->getArchive->getId, $archive->getId, 'getArchive gets the parent archive for the Story'); +############################################################ +# +# getContainer +# +############################################################ + +is($story->getContainer->getId, $archive->getId, 'getContainer gets the parent archive for the Story'); + ############################################################ # # canEdit