From bca9af757d586e8984e57cf1bbb7940800236550 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 2 May 2007 21:18:29 +0000 Subject: [PATCH] Incomplete Form data on Asset Edit causes asset to be unaccessible --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset.pm | 68 ++++++++++++++++++++++++++----------- lib/WebGUI/Asset/Wobject.pm | 2 ++ 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 6410632bc..db63fb0dd 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,7 @@ - fix: Email to forum not working from Mac - fix: Unable to set size in DynamicField (Diona Kidd / Knowmad) - fix: race condition causes upgrade.pl to fail (Martin Kamerbeek / Oqapi) + - fix: Incomplete Form data on Asset Edit causes asset to be unaccessible - fix: Calendar Events Disappearing http://www.plainblack.com/bugs/tracker/calendar-events-disappearing - fix: Modified SQLForm.pm to handle MySQL null dates. Undefs them. Undef dates default to time(), i.e. today's date diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index f01f145ac..391d1abf0 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -276,6 +276,7 @@ sub definition { hoverHelp=>$i18n->get('108 description'), uiLevel=>6, fieldType=>'user', + filter=>'fixId', defaultValue=>'3' }, groupIdView=>{ @@ -284,6 +285,7 @@ sub definition { hoverHelp=>$i18n->get('872 description'), uiLevel=>6, fieldType=>'group', + filter=>'fixId', defaultValue=>'7' }, groupIdEdit=>{ @@ -293,6 +295,7 @@ sub definition { hoverHelp=>$i18n->get('871 description'), uiLevel=>6, fieldType=>'group', + filter=>'fixId', defaultValue=>'4' }, synopsis=>{ @@ -370,6 +373,51 @@ sub DESTROY { } +#------------------------------------------------------------------- + +=head2 fixId ( id, fieldName ) + +Returns the default Id for a field if we get an invalid Id, otherwise returns the id passed in. An valid id either looks like a GUID or is an integer. + +=head3 id + +The id to check. + +=head3 fieldName + +The name of the property we're checking. This is used to retrieve whatever the default is set to in the definition. + +=cut + +sub fixId { + my $self = shift; + my $id = shift; + my $field = shift; + if ($id =~ m/\Ad+\Z/xms || $id =~ m/\A[A-Za-z0-9\-\_]{22}\Z/xms) { + return $id; + } + return $self->getValue($field); +} + + +#------------------------------------------------------------------- + +=head2 fixTitle ( string ) + +Fixes a title by eliminating HTML from it. + +=head3 string + +Any text string. Most likely will have been the Asset's name or title. + +=cut + +sub fixTitle { + my $self = shift; + return WebGUI::HTML::filter(shift || $self->getValue("title") || 'Untitled', 'all'); +} + + #------------------------------------------------------------------- =head2 fixUrl ( string ) @@ -441,24 +489,6 @@ sub fixUrl { } -#------------------------------------------------------------------- - -=head2 fixTitle ( string ) - -Fixes a title by eliminating HTML from it. - -=head3 string - -Any text string. Most likely will have been the Asset's name or title. - -=cut - -sub fixTitle { - my $self = shift; - return WebGUI::HTML::filter(shift || $self->getValue("title") || 'Untitled', 'all'); -} - - #------------------------------------------------------------------- =head2 get ( [propertyName] ) @@ -1870,7 +1900,7 @@ sub update { my $value = $properties->{$property}; if (exists $definition->{properties}{$property}{filter}) { my $filter = $definition->{properties}{$property}{filter}; - $value = $self->$filter($value); + $value = $self->$filter($value, $property); } $self->{_properties}{$property} = $value; push(@setPairs, $property."=".$self->session->db->quote($value)); diff --git a/lib/WebGUI/Asset/Wobject.pm b/lib/WebGUI/Asset/Wobject.pm index 7626b547a..4b9cd3ec0 100644 --- a/lib/WebGUI/Asset/Wobject.pm +++ b/lib/WebGUI/Asset/Wobject.pm @@ -88,6 +88,7 @@ sub definition { tab=>"display", label=>$i18n->get(1073), hoverHelp=>$i18n->get('1073 description'), + filter=>'fixId', namespace=>'style' }, printableStyleTemplateId=>{ @@ -96,6 +97,7 @@ sub definition { tab=>"display", label=>$i18n->get(1079), hoverHelp=>$i18n->get('1079 description'), + filter=>'fixId', namespace=>'style' } );