getting closer to having approvals work

This commit is contained in:
JT Smith 2006-03-23 00:01:35 +00:00
parent f3a306d21c
commit eef3a0b654
6 changed files with 114 additions and 8 deletions

View file

@ -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;

View file

@ -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]);
}