-
Notifications
You must be signed in to change notification settings - Fork 11
/
IsCreator.pm
36 lines (26 loc) · 1.03 KB
/
IsCreator.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package App::Condition::IsCreator;
use strict;
use base qw( Workflow::Condition );
use Log::Log4perl qw( get_logger );
use Workflow::Exception qw( condition_error );
use Workflow::Factory qw( FACTORY );
$App::Condition::IsCreator::VERSION = '1.02';
my ( $log );
my ( $FACTORY );
sub evaluate {
my ( $self, $wf ) = @_;
$log ||= get_logger();
$log->debug( "Trying to execute condition ", ref( $self ) );
# First see that we have both a user and ticket...
my $cond_has_info = FACTORY->get_condition( 'HasUserAndTicket' );
$cond_has_info->evaluate( $wf );
# ...then see that the user is the ticket creator (simple name match)
my $current_user = $wf->context->param( 'current_user' );
my $ticket = $wf->context->param( 'ticket' );
$log->debug( "Current user in the context is '", $current_user, "' ",
"ticket creator is '", $ticket->creator, "'" );
unless ( $ticket->creator eq $current_user ) {
condition_error "User is not the creator of the ticket";
}
}
1;