rename WebExternalAutoInfo to WebRemoteUserAutocreateInfo, #37318
[freeside.git] / rt / lib / RT / Action / SetPriority_Local.pm
1 package RT::Action::SetPriority;
2 use strict;
3 no warnings 'redefine';
4
5 # Extension to allow relative priority changes:
6 # if Argument is "R" followed by a value, it's 
7 # relative to current priority.
8 sub Commit {
9     my $self = shift;
10     my ($rel, $val);
11     my $arg = $self->Argument;
12     if ( $arg ) {
13       ($rel, $val) = ( $arg =~ /^(r?)(-?\d+)$/i );
14       if (!length($val)) {
15         warn "Bad argument to SetPriority: '$arg'\n";
16         return 0;
17       }
18     }
19     else {
20       my %Rules = $self->Rules;
21       $rel = length($Rules{'inc'}) ? 1 : 0;
22       $val = $Rules{'inc'} || $Rules{'set'};
23       if ($val !~ /^[+-]?\d+$/) {
24         warn "Bad argument to SetPriority: '$val'\n";
25         return 0;
26       }
27     }
28     $val += $self->TicketObj->Priority if $rel;
29     $self->TicketObj->SetPriority($val);
30 }
31
32 sub Options {
33   (
34     {
35       'name'    => 'set',
36       'label'   => 'Set to value',
37       'type'    => 'text',
38     },
39     {
40       'name'    => 'inc',
41       'label'   => 'Increment by',
42       'type'    => 'text',
43     },
44   )
45 }
46
47 1;