diff --git a/docs/migration.txt b/docs/migration.txt index fad56eace..150ae7111 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -281,15 +281,6 @@ processPropertiesFromFormPost ----------------------------- Absurdly long and non-descriptive name, changed to processEditForm -Versioning ----------- -New revisions are not created in a "pending" state automatically. VersionTags -are not created by calling addRevision(). If you want a revision to be part of -a version tag, you must set - status => "pending", - tagId => $tag->getId, -explicitly. - Admin Controls -------------------- The admin controls are now added to the asset with javascript. This javascript diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 03f288cd8..26e554c9b 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2776,40 +2776,12 @@ sub www_addSave { return $self->session->style->userStyle($i18n->get("over max assets")) if ($self->session->config->get("maximumAssets") <= $count); } - # Determine what version tag we should use - my $autoCommitId = $self->getAutoCommitWorkflowId(); - - my ($workingTag, $oldWorking); - if ( $autoCommitId ) { - $workingTag - = WebGUI::VersionTag->create( $session, { - groupToUse => '12', # Turn Admin On (for lack of something better) - workflowId => $autoCommitId, - } ); - } - else { - my $parentAsset; - if ( not defined( $parentAsset = $self->getParent ) ) { - $parentAsset = WebGUI::Asset->newPending( $session, $self->parentId ); - } - if ( $parentAsset->hasBeenCommitted ) { - $workingTag = WebGUI::VersionTag->getWorking( $session ); - } - else { - $oldWorking = WebGUI::VersionTag->getWorking($session, 'noCreate'); - $workingTag = WebGUI::VersionTag->new( $session, $parentAsset->tagId ); - $workingTag->setWorking(); - } - } - # Add the new asset my $object; my $className = $form->process('className','className') || $form->process('class','className'); $object = $self->addChild({ className => $className, revisedBy => $session->user->userId, - tagId => $workingTag->getId, - status => "pending", }); if ( !defined $object ) { my $url = $session->url->page; @@ -2819,11 +2791,6 @@ sub www_addSave { $object->{_parent} = $self; $object->url(undef); - # More version tag stuff - $object->setVersionLock; - $object->setAutoCommitTag($workingTag) if (defined $autoCommitId); - $oldWorking->setWorking if $oldWorking; - # Process properties from form post my $errors = $object->processEditForm; if (ref $errors eq 'ARRAY') { @@ -2924,43 +2891,8 @@ sub www_editSave { return $session->privilege->locked() unless $self->canEditIfLocked; return $session->privilege->insufficient() unless $self->canEdit; - # Determine what version tag we should use - my $autoCommitId = $self->getAutoCommitWorkflowId(); - - my ($workingTag, $oldWorking); - if ( $autoCommitId ) { - $workingTag - = WebGUI::VersionTag->create( $session, { - groupToUse => '12', # Turn Admin On (for lack of something better) - workflowId => $autoCommitId, - } ); - } - else { - my $parentAsset; - if ( not defined( $parentAsset = $self->getParent ) ) { - $parentAsset = WebGUI::Asset->newPending( $session, $self->parentId ); - } - if ( $parentAsset->hasBeenCommitted ) { - $workingTag = WebGUI::VersionTag->getWorking( $session ); - } - else { - $oldWorking = WebGUI::VersionTag->getWorking($session, 'noCreate'); - $workingTag = WebGUI::VersionTag->new( $session, $parentAsset->tagId ); - $workingTag->setWorking(); - } - } - # Add the new revision - my $object = $self->addRevision({ - revisedBy => $session->user->userId, - tagId => $workingTag->getId, - status => "pending", - }); - - # More version tag stuff - $object->setVersionLock; - $object->setAutoCommitTag($workingTag) if (defined $autoCommitId); - $oldWorking->setWorking if $oldWorking; + my $object = $self->addRevision(); # Process properties from form post my $errors = $object->processEditForm; diff --git a/lib/WebGUI/Asset/EMSSubmission.pm b/lib/WebGUI/Asset/EMSSubmission.pm index 8333df1c8..6f7e9b9aa 100644 --- a/lib/WebGUI/Asset/EMSSubmission.pm +++ b/lib/WebGUI/Asset/EMSSubmission.pm @@ -98,11 +98,14 @@ property seatsAvailable => ( property startDate => ( noFormPost => 1, fieldType => "dateTime", - default => '', + builder => '_default_startDate', label => [ "add/edit event start date", 'Asset_EMSSubmission' ], hoverHelp => [ "add/edit event start date help", 'Asset_EMSSubmission' ], autoGenerate => 0, ); +sub _default_startDate { + return WebGUI::DateTime->new()->toMysql; +} property duration => ( tab => "properties", fieldType => "float", diff --git a/lib/WebGUI/Asset/EMSSubmissionForm.pm b/lib/WebGUI/Asset/EMSSubmissionForm.pm index b5428f5a4..69f9bfda9 100644 --- a/lib/WebGUI/Asset/EMSSubmissionForm.pm +++ b/lib/WebGUI/Asset/EMSSubmissionForm.pm @@ -123,7 +123,6 @@ sub addSubmission { $newParams->{submissionId} = $self->ems->getNextSubmissionId; my $newAsset = $self->addChild($newParams); WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, { override => 1, allowComments => 0 }); - $self = $self->cloneFromDb; return $newAsset; } diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index c25185aec..099e0f25b 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -344,7 +344,7 @@ sub disqualifyAsLastPost { $thread->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), }); } else { - $thread->update({ lastPostId => '', lastPostDate => '', }); + $thread->update({ lastPostId => '', lastPostDate => 0 }); } } my $cs = $thread->getParent; @@ -359,7 +359,7 @@ sub disqualifyAsLastPost { $cs->update({ lastPostId => $secondary_post->getId, lastPostDate => $secondary_post->get('creationDate'), }); } else { - $cs->update({ lastPostId => '', lastPostDate => '', }); + $cs->update({ lastPostId => '', lastPostDate => 0 }); } } } diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index a310411b8..58736d530 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -45,7 +45,7 @@ property lastPostId => ( property lastPostDate => ( noFormPost => 1, fieldType => "dateTime", - default => undef, + default => 0, ); property karma => ( noFormPost => 1, diff --git a/lib/WebGUI/Asset/Sku/Subscription.pm b/lib/WebGUI/Asset/Sku/Subscription.pm index 8fa0ba0e0..647665742 100644 --- a/lib/WebGUI/Asset/Sku/Subscription.pm +++ b/lib/WebGUI/Asset/Sku/Subscription.pm @@ -620,13 +620,13 @@ sub www_createSubscriptionCodeBatch { name => 'name', label => $i18n->get('batch name'), hoverHelp => $i18n->get('batch name description'), - value => $session->form->process('name'), + value => $session->form->process('name') || '', ); $f->addField( "textarea", name => 'description', label => $i18n->get('batch description'), hoverHelp => $i18n->get('batch description description'), - value => $session->form->process("description"), + value => $session->form->process("description") || '', ); $f->addField( "submit", name => "send" ); diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index fc3a7e680..415e9f996 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -1379,7 +1379,7 @@ around groupIdView => sub { my $oldValue = $self->$orig; my $return = $self->$orig(@_); # Update the subscription group so if they can't see the collab, they don't get e-mailed - if ( $newValue && $newValue != $oldValue ) { + if ( $newValue && $newValue ne $oldValue ) { my $instance_data = { workflowId => 'xR-_GRRbjBojgLsFx3dEMA', className => 'WebGUI::Asset', diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index 031d3ae4d..148ab91ca 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -121,6 +121,7 @@ use WebGUI::Asset::Wobject::Folder; use WebGUI::Paginator; use WebGUI::Keyword; use WebGUI::Search; +use WebGUI::VersionTag; use File::Path; @@ -302,7 +303,20 @@ sub getFolder { my $folder = eval { WebGUI::Asset->newByUrl($session, $folderUrl); }; return $folder if !Exception::Class->caught(); - ##The requested folder doesn't exist. Make it. + ##The requested folder doesn't exist. Make it and autocommit it. + + ##For a fully automatic commit, save the current tag, create a new one + ##with the commit without approval workflow, commit it, then restore + ##the original if it exists + my ($oldVersionTag, $newVersionTag); + $oldVersionTag = WebGUI::VersionTag->getWorking($session, 'noCreate'); + + if ($self->hasBeenCommitted) { + $newVersionTag = WebGUI::VersionTag->create($session, { workflowId => 'pbworkflow00000000003', }); + $newVersionTag->setWorking; + $newVersionTag->set({ name => 'Adding folder '. $folderName. ' to archive '. $self->getUrl}); + } + ##Call SUPER because my addChild calls getFolder $folder = $self->addChild({ @@ -313,6 +327,9 @@ sub getFolder { isHidden => 1, styleTemplateId => $self->styleTemplateId, }); + $newVersionTag->commit() if $newVersionTag; + ##Restore the old one, if it exists + $oldVersionTag->setWorking() if $oldVersionTag; ##Get a new version of the asset from the db with the correct state $folder = $folder->cloneFromDb(); diff --git a/lib/WebGUI/AssetHelper/Copy.pm b/lib/WebGUI/AssetHelper/Copy.pm index 8d8bd7736..3e8788846 100644 --- a/lib/WebGUI/AssetHelper/Copy.pm +++ b/lib/WebGUI/AssetHelper/Copy.pm @@ -72,18 +72,15 @@ sub copy { my $tree = WebGUI::ProgressTree->new($session, [ $asset->getId ] ); $process->update(sub { $tree->json }); my $newAsset = $asset->duplicate({ state => "clipboard" }); - - # If we aren't committing, add to a tag - if ( !$args->{commit} ) { - $newAsset->update({ - status => "pending", - tagId => WebGUI::VersionTag->getWorking( $session )->getId, - }); - } $newAsset->update({ title => $newAsset->getTitle . ' (copy)'}); $tree->success($asset->getId); $process->update(sub { $tree->json }); + + my $tag = WebGUI::VersionTag->getWorking($session); + if ($tag->canAutoCommit) { + $tag->commit; + } } 1; diff --git a/lib/WebGUI/AssetHelper/CopyBranch.pm b/lib/WebGUI/AssetHelper/CopyBranch.pm index e8ceea32c..2c4ebc214 100644 --- a/lib/WebGUI/AssetHelper/CopyBranch.pm +++ b/lib/WebGUI/AssetHelper/CopyBranch.pm @@ -4,6 +4,7 @@ use strict; use Class::C3; use base qw/WebGUI::AssetHelper::Copy/; use Scalar::Util qw{ blessed }; +use WebGUI::VersionTag; =head1 LEGAL @@ -122,17 +123,16 @@ sub copyBranch { $process->update(sub { $tree->json }); my $newAsset = $asset->duplicateBranch( $args->{childrenOnly} ? 1 : 0, 'clipboard' ); - # If we aren't committing, add to a tag - if ( !$args->{commit} ) { - $newAsset->update({ - status => "pending", - tagId => WebGUI::VersionTag->getWorking( $session )->getId, - }); - } $newAsset->update({ title => $newAsset->getTitle . ' (copy)'}); $tree->success($asset->getId); $process->update(sub { $tree->json }); + + my $tag = WebGUI::VersionTag->getWorking($session); + if ($tag->canAutoCommit) { + $tag->commit; + } + } 1; diff --git a/lib/WebGUI/AssetHelper/CreateShortcut.pm b/lib/WebGUI/AssetHelper/CreateShortcut.pm index bcf4f4208..93724f3a1 100644 --- a/lib/WebGUI/AssetHelper/CreateShortcut.pm +++ b/lib/WebGUI/AssetHelper/CreateShortcut.pm @@ -48,8 +48,6 @@ sub process { my $import = WebGUI::Asset->getImportNode( $session ); my $tag = WebGUI::VersionTag->getWorking( $session ); my $child = $import->addChild({ - tagId => $tag->getId, - status => 'pending', className => 'WebGUI::Asset::Shortcut', shortcutToAssetId => $asset->getId, title => $asset->getTitle, diff --git a/lib/WebGUI/AssetHelper/Duplicate.pm b/lib/WebGUI/AssetHelper/Duplicate.pm index 620ba924e..e562efc3b 100644 --- a/lib/WebGUI/AssetHelper/Duplicate.pm +++ b/lib/WebGUI/AssetHelper/Duplicate.pm @@ -73,13 +73,6 @@ sub duplicate { $process->update(sub { $tree->json }); my $newAsset = $asset->duplicate; - # If we aren't committing, add to a tag - if ( !$args->{commit} ) { - $newAsset->update({ - status => "pending", - tagId => WebGUI::VersionTag->getWorking( $session )->getId, - }); - } $newAsset->update({ title => $newAsset->getTitle . ' (Duplicate)'}); $tree->success($asset->getId); diff --git a/lib/WebGUI/AssetHelper/EditBranch.pm b/lib/WebGUI/AssetHelper/EditBranch.pm index 358387776..f728f4d4b 100644 --- a/lib/WebGUI/AssetHelper/EditBranch.pm +++ b/lib/WebGUI/AssetHelper/EditBranch.pm @@ -405,7 +405,7 @@ sub www_editBranchSave { my $revision; if (scalar %$newData > 0) { $revision = $descendant->addRevision( - { %$newData, tagId => $tag->getId, status => "pending" }, + { %$newData, }, undef, {skipAutoCommitWorkflows => 1, skipNotification => 1}, ); diff --git a/lib/WebGUI/AssetHelper/Image/Crop.pm b/lib/WebGUI/AssetHelper/Image/Crop.pm index 122ed8cb6..a166bab47 100644 --- a/lib/WebGUI/AssetHelper/Image/Crop.pm +++ b/lib/WebGUI/AssetHelper/Image/Crop.pm @@ -157,8 +157,7 @@ sub www_cropSave { return $session->privilege->locked() unless $asset->canEditIfLocked; my $tag = WebGUI::VersionTag->getWorking( $session ); - $asset = $asset->addRevision({ tagId => $tag->getId, status => "pending" }); - $asset->setVersionLock; + $asset = $asset->addRevision(); delete $asset->{_storageLocation}; $asset->getStorageLocation->crop( $asset->filename, @@ -171,7 +170,7 @@ sub www_cropSave { WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, { allowComments => 0 }); # We're in admin mode, close the dialog - my $helper = { message => 'Image croped', }; + my $helper = { message => 'Image cropped', }; my $text = '