RT Hack: Propogate permission to dependent tickets

In our organization we often have tickets that are linked with
a dependency link. The role AdminCCs is given permission to
see a ticket, but they could not see other tickets that their
specific ticket depended on.

I had some old code that made it possible to view a ticket
if the AdminCc had permission to see a ticket that was depended
on by a ticket they could see.

Today I had a inspiration for doing this more cleanly. Here
is the simpler and much faster code:

Ticket_Overlay.pm:

sub HasRight {
my $self = shift;
my %args = (
Right => undef,
Principal => undef,
@_
);

unless ( ( defined $args{'Principal'} ) and ( ref( $args{'Principal'} ) ) )
{
    Carp::cluck;
    $RT::Logger->crit("Principal attrib undefined for Ticket::HasRight");
    return(undef);
}

my @Equiv;
if ($args{Right} = 'ShowTicket') {
    my $deps = RT::Tickets->new($self->CurrentUser);

    $deps->LimitDependsOn($self->Id);
    while (my $tick = $deps->Next) {
        push @Equiv, $tick;
    }
}


return (
    $args{'Principal'}->HasRight(
        Object => $self,
        EquivObjects => \@Equiv,
        Right     => $args{'Right'}
      )
);

}

End code

This could be extended to recursively add all tickets in a
dependency chain.

I’ll add this to the wiki.

-Todd

Correction, the proper file would be Ticket_Local.pm. I knew that! :slight_smile:

-Todd