From 37c7f002ac1a8044f44586973a333b0ebb4b3cf6 Mon Sep 17 00:00:00 2001 From: Roy Johnson Date: Fri, 23 Jun 2006 19:34:53 +0000 Subject: [PATCH] fix - Deleted assets reappear upon paste of parent --- docs/changelog/6.x.x.txt | 1 + lib/WebGUI/Asset.pm | 19 +++++++++++++++---- lib/WebGUI/AssetClipboard.pm | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 63a6a105f..9153e60b0 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -23,6 +23,7 @@ over from scratch. - fix: Very very bad commerce bug that caused ITransact to charge the user more than it was supposed to and more than it told them it was charging. + - fix: Deleted assets reappear upon paste of parent 6.99.4 diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index f4e9fa329..dd9ecbd49 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1641,17 +1641,28 @@ sub processTemplate { #------------------------------------------------------------------- -=head2 publish ( ) +=head2 publish ( arrayref ) -Sets an asset and it's descendants to a state of 'published' regardless of it's current state. +Sets an asset and it's descendants to a state of 'published' regardless of it's current state by default. +Otherwise sets state to published only for assests matching one of the states passed in. + +=head3 arrayref + +[ 'clipboard', 'clipboard-limbo', 'trash', 'trash-limbo', 'published' ] =cut sub publish { my $self = shift; - my $assetIds = $self->session->db->buildArrayRef("select assetId from asset where lineage like ".$self->session->db->quote($self->get("lineage").'%')); + my $statesToPublish = shift; + + my $stateList = $self->session->db->quoteAndJoin($statesToPublish); + my $where = "and state in (".$stateList.")" if $statesToPublish; + + my $assetIds = $self->session->db->buildArrayRef("select assetId from asset where lineage like ".$self->session->db->quote($self->get("lineage").'%')." $where"); my $idList = $self->session->db->quoteAndJoin($assetIds); - $self->session->db->write("update asset set state='published', stateChangedBy=".$self->session->db->quote($self->session->user->userId).", stateChanged=".$self->session->datetime->time()." where assetId in (".$idList.")"); + + $self->session->db->write("update asset set state='published', stateChangedBy=".$self->session->db->quote($self->session->user->userId).", stateChanged=".$self->session->datetime->time()." where assetId in (".$idList.")"); my $cache = WebGUI::Cache->new($self->session); foreach my $id (@{$assetIds}) { # we do the purge directly cuz it's a lot faster than instantiating all these assets diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 71abcc3d7..9f49e2836 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -153,7 +153,7 @@ sub paste { my $pastedAsset = WebGUI::Asset->newByDynamicClass($self->session,$assetId); return 0 unless ($self->get("state") eq "published"); if ($self->getId eq $pastedAsset->get("parentId") || $pastedAsset->setParent($self)) { - $pastedAsset->publish; + $pastedAsset->publish(['published']); # Paste only published assets $pastedAsset->updateHistory("pasted to parent ".$self->getId); return 1; }