[rt-users] Identifying Current User

Thomas Akin takin at kennesaw.edu
Fri Jul 19 16:19:44 EDT 2002


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 at kennesaw.edu * www.cybercrime.kennesaw.edu




More information about the rt-users mailing list