[rt-users] Scrips firing at will - huh?

Ruslan Zakirov ruslan.zakirov at gmail.com
Mon Dec 12 10:35:45 EST 2005


AFAIK $ticket->CurrentUser is $RT::SystemUser in scrips. It's
described in WritingCustomScrips page on the wiki.

On 12/12/05, Leif Nixon <nixon at nsc.liu.se> wrote:
> Stephen Turner <sturner at MIT.EDU> writes:
>
> > I was wondering if moving the code to the 'Custom action cleanup code'
> > section would solve the problem? You may also need to put "return 1;"
> > into the Custom action prep section.
>
> Yes, it seems it does.
>
> However, now I have another problem. The problem itself is mainly
> cosmetic, but I'd like to understand what's causing it.
>
> In the action prep section I now have a check for "this ticket is
> owned by Nobody" and also a check for
> $self->TicketObj->CurrentUserHasRight('OwnTicket').
>
> The action cleanup section now contains:
>
>   my $ticket = $self->TicketObj;
>   my $Actor = $self->TransactionObj->CreatorObj->Id;
>
>   if ($ticket->CurrentUserHasRight('OwnTicket')) { # Debug message
>     $RT::Logger->info("The user seems to be allowed to own tickets");
>   }
>
>   if ($Actor != $ticket->OwnerObj->Id) {
>     $RT::Logger->info("Auto assign ticket #". $ticket->id ." to user #". $Actor );
>
>     my ($status, $msg) = $ticket->SetOwner($Actor);
>     unless( $status ) {
>        $RT::Logger->error("AutoTake error: $msg");
>        return(undef);
>     }
>   }
>
> Seems simple enough, but if a non-privileged user replies to an
> unowned ticket I get the following in the log:
>
>   Dec 12 16:03:49 d116 RT: The user seems to be allowed to own tickets ((eval 449) :5)
>   Dec 12 16:03:49 d116 RT: Auto assign ticket #5 to user #28 ((eval 449):8)
>   Dec 12 16:03:49 d116 RT: AutoTake error: That user may not own tickets in that queue ((eval 449):12)
>
> Why does $ticket->CurrentUserHasRight('OwnTicket') return true for a
> non-privileged user? Should I dig up the queue and call
> CurrentUserHasRight() on that instead?
>
> --
> Leif Nixon                       -            Systems expert
> ------------------------------------------------------------
> National Supercomputer Centre    -      Linkoping University
> ------------------------------------------------------------
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Be sure to check out the RT Wiki at http://wiki.bestpractical.com
>
> Download a free sample chapter of RT Essentials from O'Reilly Media at http://rtbook.bestpractical.com
>
> WE'RE COMING TO YOUR TOWN SOON - RT Training in Amsterdam, Boston and
> San Francisco - Find out more at http://bestpractical.com/services/training.html
>


--
Best regards, Ruslan.



More information about the rt-users mailing list