Identifying Current User

All,

I’ve just installed RT and have been working on creating a
ScipAction which will give the current user the ticket is
they open a ticket owned by Nobody. I’m having trouble
consistently identifying the current user in my
ScripAction–sometimes it errors out with an unknown
function, sometimes is assigns the correct users (rarely),
sometimes it assigns the user RT_System to the ticket.

Here is my code, please let me know if you have any
suggestions…

#$Id$

This will allow you to change the owner of a ticket to whoever performs

the transaction that triggers it. Is used so that whenever someone opens a

ticket, and the owner is Nobody, they take ownership of that ticket

package RT::Action::ChangeOwner;
use RT::Action::Generic;
@ISA = qw(RT::Action::Generic);
use RT::User;

sub Describe {
my $self = shift;
return(ref $self . " if the current owner is Nobody, this will set the o
wner of the ticket to whoever opened it.");
}

sub Prepare {
#nothing to prepare
return 1;
}

sub Commit {
my $self = shift;
if ($self->TicketObj->OwnerObj->Id == $RT::Nobody->Id) {
return($self->TicketObj->SetOwner($self->CurrentUser->Name, ‘Giv
e’));
} else {
return(undef);
}
}

1;

Thanks!

Thomas

Thomas Akin, CISSP
Director, Southeast Cybercrime Institute
Continuing Education @ Kennesaw State University
takin@kennesaw.edu * www.cybercrime.kennesaw.edu

I’ve just installed RT and have been working on creating a
ScipAction which will give the current user the ticket is
they open a ticket owned by Nobody. I’m having trouble
consistently identifying the current user in my
ScripAction–sometimes it errors out with an unknown
function, sometimes is assigns the correct users (rarely),
sometimes it assigns the user RT_System to the ticket.

When working within Scrips, you are in a slightly different environment
than the rest of RT. Possibly what you are looking for is the Creator of
the current transaction ( $self->TransactionObj->CreatorObj ) to play
with, instead of the CurrentUser.

sub Commit {
my $self = shift;
if ($self->TicketObj->OwnerObj->Id == $RT::Nobody->Id) {
return($self->TicketObj->SetOwner($self->CurrentUser->Name, ‘Giv
e’));
} else {

You probably want to be making sure that that person can actually own
tickets within that queue. Heres one that I prepared earlier;

http://www.amsterdamned.org/~bc/rt/AutoTake.pm (theres also a
readme in that directory)

:wink:

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B             Operations/Security