RT# 75322 Add ticket action Quiet Resolve
[freeside.git] / rt / lib / RT / Condition / StatusChangeQuietResolve.pm
1 package RT::Condition::StatusChangeQuietResolve;
2 use base 'RT::Condition';
3 use strict;
4 use warnings;
5
6 =head2 DESCRIPTION
7
8 This condition allows for muting of resolution notifications when
9 combined with the ticket status 'resolved_quiet'
10
11 If status has been updated as 'resolved_quiet', this condition
12 will block notification, and update ticket status to 'resolved'
13
14 If status has been updated as 'resolved', this condition
15 will block notification only if the previous ticket status
16 had been 'resolved_quiet'
17
18 =cut
19
20 sub IsApplicable {
21   my $self = shift;
22   my $txn = $self->TransactionObj;
23   my ($type, $field) = ($txn->Type, $txn->Field);
24
25   return 0
26     unless $type eq 'Status'
27     || ($type eq 'Set' && $field eq 'Status');
28
29   return 0
30     unless $txn->NewValue eq 'resolved'
31     || $txn->NewValue eq 'resolved_quiet';
32
33   my $ticket = $self->TicketObj;
34
35   if ($txn->NewValue eq 'resolved_quiet') {
36     $ticket->SetStatus('resolved');
37     return 0;
38   }
39   elsif ($txn->NewValue eq 'resolved' && $txn->OldValue eq 'resolved_quiet') {
40     return 0;
41   }
42
43   return 1;
44 }
45
46 RT::Base->_ImportOverlays();
47
48 1;