AutoSetOwnerIfAdminCc: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
m (2 revisions imported)
 
mNo edit summary
 
Line 1: Line 1:
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:
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:


<nowiki># Condition: On correspond
<syntaxhighlight lang="perl" line="1" >
# Condition: On correspond
  # Action: User Defined
  # Action: User Defined
  # Template: blank
  # Template: blank
Line 22: Line 23:
  }
  }
  return 1;
  return 1;
  </nowiki>
  </syntaxhighlight>

Latest revision as of 20:06, 13 August 2016

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-&gt;TransactionObj-&gt;Creator;
 my $Queue = $self-&gt;TicketObj-&gt;QueueObj;
 # if actor is RT_SystemUser then get out of here
 return 1 if $Actor == $RT::SystemUser-&gt;id;
 # get out unless ticket owner is nobody
 return 1 unless $self-&gt;TicketObj-&gt;Owner == $RT::Nobody-&gt;id;
 # get out unless $Actor is not part of AdminCc watchers
 return 1 unless $Queue-&gt;IsWatcher(Type =&gt; 'AdminCc', PrincipalId =&gt; $Actor);
 # do the actual 'status update'
 my ($status, $msg) = $self-&gt;TicketObj-&gt;SetOwner( $Actor );
 unless( $status ) {
  $RT::Logger-&gt;warning( "can't set ticket owner to $Actor: $msg" );
  return undef;
 }
 return 1;