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 ();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditForm ()
|
||||
|
||||
Creates and returns a tabform to edit parameters of an Asset.
|
||||
|
|
|
|||
|
|
@ -301,6 +301,12 @@ sub formatContent {
|
|||
return $msg;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getAutoCommitWorkflowId {
|
||||
my $self = shift;
|
||||
return $self->getThread->getParent->get("approvalWorkflow");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getAvatarUrl ( )
|
||||
|
|
@ -749,20 +755,6 @@ sub processPropertiesFromFormPost {
|
|||
$self->getThread->subscribe if ($self->session->form->process("subscribe"));
|
||||
delete $self->{_storageLocation};
|
||||
$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 {
|
||||
my $self = shift;
|
||||
|
|
@ -231,7 +238,7 @@ sub processPropertiesFromFormPost {
|
|||
isHidden => 1,
|
||||
actionTakenBy => $self->session->user->userId,
|
||||
actionTaken => $actionTaken});
|
||||
if ($self->canAdminister) {
|
||||
if ($self->getWiki->canAdminister) {
|
||||
$self->update({isProtected => $self->session->form("isProtected")});
|
||||
}
|
||||
delete $self->{_storageLocation};
|
||||
|
|
@ -249,20 +256,6 @@ sub processPropertiesFromFormPost {
|
|||
$size += $storage->getFileSize($file);
|
||||
}
|
||||
$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 {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient unless $self->canAdminister;
|
||||
return $self->session->privilege->insufficient unless $self->getWiki->canAdminister;
|
||||
$self->trash;
|
||||
$self->session->asset($self->getParent);
|
||||
return $self->getParent->www_view;
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ sub addChild {
|
|||
$self->session->db->beginTransaction;
|
||||
$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}]);
|
||||
my $temp = WebGUI::Asset->newByPropertyHashRef($self->session,{
|
||||
assetId=>$id,
|
||||
className=>$properties->{className}
|
||||
});
|
||||
my $newAsset = $temp->addRevision($properties,$now);
|
||||
$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->session->http->setStatus(201,"Asset Creation Successful");
|
||||
return $newAsset;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ sub addRevision {
|
|||
my $self = shift;
|
||||
my $properties = shift;
|
||||
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,
|
||||
ownerUserId, groupIdEdit, groupIdView) values (?, ?, ?, ?, 'pending', ?, '3','3','7')",
|
||||
[$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->commit;
|
||||
my $newVersion = WebGUI::Asset->new($self->session,$self->getId, $self->get("className"), $now);
|
||||
$newVersion->updateHistory("created revision");
|
||||
$newVersion->update($self->get);
|
||||
$newVersion->setVersionLock;
|
||||
$properties->{status} = 'pending';
|
||||
$newVersion->update($properties);
|
||||
$workingTag->requestCommit if ($autoCommitId);
|
||||
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 ] )
|
||||
|
|
|
|||
|
|
@ -129,7 +129,6 @@ sub addPost {
|
|||
}
|
||||
$post->postProcess;
|
||||
$post->getThread->unarchive if ($post->getThread->get("status") eq "archived");
|
||||
$post->requestCommit;
|
||||
return $post;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue