From ab6d0d2ce69f4f7e13b0e9bce449e1b0955b6fa4 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 16 Feb 2007 22:31:53 +0000 Subject: [PATCH] fix for file uploading problems in File, Image, FilePile, Graphics (font) and FormHelper --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/File.pm | 6 +++++- lib/WebGUI/Asset/FilePile.pm | 5 ++++- lib/WebGUI/Asset/Wobject/Matrix.pm | 6 +++++- lib/WebGUI/AssetPackage.pm | 6 +++++- lib/WebGUI/Operation/FormHelpers.pm | 4 +++- lib/WebGUI/Operation/Graphics.pm | 6 +++++- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 659529cbf..1c8e7fe23 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -14,6 +14,7 @@ - fix: Calendars created with the 7.2.3-7.3.0 upgrade now have the same URL as the Events Calendars they replace. - fix: Events are created with no group information. + - fix: Can't add files with File Pile (perlDreamer Consulting, LLC) 7.3.9 - fix: SQL Form and big table imports diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 3c9664c35..8ea183d7a 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -247,7 +247,11 @@ sub processPropertiesFromFormPost { $self->SUPER::processPropertiesFromFormPost; delete $self->{_storageLocation}; my $storage = $self->getStorageLocation; - my $filename = $storage->addFileFromFormPost("file",1); + + ##The file form element adds a _file to each input name. + ##This thing should really try to use the whole Form API, but that's a major + ##change to this Asset + my $filename = $storage->addFileFromFormPost("file_file",1); $storage->setPrivileges($self->get('ownerUserId'), $self->get('groupIdView'), $self->get('groupIdEdit')); if (defined $filename && $filename ne $self->get("filename")) { my %data; diff --git a/lib/WebGUI/Asset/FilePile.pm b/lib/WebGUI/Asset/FilePile.pm index 3fbd8fb72..2c2214a49 100644 --- a/lib/WebGUI/Asset/FilePile.pm +++ b/lib/WebGUI/Asset/FilePile.pm @@ -137,7 +137,10 @@ sub edit { sub editSave { my $self = shift; my $tempStorage = WebGUI::Storage->create($self->session); - $tempStorage->addFileFromFormPost("file"); + + ##This is a hack. File uploads should go through the WebGUI::Form::File API + $tempStorage->addFileFromFormPost("file_file"); + foreach my $filename (@{$tempStorage->getFiles}) { my $storage = WebGUI::Storage::Image->create($self->session); $storage->addFileFromFilesystem($tempStorage->getPath($filename)); diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index fb7eddaed..3fec087c4 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -697,7 +697,11 @@ sub www_editListingSave { $storage = WebGUI::Storage::Image->create($self->session); $data{storageId} = $storage->getId; } - my $screenshot = $storage->addFileFromFormPost("screenshot"); + + ##This is a hack. File upload should go throught the WebGUI::Form::File API + ##so that future changes don't affect us like this + my $screenshot = $storage->addFileFromFormPost("screenshot_file"); + if (defined $screenshot) { $data{filename} = $screenshot; $storage->generateThumbnail($screenshot); diff --git a/lib/WebGUI/AssetPackage.pm b/lib/WebGUI/AssetPackage.pm index 54b686990..c54bd190e 100644 --- a/lib/WebGUI/AssetPackage.pm +++ b/lib/WebGUI/AssetPackage.pm @@ -255,7 +255,11 @@ sub www_importPackage { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit && $self->session->user->isInGroup(4)); my $storage = WebGUI::Storage->createTemp($self->session); - $storage->addFileFromFormPost("packageFile",1); + + ##This is a hack. It should use the WebGUI::Form::File API to insulate + ##us from future form name changes. + $storage->addFileFromFormPost("packageFile_file",1); + my $error = ""; if ($storage->getFileExtension($storage->getFiles->[0]) eq "wgpkg") { $error = $self->importPackage($storage); diff --git a/lib/WebGUI/Operation/FormHelpers.pm b/lib/WebGUI/Operation/FormHelpers.pm index 58505c601..23739eb62 100644 --- a/lib/WebGUI/Operation/FormHelpers.pm +++ b/lib/WebGUI/Operation/FormHelpers.pm @@ -461,7 +461,9 @@ sub www_richEditAddImageSave { return $session->privilege->insufficient('bare') unless $base->canEdit; my $storage = WebGUI::Storage::Image->create($session); - my $filename = $storage->addFileFromFormPost('filename'); + ##This is a hack. It should use the WebGUI::Form::File API to insulate + ##us from future form name changes. + my $filename = $storage->addFileFromFormPost('filename_file'); if ($filename) { $base->addChild({ assetId => 'new', diff --git a/lib/WebGUI/Operation/Graphics.pm b/lib/WebGUI/Operation/Graphics.pm index 7e44f04cc..b47aa9526 100644 --- a/lib/WebGUI/Operation/Graphics.pm +++ b/lib/WebGUI/Operation/Graphics.pm @@ -261,7 +261,11 @@ sub www_editFontSave { if ($session->form->process('fid') eq 'new') { my $storage = WebGUI::Storage->create($session, 'new'); - my $filename = $storage->addFileFromFormPost('fontFile'); + + ##This is a hack. It should use the WebGUI::Form::File API to insulate + ##us from future form name changes. + my $filename = $storage->addFileFromFormPost('fontFile_file'); + if ($filename) { my $font = WebGUI::Image::Font->new($session, 'new'); $font->setName($session->form->process('fontName'));