AutoSetOwnerIfAdminCc: Difference between revisions
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: | ||
<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; | ||
</ | </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->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;