Index: lib/WebGUI/VersionTag.pm =================================================================== --- lib/WebGUI/VersionTag.pm (revision 6254) +++ lib/WebGUI/VersionTag.pm (working copy) @@ -125,10 +125,13 @@ #------------------------------------------------------------------- -=head2 get ( name ) +=head2 get ( [ name ] ) -Returns the value for a given property. An incomplete list of properties is below: +Returns the value for a given property. If C is not specified, returns +all the properties. +An incomplete list of properties is below: + =head3 name The name of the tag. @@ -170,9 +173,15 @@ =cut sub get { - my $self = shift; - my $name = shift; - return $self->{_data}{$name}; + my $self = shift; + my $name = shift; + + if ( $name ) { + return $self->{_data}{$name}; + } + else { + return \%{ $self->{_data} }, + } } #------------------------------------------------------------------- Index: lib/WebGUI/Operation/VersionTag.pm =================================================================== --- lib/WebGUI/Operation/VersionTag.pm (revision 6254) +++ lib/WebGUI/Operation/VersionTag.pm (working copy) @@ -56,6 +56,25 @@ return $user->isInGroup( $session->setting->get("groupIdAdminVersionTag") ); } +#---------------------------------------------------------------------------- + +=head2 getVersionTagOptions ( session ) + +Gets a hash of tagId => name for all open version tags + +=cut + +sub getVersionTagOptions { + my $session = shift; + tie my %tag, 'Tie::IxHash'; + + for my $tag ( @{ WebGUI::VersionTag->getOpenTags( $session ) } ) { + $tag{ $tag->getId } = $tag->get('name'); + } + + return %tag; +} + #------------------------------------------------------------------- =head2 www_editVersionTag ( session ) @@ -422,6 +441,9 @@ Displays a list of the revsions associated with this tag. +Optionally performs an action related to the revisions in this version +tag, such as purging or moving to another version tag. + =head3 session A reference to the current session. @@ -439,6 +461,40 @@ $ac->addSubmenuItem($session->url->page('op=editVersionTag'), $i18n->get("add a version tag")); $ac->addSubmenuItem($session->url->page('op=manageCommittedVersions'), $i18n->get("manage committed versions")) if canView($session); $ac->addSubmenuItem($session->url->page('op=manageVersions'), $i18n->get("manage versions")); + + # Process any actions + if ( $session->form->get('action') eq "purge" ) { + # Purge these revisions + my @assetInfo = $session->form->get('assetInfo'); + for my $assetInfo ( @assetInfo ) { + ( my $assetId, my $revisionDate ) = split ":", $assetInfo; + my $asset = WebGUI::Asset->new( $session, $assetId, undef, $revisionDate ); + $asset->purgeRevision; + } + } + elsif ( $session->form->get('action') eq "move" ) { + # Get the new version tag + my $moveToTagId = $session->form->get('moveToTagId'); + my $moveToTag; + if ( $moveToTagId eq "new" ) { + # Create a copy of the old version tag + $moveToTag = WebGUI::VersionTag->create( $session, $tag->get ); + # But update the name + $moveToTag->set( { "name" => $tag->get('name') . ' ( copy )' } ); + } + else { + $moveToTag = WebGUI::VersionTag->new( $session, $moveToTagId ); + } + + # Move these revisions + my @assetInfo = $session->form->get('assetInfo'); + for my $assetInfo ( @assetInfo ) { + ( my $assetId, my $revisionDate ) = split ":", $assetInfo; + my $asset = WebGUI::Asset->new( $session, $assetId, undef, $revisionDate ); + $asset->setVersionTag( $moveToTag->getId ); + } + } + my $output = ""; if ($session->form->param("workflowInstanceId")) { my $instance = WebGUI::Workflow::Instance->new($session, $session->form->param("workflowInstanceId")); @@ -477,8 +533,38 @@ $comments =~ s/\n/
/g; $output .= $comments; } - $output .= ' - '; + + # The options for tags to move to + tie my %moveToTagOptions, 'Tie::IxHash', ( + "new" => $i18n->get( "manageRevisionsInTag moveTo new" ), + ( getVersionTagOptions( $session ) ), + ); + + # Output the revisions + $output + .= WebGUI::Form::formHeader( $session, {} ) + . WebGUI::Form::hidden( $session, { name => 'op', value=> 'manageRevisionsInTag' } ) + . WebGUI::Form::hidden( $session, { name => 'tagId', value => $tag->getId } ) + . '
'.$i18n->get(99,"Asset").''.$i18n->get("type","Asset").''.$i18n->get("revision date","Asset").''.$i18n->get("revised by","Asset").'
' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . ' ' + ; my $p = WebGUI::Paginator->new($session,$session->url->page("op=manageRevisionsInTag;tagId=".$tag->getId)); $p->setDataByQuery("select assetData.revisionDate, users.username, asset.assetId, asset.className from assetData left join asset on assetData.assetId=asset.assetId left join users on assetData.revisedBy=users.userId @@ -486,8 +572,13 @@ foreach my $row (@{$p->getPageData}) { my ($date,$by,$id, $class) = ($row->{revisionDate}, $row->{username}, $row->{assetId}, $row->{className}); my $asset = WebGUI::Asset->new($session,$id,$class,$date); + # A checkbox for delete and move actions + my $checkbox = WebGUI::Form::checkbox( $session, { + name => 'assetInfo', + value => join( ":", $id, $date ), + }); $output .= ' @@ -495,7 +586,7 @@ '; } - $output .= '
' + . $i18n->get("manageRevisionsInTag with selected") + . '' + . '' + . WebGUI::Form::SelectBox( $session, { + name => 'moveToTagId', + options => \%moveToTagOptions, + } ) + . '
'.$i18n->get(99,"Asset").''.$i18n->get("type","Asset").''.$i18n->get("revision date","Asset").''.$i18n->get("revised by","Asset").'
' - .$session->icon->delete("func=purgeRevision;proceed=manageRevisionsInTag;tagId=".$tag->getId.";revisionDate=".$date,$asset->get("url"),$i18n->get("purge revision prompt")) + . $checkbox .$session->icon->view("func=view;revision=".$date, $asset->get("url")) .' '.$asset->getTitle.''.$session->datetime->epochToHuman($date).' '.$by.'
'.$p->getBarSimple; + $output .= ''.$p->getBarSimple.WebGUI::Form::formFooter( $session ); $tag = $session->db->getRow("assetVersionTag","tagId",$tag->getId); return $ac->render($output,$i18n->get("revisions in tag").": ".$tag->{name}); } Index: lib/WebGUI/i18n/English/VersionTag.pm =================================================================== --- lib/WebGUI/i18n/English/VersionTag.pm (revision 6254) +++ lib/WebGUI/i18n/English/VersionTag.pm (working copy) @@ -338,6 +338,31 @@ lastUpdated => 0, }, + + 'manageRevisionsInTag moveTo new' => { + message => q{-> New Version Tag}, + lastUpdated => 0, + context => q{Option to move revisions to a new version tag}, + }, + + 'manageRevisionsInTag with selected' => { + message => q{With Selected: }, + lastUpdated => 0, + context => q{Lead-in for actions to perform after selecting revisions}, + }, + + 'manageRevisionsInTag purge' => { + message => q{Purge}, + lastUpdated => 0, + context => q{Label for button to purge revisions}, + }, + + 'manageRevisionsInTag move' => { + message => q{Move To:}, + lastUpdated => 0, + context => q{Label for button to move revisions}, + }, + 'topicName' => { message => q|Version Control|, lastUpdated => 1148360141,