From 8bcfa301b3086e05a6eb61bbdba4da1c012aff30 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 25 Jun 2009 14:40:22 +0000 Subject: [PATCH] Make the AssetManager use Asset*.pm for cut, copy, paste, rank and duplicate. --- lib/WebGUI/AssetLineage.pm | 37 ++++++++++ lib/WebGUI/Content/AssetManager.pm | 104 ++++++----------------------- 2 files changed, 56 insertions(+), 85 deletions(-) diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index e04853e5e..11eda8bc4 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -1015,6 +1015,43 @@ sub www_setRank { return $self->getParent->www_manageAssets(); } +#------------------------------------------------------------------- + +=head2 www_setRanks ( ) + +Utility method for the AssetManager. Reorders 1 pagefull of assets via rank. + +If the current user cannot edit the current asset, it returns the insufficient privileges page. + +Returns the user to the manage assets screen. + +=cut + +sub www_setRanks { + my $self = shift; + my $session = $self->session; + return $session->privilege->insufficient() unless $session->asset->canEdit; + my $i18n = WebGUI::International->new($session, 'Asset'); + my $pb = WebGUI::ProgressBar->new($session); + my $form = $session->form; + + $pb->start($i18n->get('Set Rank'), $session->url->extras('adminConsole/assets.gif')); + my @assetIds = $form->get( 'assetId' ); + ASSET: for my $assetId ( @assetIds ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + next ASSET unless $asset; + my $rank = $form->get( $assetId . '_rank' ); + next ASSET unless $rank; # There's no such thing as zero + + $asset->setRank( $rank, sub { $pb->update(sprintf $i18n->get(shift), shift); } ); + } + + $pb->finish($session->asset->getManagerUrl); + return "redirect"; + #return $www_manageAssets(); +} + + 1; diff --git a/lib/WebGUI/Content/AssetManager.pm b/lib/WebGUI/Content/AssetManager.pm index 99e58f9cb..0a90f633c 100644 --- a/lib/WebGUI/Content/AssetManager.pm +++ b/lib/WebGUI/Content/AssetManager.pm @@ -334,37 +334,6 @@ sub www_manage { ### Do Action my @assetIds = $session->form->get( 'assetId' ); - if ( $session->form->get( 'action_delete' ) ) { - for my $assetId ( @assetIds ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - next unless $asset; - $asset->trash; - } - } - elsif ( $session->form->get( 'action_cut' ) ) { - for my $assetId ( @assetIds ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - next unless $asset; - $asset->cut; - } - } - elsif ( $session->form->get( 'action_copy' ) ) { - for my $assetId ( @assetIds ) { - # Copy == Duplicate + Cut - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId); - my $newAsset = $asset->duplicate( { skipAutoCommitWorkflows => 1 } ); - $newAsset->update( { title => $newAsset->getTitle . ' (copy)' } ); - $newAsset->cut; - } - } - elsif ( $session->form->get( 'action_duplicate' ) ) { - for my $assetId ( @assetIds ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - next unless $asset; - $asset->duplicate( { skipAutoCommitWorkflows => 1 } ); - } - } - # Handle autocommit workflows if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 1, @@ -428,24 +397,25 @@ ENDHTML $output .= ''; ### The page of assets - $output .= q{
} - . q{
} - . q{} - . q{} - . q{
} - . q{
} - . q{

} . $i18n->get( 'with selected' ) - . q{} - . q{} - . q{} - . q{} - . q{} - . q{

} - . q{
} - . q{} - . q{
} - ; + $output .= sprintf <asset->getUrl, $i18n->get( 'with selected' ), $i18n->get( "update" ), $i18n->get( "delete" ), $i18n->get( '43' ), $i18n->get( 'cut' ), $i18n->get( "Copy" ), $i18n->get( "duplicate" ); +
+
+ + +
+
+

%s + + + + + +

+
+ +
+EOHTML ### Clearing div $output .= q{
 
}; @@ -762,41 +732,5 @@ sub www_search { return $ac->render( $output ); } -#------------------------------------------------------------------- - -=head2 www_setRanks ( ) - -Utility method for the AssetManager. Reorders 1 pagefull of assets via rank. - -If the current user cannot edit the current asset, it returns the insufficient privileges page. - -Returns the user to the manage assets screen. - -=cut - -sub www_setRanks { - my $session = shift; - return $session->privilege->insufficient() unless $session->asset->canEdit; - my $i18n = WebGUI::International->new($session, 'Asset'); - my $pb = WebGUI::ProgressBar->new($session); - my $form = $session->form; - - $pb->start($i18n->get('Set Rank'), $session->url->extras('adminConsole/assets.gif')); - my @assetIds = $form->get( 'assetId' ); - ASSET: for my $assetId ( @assetIds ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - next ASSET unless $asset; - my $rank = $form->get( $assetId . '_rank' ); - next ASSET unless $rank; # There's no such thing as zero - - $asset->setRank( $rank, sub { $pb->update(sprintf $i18n->get(shift), shift); } ); - } - - $pb->finish($session->asset->getManagerUrl); - return "redirect"; - #return $www_manageAssets(); -} - - 1;