If adding an asset is added to another asset with an open version tag, put the

new asset in that version tag, too.
This commit is contained in:
Colin Kuskie 2009-06-23 19:32:40 +00:00
parent caee13dba2
commit f0eaa51d3a
4 changed files with 125 additions and 10 deletions

View file

@ -2757,7 +2757,7 @@ sub www_editSave {
$object->updateHistory("edited");
# we handle auto commit assets here in case they didn't handle it themselves
if ($object->getAutoCommitWorkflowId && $self->hasBeenCommitted) {
if ($object->getAutoCommitWorkflowId) {
$object->requestAutoCommit;
}
# else, try to to auto commit

View file

@ -373,6 +373,41 @@ sub purgeRevision {
}
#-------------------------------------------------------------------
=head2 moveAssetToVersionTag ( tag )
=head3 moveToTag
Migrate the current asset to the designated version tag
=cut
sub moveAssetToVersionTag {
my ( $self, $moveToTag ) = @_;
# Determine if we were passed a version tagId or a VersionTag Class and act appropriately
#
my $moveToTagId = $moveToTag;
if ( ref($moveToTag) eq "WebGUI::VersionTag" ) {
$moveToTagId = $moveToTag->get('tagId');
}
else {
$moveToTag = WebGUI::VersionTag->new( $self->session, $moveToTagId );
}
my $tag = WebGUI::VersionTag->new( $self->session, $self->get('tagId') );
$self->setVersionTag($moveToTagId);
my $versionTag = $self->session->db->quickScalar("SELECT tagId FROM assetData WHERE assetId=? AND revisionDate=?",[$self->getId,$self->get('revisionDate')]);
# If no revisions remain, delete the version tag
if ( $tag->getRevisionCount <= 0 ) {
$tag->rollback;
}
} ## end sub moveAssetToVersionTag
#-------------------------------------------------------------------
=head2 requestAutoCommit ( )
@ -382,13 +417,29 @@ Requests an autocommit tag be commited. See also getAutoCommitWorkflowId() and s
=cut
sub requestAutoCommit {
my $self = shift;
my $tag = $self->{_autoCommitTag};
if (defined $tag) {
$tag->requestCommit;
delete $self->{_autoCommitTag};
}
}
my $self = shift;
my $parentAsset;
if ( not defined( $parentAsset = $self->getParent ) ) {
$parentAsset = WebGUI::Asset->newPending( $self->session, $self->get('parentId') );
}
unless ( $parentAsset->hasBeenCommitted ) {
my $tagId = $parentAsset->get('tagId');
if ($tagId) {
if ( $tagId ne $self->get('tagId') ) {
$self->moveAssetToVersionTag($tagId);
return;
}
}
}
my $tag = $self->{_autoCommitTag};
if ( defined $tag ) {
$tag->requestCommit;
delete $self->{_autoCommitTag};
}
} ## end sub requestAutoCommit
#-------------------------------------------------------------------