From 7b6ea1350fcf5264031e4e709373da1a8cf223b0 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 23 Mar 2009 05:11:01 +0000 Subject: [PATCH] Code to delete photos and their data. --- lib/WebGUI/Asset/Story.pm | 11 +++++++++-- t/Asset/Wobject/StoryTopic.t | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/WebGUI/Asset/Story.pm b/lib/WebGUI/Asset/Story.pm index a65802d07..9a514a0f2 100644 --- a/lib/WebGUI/Asset/Story.pm +++ b/lib/WebGUI/Asset/Story.pm @@ -501,10 +501,17 @@ sub processPropertiesFromFormPost { my $photoData = $self->getPhotoData; my $numberOfPhotos = scalar @{ $photoData }; ##Post process photo data here. - foreach my $photoIndex (1..$numberOfPhotos) { + PHOTO: foreach my $photoIndex (1..$numberOfPhotos) { ##TODO: Deletion check and storage cleanup + my $storageId = $photoData->[$photoIndex-1]->{storageId}; + if ($form->process('deletePhoto'.$photoIndex)) { + my $storage = WebGUI::Storage->get($session, $storageId); + $storage->delete if $storage; + splice @{ $photoData }, $photoIndex-1, 1; + next PHOTO; + } my $newPhoto = { - storageId => $form->process('photo' .$photoIndex, 'image', $photoData->[$photoIndex-1]->{storageId}), + storageId => $form->process('photo' .$photoIndex, 'image', ), caption => $form->process('imgCaption'.$photoIndex, 'text'), alt => $form->process('imgAlt' .$photoIndex, 'text'), title => $form->process('imgTitle' .$photoIndex, 'text'), diff --git a/t/Asset/Wobject/StoryTopic.t b/t/Asset/Wobject/StoryTopic.t index 342c97ddc..b21499917 100644 --- a/t/Asset/Wobject/StoryTopic.t +++ b/t/Asset/Wobject/StoryTopic.t @@ -191,9 +191,9 @@ cmp_deeply( #---------------------------------------------------------------------------- # Cleanup END { - $archive->purge if $archive; - $topic->purge if $topic; - if ($versionTag) { - $versionTag->rollback; - } +# $archive->purge if $archive; +# $topic->purge if $topic; +# if ($versionTag) { +# $versionTag->rollback; +# } }