Difference between revisions of "AutoSetOwnerIfAdminCc"

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

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