getting closer to having approvals work
This commit is contained in:
parent
f3a306d21c
commit
eef3a0b654
6 changed files with 114 additions and 8 deletions
|
|
@ -82,6 +82,7 @@ sub getOperations {
|
|||
'commitVersionTag' => 'WebGUI::Operation::VersionTag',
|
||||
'commitVersionTagConfirm' => 'WebGUI::Operation::VersionTag',
|
||||
'manageCommittedVersions' => 'WebGUI::Operation::VersionTag',
|
||||
'approveVersionTag' => 'WebGUI::Operation::VersionTag',
|
||||
'manageVersions' => 'WebGUI::Operation::VersionTag',
|
||||
'manageRevisionsInTag' => 'WebGUI::Operation::VersionTag',
|
||||
'rollbackVersionTag' => 'WebGUI::Operation::VersionTag',
|
||||
|
|
|
|||
|
|
@ -40,6 +40,29 @@ These methods are available from this class:
|
|||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editVersionTag ( session )
|
||||
|
||||
Sets an approval for a version tag.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_approveVersionTag {
|
||||
my $session = shift;
|
||||
my $tag = WebGUI::VersionTag->new($session, $session->form->param("tagId"));
|
||||
my $instance = $tag->getWorkflowInstance;
|
||||
my $activity = $instance->getNextActivity;
|
||||
return $session->privilege->insufficient() unless ($session->user->isInGroup($activity->get("groupToApprove")));
|
||||
if ($session->form->process("status", "selectBox") eq "approved") {
|
||||
$activity->setApproved($instance);
|
||||
} else {
|
||||
$activity->setDenied($instance);
|
||||
}
|
||||
$tag->set({comments=>$session->form->process("comments", "textarea")});
|
||||
return www_manageVersions($session);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editVersionTag ( session, [ tagId ] )
|
||||
|
|
|
|||
|
|
@ -150,6 +150,19 @@ sub getId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getWorkflowInstance ( )
|
||||
|
||||
Returns a reference to the workflow instance attached to this version tag if any.
|
||||
|
||||
=cut
|
||||
|
||||
sub getWorkflowInstance {
|
||||
my $self = shift;
|
||||
return WebGUI::Workflow::Instance->new($self->session, $self->get("workflowInstanceId"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getWorking ( session, noCreate )
|
||||
|
||||
This is a class method. Returns the current working version tag for this user as set by setWorking(). If there is no current working tag an autotag will be created and assigned as the working tag for this user.
|
||||
|
|
@ -245,6 +258,8 @@ sub requestCommit {
|
|||
methodName=>"new",
|
||||
parameters=>$self->getId
|
||||
});
|
||||
$self->{_data}{workflowInstanceId} = $instance->getId;
|
||||
$self->session->db->setRow("assetVersionTag","tagId",$self->{_data});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -103,12 +103,15 @@ sub execute {
|
|||
message=>join("\n\n",$self->get("message"),
|
||||
$self->session->url->page("op=manageRevisionsInTag;workflowInstanceId=".$instance->getId.";tagId=".$versionTag->getId),
|
||||
$versionTag->get('name'), $versionTag->get("comments")),
|
||||
groupId=>$self->get("groupToApprove")
|
||||
groupId=>$self->get("groupToApprove"),
|
||||
status=>'pending'
|
||||
});
|
||||
$instance->setScratch("messageId",$message->getId);
|
||||
$instance->setScratch("status","notified");
|
||||
return $self->WAITING;
|
||||
} elsif ($instance->getScratch("status") eq "denied") {
|
||||
my $message = $inbox->getMessage($instance->getScratch("messageId"));
|
||||
$message->setCompleted;
|
||||
my $newInstance = WebGUI::Workflow::Instance->create($self->session, {
|
||||
workflowId=>$self->get("doOnDeny"),
|
||||
methodName=>$instance->get("methodName"),
|
||||
|
|
@ -129,6 +132,41 @@ sub execute {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setApproved ( insstance )
|
||||
|
||||
Marks this approved so that the workflow engine knows it can continue on as approved.
|
||||
|
||||
=head3 instance
|
||||
|
||||
A reference to the instance that you wish to set this approved.
|
||||
|
||||
=cut
|
||||
|
||||
sub setApproved {
|
||||
my $self = shift;
|
||||
my $instance = shift;
|
||||
$instance->setScratch("status","approved");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setDenied ( insstance )
|
||||
|
||||
Marks this approved so that the workflow engine knows it can continue on as denied.
|
||||
|
||||
=head3 instance
|
||||
|
||||
A reference to the instance that you wish to set this denied.
|
||||
|
||||
=cut
|
||||
|
||||
sub setDenied {
|
||||
my $self = shift;
|
||||
my $instance = shift;
|
||||
$instance->setScratch("status","denied");
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ sub deleteScratch {
|
|||
my $self = shift;
|
||||
my $name = shift;
|
||||
delete $self->{_scratch}{$name};
|
||||
$self->session->db->write("delete from WorkflowInstanceScratch where instanceId=?", [$self->getId]);
|
||||
$self->session->db->write("delete from WorkflowInstanceScratch where instanceId=? and name=?", [$self->getId, $name]);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -142,6 +142,34 @@ sub get {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getId ( )
|
||||
|
||||
Returns the ID of this instance.
|
||||
|
||||
=cut
|
||||
|
||||
sub getId {
|
||||
my $self = shift;
|
||||
return $self->{_id};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNextActivity ( )
|
||||
|
||||
Returns a reference to the next activity in this workflow from the current position of this instance.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNextActivity {
|
||||
my $self = shift;
|
||||
my $workflow = $self->getWorkflow;
|
||||
return undef unless defined $workflow;
|
||||
return $workflow->getNextActivity($self->get("currentActivityId"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getScratch ( name )
|
||||
|
||||
Returns the value for a given scratch variable.
|
||||
|
|
@ -159,15 +187,15 @@ sub getScratch {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getId ( )
|
||||
=head2 getWorkflow ( )
|
||||
|
||||
Returns the ID of this instance.
|
||||
Returns a reference to the workflow object this instance is associated with.
|
||||
|
||||
=cut
|
||||
|
||||
sub getId {
|
||||
sub getWorkflow {
|
||||
my $self = shift;
|
||||
return $self->{_id};
|
||||
return WebGUI::Workflow->new($self->session, $self->get("workflowId"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -212,7 +240,7 @@ Executes the next iteration in this workflow. Returns a status code based upon w
|
|||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
my $workflow = WebGUI::Workflow->new($self->session, $self->get("workflowId"));
|
||||
my $workflow = $self->getWorkflow;
|
||||
return "undefined" unless (defined $workflow);
|
||||
return "disabled" unless ($workflow->get("enabled"));
|
||||
my $activity = $workflow->getNextActivity($self->get("currentActivityId"));
|
||||
|
|
@ -339,7 +367,7 @@ sub setScratch {
|
|||
my $name = shift;
|
||||
my $value = shift;
|
||||
delete $self->{_scratch};
|
||||
$self->session->write("replace into WorkflowInstanceScratch (instanceId, name, value) values (?,?,?)", [$self->getId, $name, $value]);
|
||||
$self->session->db->write("replace into WorkflowInstanceScratch (instanceId, name, value) values (?,?,?)", [$self->getId, $name, $value]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue