AutoSetOwnerIfAdminCc

From Request Tracker Wiki
Revision as of 21:06, 13 August 2016 by Tharn (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a variation on AutoSetOwner, it auto-sets the owner of a ticket only if the person doing the correspondence is in the AdminCc watchers:

 1  # Condition: On correspond
 2  # Action: User Defined
 3  # Template: blank
 4 
 5 ## based on http://wiki.bestpractical.com/index.cgi?AutoSetOwner
 6  ## And testcode ~ line 576 of Queue_Overlay.pm (rt3.4.2)
 7  my $Actor = $self->TransactionObj->Creator;
 8  my $Queue = $self->TicketObj->QueueObj;
 9  # if actor is RT_SystemUser then get out of here
10  return 1 if $Actor == $RT::SystemUser->id;
11  # get out unless ticket owner is nobody
12  return 1 unless $self->TicketObj->Owner == $RT::Nobody->id;
13  # get out unless $Actor is not part of AdminCc watchers
14  return 1 unless $Queue->IsWatcher(Type => 'AdminCc', PrincipalId => $Actor);
15  # do the actual 'status update'
16  my ($status, $msg) = $self->TicketObj->SetOwner( $Actor );
17  unless( $status ) {
18   $RT::Logger->warning( "can't set ticket owner to $Actor: $msg" );
19   return undef;
20  }
21  return 1;