From 9e2cdbdc4b37ab7402a476beb3da0cfbf2e24d3a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 5 Sep 2009 10:03:26 -0700 Subject: [PATCH] Fix POD in duplicateBranch, tidy the code. --- lib/WebGUI/AssetBranch.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index f79a5ff96..158c4d448 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -38,30 +38,34 @@ These methods are available from this class: #------------------------------------------------------------------- -=head2 duplicateBranch ( ) +=head2 duplicateBranch ( [ $childrenOnly ] ) Duplicates this asset and the entire subtree below it. Returns the root of the new subtree. +=head3 $childrenOnly + +If true, then only children, and not descendants, will be duplicated. + =cut sub duplicateBranch { - my $self = shift; - my $childrenOnly = shift || 0; + my $self = shift; + my $childrenOnly = shift; my $newAsset = $self->duplicate({skipAutoCommitWorkflows=>1,skipNotification=>1}); my $contentPositions = $self->get("contentPositions"); - my $assetsToHide = $self->get("assetsToHide"); + my $assetsToHide = $self->get("assetsToHide"); foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1})}) { my $newChild = $childrenOnly ? $child->duplicate({skipAutoCommitWorkflows=>1, skipNotification=>1}) : $child->duplicateBranch; $newChild->setParent($newAsset); my ($oldChildId, $newChildId) = ($child->getId, $newChild->getId); $contentPositions =~ s/\Q${oldChildId}\E/${newChildId}/g if ($contentPositions); - $assetsToHide =~ s/\Q${oldChildId}\E/${newChildId}/g if ($assetsToHide); + $assetsToHide =~ s/\Q${oldChildId}\E/${newChildId}/g if ($assetsToHide); } $newAsset->update({contentPositions=>$contentPositions}) if $contentPositions; - $newAsset->update({assetsToHide=>$assetsToHide}) if $assetsToHide; + $newAsset->update({assetsToHide=>$assetsToHide}) if $assetsToHide; return $newAsset; }