summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Action/SetPriority_Local.pm
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/Action/SetPriority_Local.pm')
-rw-r--r--rt/lib/RT/Action/SetPriority_Local.pm47
1 files changed, 47 insertions, 0 deletions
diff --git a/rt/lib/RT/Action/SetPriority_Local.pm b/rt/lib/RT/Action/SetPriority_Local.pm
new file mode 100644
index 000000000..efaadc961
--- /dev/null
+++ b/rt/lib/RT/Action/SetPriority_Local.pm
@@ -0,0 +1,47 @@
+package RT::Action::SetPriority;
+use strict;
+no warnings 'redefine';
+
+# Extension to allow relative priority changes:
+# if Argument is "R" followed by a value, it's
+# relative to current priority.
+sub Commit {
+ my $self = shift;
+ my ($rel, $val);
+ my $arg = $self->Argument;
+ if ( $arg ) {
+ ($rel, $val) = ( $arg =~ /^(r?)(-?\d+)$/i );
+ if (!length($val)) {
+ warn "Bad argument to SetPriority: '$arg'\n";
+ return 0;
+ }
+ }
+ else {
+ my %Rules = $self->Rules;
+ $rel = length($Rules{'inc'}) ? 1 : 0;
+ $val = $Rules{'inc'} || $Rules{'set'};
+ if ($val !~ /^[+-]?\d+$/) {
+ warn "Bad argument to SetPriority: '$val'\n";
+ return 0;
+ }
+ }
+ $val += $self->TicketObj->Priority if $rel;
+ $self->TicketObj->SetPriority($val);
+}
+
+sub Options {
+ (
+ {
+ 'name' => 'set',
+ 'label' => 'Set to value',
+ 'type' => 'text',
+ },
+ {
+ 'name' => 'inc',
+ 'label' => 'Increment by',
+ 'type' => 'text',
+ },
+ )
+}
+
+1;