[rt-users] Getting owner to change when replying

Jamie Wilkinson jaq at spacepants.org
Thu Jun 12 22:16:58 EDT 2003


This one time, at band camp, jennyw wrote:
>I've noticed that when a user replies to a new ticket, they do not
>become the owner -- it remains owned by nobody. Is there a way to change 
>this so that if someone takes an action on a ticket that's owned by 
>nobody, they own it?

I've got a patch that adds an AutoTake.pm action, then all you need to do is
do a couple of database inserts to enable the new script as a separate
action/scrip.

Apply the attachment, then perform the following queries on your database:

 insert into scripactions (name, description, execmodule, creator, created,
 lastupdatedby, lastupdated) values ('Assign Tickets', 'Assign a ticket on
 first correspondance', 'AutoTake', 1, current_timestamp, 1, current_timestamp);

 insert into scrips (description, scripcondition, scripaction, stage, queue,
 template, creator, created, lastupdatedby, lastupdated) values ('AutoTake',
 3, ID of the above scripaction, 'TransactionCreate', 0, 1, 1,
 current_timestamp, 1, current_timestamp);

Remember to get the ID of the scripaction from the first query for the
scripaction column in the second query.

-- 
jaq at spacepants.org                           http://spacepants.org/jaq.gpg
-------------- next part --------------
Index: lib/RT/Action/AutoTake.pm
--- lib/RT/Action/AutoTake.pm
+++ lib/RT/Action/AutoTake.pm
***************
--- 0 ****
+++ 1,81 ----
+ # BEGIN LICENSE BLOCK
+ #
+ # Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
+ # Copyright (c) 2003 Jamie Wilkinson <jaq at spacepants.org>
+ #
+ # (Except where explictly superceded by other copyright notices)
+ #
+ # This work is made available to you under the terms of Version 2 of
+ # the GNU General Public License. A copy of that license should have
+ # been provided with this software, but in any event can be snarfed
+ # from www.gnu.org.
+ #
+ # This work is distributed in the hope that it will be useful, but
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ # General Public License for more details.
+ #
+ # Unless otherwise specified, all modifications, corrections or
+ # extensions to this work which alter its source code become the
+ # property of Best Practical Solutions, LLC when submitted for
+ # inclusion in the work.
+ #
+ # END LICENSE BLOCK
+ 
+ # automatically assign a ticket to the current user if
+ # * ticket is owned by Nobody
+ # * user is privileged
+ # * user can own tickets in this queue
+ 
+ # Based on Bruce Campbell's AutoTake.pm module for RT2
+ 
+ package RT::Action::AutoTake;
+ require RT::Action::Generic;
+ 
+ use strict;
+ use vars qw/@ISA/;
+ @ISA=qw(RT::Action::Generic);
+ 
+ sub Describe  {
+   my $self = shift;
+   return (ref $self );
+ }
+ 
+ sub Prepare {
+   my $self = shift;
+ 
+   my $retval = undef;
+ 
+   if (defined($delf->TicketObj->OwnerObj->id)) {
+     if ($self->TicketObj->OwnerObj->id == $RT::Nobody->id) {
+       $retval = 1;
+     }
+   } else {
+     # undefined, must be Nobody
+     $retval = 1;
+   }
+   return($retval);
+ }
+ 
+ sub Commit {
+   my $self = shift;
+ 
+   my $retval = undef;
+ 
+   # are they priv'd?
+   if ($self->TransactionObj->CreatorObj->Privileged && $self->TransactionObj->CreatorObj->id != $RT::Nobody->id) {
+     # can they own tickets?
+     if ($self->TransactionObj->CreatorObj->HasQueueRight(QueueObj => $self->TicketObj->QueueObj,
+ 							 Right => 'OwnTicket')) {
+       $retval = $self->TicketObj->SetOwner($self->TransactionObj->CreatorObj->id);
+     }
+   }
+   return($retval);
+ }
+ 
+ eval "require RT::Action::AutoTake_Vendor";
+ die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/AutoOpen_Vendor.pm});
+ eval "require RT::Action::AutoTake_Local";
+ die $@ if ($@ && $@ !~ qr{^Can't locate RT/Action/AutoOpen_Local.pm});
+ 
+ 1;


More information about the rt-users mailing list