From 7191b53e3e5f84da17b6277c20b64dfeceb68075 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 14 Jun 2006 19:28:32 +0000 Subject: [PATCH] fix - fix: shortcut bombs --- docs/changelog/6.x.x.txt | 1 + lib/WebGUI/Asset/Shortcut.pm | 62 +++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 1d5b81753..b6cf82e58 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -53,6 +53,7 @@ - fix: cs mail posts - no url prepending - Multiple "Re:"'s on CS Mail posts are now a thing of the past. - Made mail message ids follow convention. + - fix: shortcut bombs 6.99.3 diff --git a/lib/WebGUI/Asset/Shortcut.pm b/lib/WebGUI/Asset/Shortcut.pm index 0871bb6e1..42ebab72c 100644 --- a/lib/WebGUI/Asset/Shortcut.pm +++ b/lib/WebGUI/Asset/Shortcut.pm @@ -214,11 +214,18 @@ sub getEditForm { my $tabform = $self->SUPER::getEditForm(); my $originalTemplate; my $i18n = WebGUI::International->new($self->session, "Asset_Shortcut"); - $tabform->getTab("properties")->readOnly( - -label=>$i18n->get(1), - -hoverHelp=>$i18n->get('1 description'), - -value=>''.$self->getShortcut->get('title').' ('.$self->getShortcut->getId.')' - ); + my $shortcut = $self->getShortcut; + if (defined $shortcut) { + $tabform->getTab("properties")->readOnly( + -label=>$i18n->get(1), + -hoverHelp=>$i18n->get('1 description'), + -value=>''.$shortcut->get('title').' ('.$shortcut->getId.')' + ); + } else { + $tabform->getTab("properties")->readOnly( + value=>''.$self->notLinked.'' + ); + } $tabform->getTab("display")->template( -value=>$self->getValue("templateId"), -label=>$i18n->get('shortcut template title'), @@ -341,7 +348,9 @@ sub getOverridesList { my %overrides = $self->getOverrides; $output .= ''; $output .= ''; - foreach my $definition (@{$self->getShortcutOriginal->definition($self->session)}) { + my $shortcut = $self->getShortcutOriginal; + return undef unless defined $shortcut; + foreach my $definition (@{$shortcut->definition($self->session)}) { foreach my $prop (keys %{$definition->{properties}}) { next if $definition->{properties}{$prop}{fieldType} eq 'hidden'; $output .= ''; @@ -373,12 +382,14 @@ sub getOverrides { unless ($overridesRef->{cacheNotExpired}) { my %overrides; my $orig = $self->getShortcutOriginal; - unless (exists $orig->{_propertyDefinitions}) { + if (defined $orig) { + unless ( exists $orig->{_propertyDefinitions}) { my %properties; - foreach my $definition (@{$orig->definition($self->session)}) { - %properties = (%properties, %{$definition->{properties}}); + foreach my $definition (@{$orig->definition($self->session)}) { + %properties = (%properties, %{$definition->{properties}}); + } + $orig->{_propertyDefinitions} = \%properties; } - $orig->{_propertyDefinitions} = \%properties; } $overrides{cacheNotExpired} = 1; my $sth = $self->session->db->read("select fieldName, newValue from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." order by fieldName"); @@ -577,6 +588,14 @@ sub isDashlet { #------------------------------------------------------------------- +sub notLinked { + my $self = shift; + $self->session->errorHandler->warn("Shortcut ".$self->getId." is linked to an asset ".$self->get("shortcutToAssetId").", which no longer exists."); + return "The asset this shortcut is linked to no longer exists. You need to delete this shortcut."; +} + +#------------------------------------------------------------------- + =head2 prepareView ( ) See WebGUI::Asset::prepareView() for details. @@ -589,7 +608,12 @@ sub prepareView { my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId")); $template->prepare; $self->{_viewTemplate} = $template; - $self->getShortcut->prepareView; + my $shortcut = $self->getShortcut; + if (defined $shortcut) { + $shortcut->prepareView; + } else { + $self->notLinked; + } } @@ -614,6 +638,13 @@ sub view { my $content; my $i18n = WebGUI::International->new($self->session,"Asset_Shortcut"); my $shortcut = $self->getShortcut; + if (defined $shortcut) { + # continue + } elsif ($self->canEdit) { + return ''.$self->notLinked.''; + } else { + return undef; + } if ($self->get("shortcutToAssetId") eq $self->get("parentId")) { $content = $i18n->get("Displaying this shortcut would cause a feedback loop"); } else { @@ -814,7 +845,14 @@ sub www_view { $self->session->asset($self->getParent); return $self->session->asset->www_view; } else { - return $self->getShortcut->www_view; + my $shortcut = $self->getShortcut; + if (defined $shortcut) { + return $shortcut->www_view; + } elsif ($self->canEdit) { + return $self->session->style->userStyle(''.$self->notLinked.''); + } else { + return $self->getParent->www_view; + } } }
'.$i18n->get('fieldName').''.$i18n->get('edit delete fieldname').''.$i18n->get('Original Value').''.$i18n->get('New value').''.$i18n->get('Replacement value').'