AllowSuperUserToReassignTickets
Shevek and I got a little annoyed when we found that a superuser could not reassign tickets arbitrarilly (one of the things I tend to to rather more often than I would like is to assign the ticket to the wrong person the first time around), so after much discussion with Jesse and some poking from Shevek, our copy of lib/RT/Ticket_Local.pm now contains:
use strict; use Hook::LexWrap; wrap 'SetOwner', pre => sub { $_[2] = 'Force' if $_[0]->CurrentUserHasRight('SuperUser'); }; 1;
which should allow any SuperUser to reassign tickets arbitrarily. I have tested it after we restarted apache and it seems to be working fine. (we are currently using 3.2.)
Zaniyah
This worked for us as advertised, but now when anyone attempts to use the "take" function of an unowned ticket we get the following error:
Modification of a read-only value attempted at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 5. Trace begun at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Exceptions.pm line 131 HTML::Mason::Exceptions::rethrow_exception('Modification of a read-only value attempted at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 5.^J') called at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 5 RT::Ticket::__ANON__('RT::Ticket=HASH(0xb1210f8)', 26, 'Take', 'ARRAY(0xb125d30)') called at /usr/local/lib/perl5/site_perl/5.8.6/Hook/LexWrap.pm line 39 Hook::LexWrap::__ANON__('RT::Ticket=HASH(0xb1210f8)', 26, 'Take') called at /usr/local/rt3/lib/RT/Ticket_Overlay.pm line 3030 RT::Ticket::Take('RT::Ticket=HASH(0xb1210f8)') called at /usr/local/rt3/share/html/Ticket/Display.html line 122 HTML::Mason::Commands::__ANON__('Action', 'Take', 'id', 7322, 'Action', 'Take', 'id', 7322) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Component.pm line 136 HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0xb0b4050)', 'Action', 'Take', 'id', 7322, 'Action', 'Take', 'id', 7322) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 1074 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 1068 HTML::Mason::Request::comp(undef, undef, 'Action', 'Take', 'id', 7322, 'Action', 'Take', 'id', 7322) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 760 HTML::Mason::Request::call_next('HTML::Mason::Request::ApacheHandler=HASH(0xae8d704)', 'Action', 'Take', 'id', 7322) called at /usr/local/rt3/share/html/autohandler line 215 HTML::Mason::Commands::__ANON__('Action', 'Take', 'id', 7322) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Component.pm line 136 HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0xb092020)', 'Action', 'Take', 'id', 7322) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 1069 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 1068 HTML::Mason::Request::comp(undef, undef, undef, 'Action', 'Take', 'id', 7322) called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 338 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 338 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/Request.pm line 297 HTML::Mason::Request::exec('HTML::Mason::Request::ApacheHandler=HASH(0xae8d704)') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/ApacheHandler.pm line 134 eval {...} at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/ApacheHandler.pm line 134 HTML::Mason::Request::ApacheHandler::exec('HTML::Mason::Request::ApacheHandler=HASH(0xae8d704)') called at /usr/local/lib/perl5/site_perl/5.8.6/HTML/Mason/ApacheHandler.pm line 827 HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler=HASH(0xad88e14)', 'Apache=SCALAR(0xacf4638)') called at /usr/local/rt3/bin/webmux.pl line 124 eval {...} at /usr/local/rt3/bin/webmux.pl line 124 RT::Mason::handler('Apache=SCALAR(0xacf4638)') called at /dev/null line 0 eval {...} at /dev/null line 0
Any thoughts? We're on FreeBSD 5.4, using RT 3.4.2.
Thanks
Try this:
use strict; use Hook::LexWrap; wrap 'SetOwner', pre => sub { my $Self = $_[2]; my $Stuff = $_[0]; if ( ( $Type ne 'Take' ) and ( $Type ne 'Steal' ) ) { if ( $Self->OwnerObj->Id ne $Self->CurrentUser->Id and $Self->CurrentUserHasRight('SuperUser')){ $_[2] = 'Force' }}} 1;
Taan
Taan,
Thanks. We tried that, but unfortunately it didn't work. Here is the error we got:
Number found where operator expected at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 12, near "1" (Missing semicolon on previous line?) [Thu Jan 4 11:01:21 2007] [error] Global symbol "$Type" requires explicit package name at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 7.\nGlobal symbol "$Type" requires explicit package name at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 7.\nsyntax error at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 12, near "1"\nCompilation failed in require at (eval 238) line 3.\nCompilation failed in require at /usr/local/rt3/lib/RT/Tickets.pm line 73.\nBEGIN failed--compilation aborted at /usr/local/rt3/lib/RT/Tickets.pm line 73.\nCompilation failed in require at /usr/local/rt3/lib/RT.pm line 305.\n
We played with putting semicolons in different positions, and successfully got rid of the semicolon error, but still had a problem with global symbol $Type errors.
Do you have any more thoughts?
Recent upgrade from 3.4.2 to 3.8.2 broke this. Now I get this in my logs:
Can't modify constant item in scalar assignment at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 4, near ">" Bareword "pre" not allowed while "strict subs" in use at /usr/local/rt3/local/lib/RT/Ticket_Local.pm line 4. Compilation failed in require at (eval 1184) line 3. Compilation failed in require at /usr/local/rt3/lib/RT/Tickets.pm line 76. BEGIN failed--compilation aborted at /usr/local/rt3/lib/RT/Tickets.pm line 76. Compilation failed in require at /usr/local/rt3/lib/RT.pm line 423. [Thu Feb 5 11:59:38 2009] [warn] FastCGI: server "/usr/local/rt3/bin/mason_handler.fcgi" (pid 3631) terminated by calling exit with status '255' [Thu Feb 5 11:59:38 2009] [warn] FastCGI: server "/usr/local/rt3/bin/mason_handler.fcgi" restarted (pid 3654)
Any thoughts on how to fix this? Thank you.
Not a pretty/good soulution, but it works (3.8.7. on a Xubuntu Perl MYSQL Apache2)
Edit Ticket_Overlay.pm in /your/rt/directory/lib/RT/
FROM:
# If we're not stealing and the ticket has an owner and it's not # the current user if ( $Type ne 'Steal' and $Type ne 'Force' and $OldOwnerObj->Id != $RT::Nobody->Id and $OldOwnerObj->Id != $self->CurrentUser->Id) { $RT::Handle->Rollback(); return ( 0, $self->loc("You can only take tickets that are unowned") ) if $NewOwnerObj->id == $self->CurrentUser->id; return ( 0, $self->loc("You can only reassign tickets that you own or that are unowned" ) ); }
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv TO:
# If we're not stealing and the ticket has an owner and it's not # the current user if ( $Type ne 'Steal' and $Type ne 'Force' and $OldOwnerObj->Id != $RT::Nobody->Id and $OldOwnerObj->Id != $self->CurrentUser->Id) {
unless ( $self->CurrentUserHasRight('SuperUser') ) {
$RT::Handle->Rollback(); return ( 0, $self->loc("You can only take tickets that are unowned") ) if $NewOwnerObj->id == $self->CurrentUser->id; return ( 0, $self->loc("You can only reassign tickets that you own or that are unowned" ) ); } }
If anyone could, it would be a nice thing to make a patch/callback of this. DanielOT