removing the autocommit jury rig that posts and wikipage's were using
This commit is contained in:
parent
82867ec273
commit
eb580be7f1
6 changed files with 39 additions and 37 deletions
|
|
@ -601,6 +601,8 @@ sub getEditTabs {
|
||||||
return ();
|
return ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getEditForm ()
|
=head2 getEditForm ()
|
||||||
|
|
||||||
Creates and returns a tabform to edit parameters of an Asset.
|
Creates and returns a tabform to edit parameters of an Asset.
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,12 @@ sub formatContent {
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub getAutoCommitWorkflowId {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->getThread->getParent->get("approvalWorkflow");
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getAvatarUrl ( )
|
=head2 getAvatarUrl ( )
|
||||||
|
|
@ -749,20 +755,6 @@ sub processPropertiesFromFormPost {
|
||||||
$self->getThread->subscribe if ($self->session->form->process("subscribe"));
|
$self->getThread->subscribe if ($self->session->form->process("subscribe"));
|
||||||
delete $self->{_storageLocation};
|
delete $self->{_storageLocation};
|
||||||
$self->postProcess;
|
$self->postProcess;
|
||||||
# allows us to let the cs post use it's own workflow approval process
|
|
||||||
my $currentTag = WebGUI::VersionTag->getWorking($self->session);
|
|
||||||
if ($currentTag->getAssetCount < 2) {
|
|
||||||
$currentTag->set({workflowId=>$self->getThread->getParent->get("approvalWorkflow")});
|
|
||||||
$currentTag->requestCommit;
|
|
||||||
} else {
|
|
||||||
my $newTag = WebGUI::VersionTag->create($self->session, {
|
|
||||||
name=>$self->getTitle." / ".$self->session->user->username,
|
|
||||||
workflowId=>$self->getThread->getParent->get("approvalWorkflow")
|
|
||||||
});
|
|
||||||
$self->session->db->write("update assetData set tagId=? where assetId=? and tagId=?",[$newTag->getId, $self->getId, $currentTag->getId]);
|
|
||||||
$self->purgeCache;
|
|
||||||
$newTag->requestCommit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,13 @@ sub duplicate {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub getAutoCommitWorkflowId {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->getWiki->get("approvalWorkflow");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub getEditForm {
|
sub getEditForm {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
@ -231,7 +238,7 @@ sub processPropertiesFromFormPost {
|
||||||
isHidden => 1,
|
isHidden => 1,
|
||||||
actionTakenBy => $self->session->user->userId,
|
actionTakenBy => $self->session->user->userId,
|
||||||
actionTaken => $actionTaken});
|
actionTaken => $actionTaken});
|
||||||
if ($self->canAdminister) {
|
if ($self->getWiki->canAdminister) {
|
||||||
$self->update({isProtected => $self->session->form("isProtected")});
|
$self->update({isProtected => $self->session->form("isProtected")});
|
||||||
}
|
}
|
||||||
delete $self->{_storageLocation};
|
delete $self->{_storageLocation};
|
||||||
|
|
@ -249,20 +256,6 @@ sub processPropertiesFromFormPost {
|
||||||
$size += $storage->getFileSize($file);
|
$size += $storage->getFileSize($file);
|
||||||
}
|
}
|
||||||
$self->setSize($size);
|
$self->setSize($size);
|
||||||
# allows us to let the cs post use it's own workflow approval process
|
|
||||||
my $currentTag = WebGUI::VersionTag->getWorking($self->session);
|
|
||||||
if ($currentTag->getAssetCount < 2) {
|
|
||||||
$currentTag->set({workflowId=>$self->getWiki->get("approvalWorkflow")});
|
|
||||||
$currentTag->requestCommit;
|
|
||||||
} else {
|
|
||||||
my $newTag = WebGUI::VersionTag->create($self->session, {
|
|
||||||
name=>$self->getTitle." / ".$self->session->user->username,
|
|
||||||
workflowId=>$self->getWiki->get("approvalWorkflow")
|
|
||||||
});
|
|
||||||
$self->session->db->write("update assetData set tagId=? where assetId=? and tagId=?",[$newTag->getId, $self->getId, $currentTag->getId]);
|
|
||||||
$self->purgeCache;
|
|
||||||
$newTag->requestCommit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -298,7 +291,7 @@ sub view {
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub www_delete {
|
sub www_delete {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->session->privilege->insufficient unless $self->canAdminister;
|
return $self->session->privilege->insufficient unless $self->getWiki->canAdminister;
|
||||||
$self->trash;
|
$self->trash;
|
||||||
$self->session->asset($self->getParent);
|
$self->session->asset($self->getParent);
|
||||||
return $self->getParent->www_view;
|
return $self->getParent->www_view;
|
||||||
|
|
|
||||||
|
|
@ -75,12 +75,12 @@ sub addChild {
|
||||||
$self->session->db->beginTransaction;
|
$self->session->db->beginTransaction;
|
||||||
$self->session->db->write("insert into asset (assetId, parentId, lineage, creationDate, createdBy, className, state) values (?,?,?,?,?,?,'published')",
|
$self->session->db->write("insert into asset (assetId, parentId, lineage, creationDate, createdBy, className, state) values (?,?,?,?,?,?,'published')",
|
||||||
[$id,$self->getId,$lineage,$now,$self->session->user->userId,$properties->{className}]);
|
[$id,$self->getId,$lineage,$now,$self->session->user->userId,$properties->{className}]);
|
||||||
my $temp = WebGUI::Asset->newByPropertyHashRef($self->session,{
|
|
||||||
assetId=>$id,
|
|
||||||
className=>$properties->{className}
|
|
||||||
});
|
|
||||||
my $newAsset = $temp->addRevision($properties,$now);
|
|
||||||
$self->session->db->commit;
|
$self->session->db->commit;
|
||||||
|
$properties->{assetId} = $id;
|
||||||
|
$properties->{parentId} = $self->getId;
|
||||||
|
my $temp = WebGUI::Asset->newByPropertyHashRef($self->session,$properties);
|
||||||
|
$temp->{_parent} = $self;
|
||||||
|
my $newAsset = $temp->addRevision($properties,$now);
|
||||||
$self->updateHistory("added child ".$id);
|
$self->updateHistory("added child ".$id);
|
||||||
$self->session->http->setStatus(201,"Asset Creation Successful");
|
$self->session->http->setStatus(201,"Asset Creation Successful");
|
||||||
return $newAsset;
|
return $newAsset;
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,9 @@ sub addRevision {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $properties = shift;
|
my $properties = shift;
|
||||||
my $now = shift ||$self->session->datetime->time();
|
my $now = shift ||$self->session->datetime->time();
|
||||||
my $workingTag = WebGUI::VersionTag->getWorking($self->session);
|
my $autoCommitId = $self->getAutoCommitWorkflowId();
|
||||||
|
my $workingTag = ($autoCommitId) ? WebGUI::VersionTag->create($self->session, {groupToUse=>'12', workflowId=>$autoCommitId}) : WebGUI::VersionTag->getWorking($self->session);
|
||||||
|
$self->session->db->beginTransaction;
|
||||||
$self->session->db->write("insert into assetData (assetId, revisionDate, revisedBy, tagId, status, url,
|
$self->session->db->write("insert into assetData (assetId, revisionDate, revisedBy, tagId, status, url,
|
||||||
ownerUserId, groupIdEdit, groupIdView) values (?, ?, ?, ?, 'pending', ?, '3','3','7')",
|
ownerUserId, groupIdEdit, groupIdView) values (?, ?, ?, ?, 'pending', ?, '3','3','7')",
|
||||||
[$self->getId, $now, $self->session->user->userId, $workingTag->getId, $self->getId] );
|
[$self->getId, $now, $self->session->user->userId, $workingTag->getId, $self->getId] );
|
||||||
|
|
@ -67,12 +69,14 @@ sub addRevision {
|
||||||
$self->session->db->write("insert into ".$definition->{tableName}." (assetId,revisionDate) values (?,?)", [$self->getId, $now]);
|
$self->session->db->write("insert into ".$definition->{tableName}." (assetId,revisionDate) values (?,?)", [$self->getId, $now]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$self->session->db->commit;
|
||||||
my $newVersion = WebGUI::Asset->new($self->session,$self->getId, $self->get("className"), $now);
|
my $newVersion = WebGUI::Asset->new($self->session,$self->getId, $self->get("className"), $now);
|
||||||
$newVersion->updateHistory("created revision");
|
$newVersion->updateHistory("created revision");
|
||||||
$newVersion->update($self->get);
|
$newVersion->update($self->get);
|
||||||
$newVersion->setVersionLock;
|
$newVersion->setVersionLock;
|
||||||
$properties->{status} = 'pending';
|
$properties->{status} = 'pending';
|
||||||
$newVersion->update($properties);
|
$newVersion->update($properties);
|
||||||
|
$workingTag->requestCommit if ($autoCommitId);
|
||||||
return $newVersion;
|
return $newVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,6 +114,18 @@ sub commit {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getAutoCommitWorkflowId ( )
|
||||||
|
|
||||||
|
Override this method in your asset if you want your asset to auto-commit its workflow each time addRevision() is called on it. Your overridden method must return the workflow Id of the workflow to run on autocommit.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getAutoCommitWorkflowId {
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getRevisionCount ( [ status ] )
|
=head2 getRevisionCount ( [ status ] )
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,6 @@ sub addPost {
|
||||||
}
|
}
|
||||||
$post->postProcess;
|
$post->postProcess;
|
||||||
$post->getThread->unarchive if ($post->getThread->get("status") eq "archived");
|
$post->getThread->unarchive if ($post->getThread->get("status") eq "archived");
|
||||||
$post->requestCommit;
|
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue