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
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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:

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