[rt-users] RT Hack: Propogate permission to dependent tickets.
Todd Chapman
todd at chaka.net
Fri Apr 1 15:43:42 EST 2005
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
More information about the rt-users
mailing list