https://rt-wiki.bestpractical.com/index.php?title=GrantShowTicket&feed=atom&action=historyGrantShowTicket - Revision history2024-03-29T15:49:55ZRevision history for this page on the wikiMediaWiki 1.37.2https://rt-wiki.bestpractical.com/index.php?title=GrantShowTicket&diff=1452&oldid=prevAdmin: 2 revisions imported2016-04-06T20:11:17Z<p>2 revisions imported</p>
<p><b>New page</b></p><div>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. This code makes it possible to view a ticket if the [[AdminCc]] has permission to see a ticket that is depended on by a ticket they could see.<br />
<br />
[[Ticket Local|Ticket_Local]].pm:<br />
<br />
use strict;<br />
no warnings qw(redefine);<br />
<br />
sub HasRight {<br />
my $self = shift;<br />
my %args = (<br />
Right =&gt; undef,<br />
Principal =&gt; undef,<br />
@_<br />
);<br />
<br />
unless ( ( defined $args{'Principal'} ) and ( ref( $args{'Principal'} ) ) )<br />
{<br />
Carp::cluck;<br />
$RT::Logger-&gt;crit("Principal attrib undefined for Ticket::HasRight");<br />
return(undef);<br />
}<br />
<br />
my @Equiv;<br />
if ($args{Right} eq 'ShowTicket') {<br />
my $deps = RT::Tickets-&gt;new($self-&gt;CurrentUser);<br />
<br />
$deps-&gt;LimitDependsOn($self-&gt;Id);<br />
while (my $tick = $deps-&gt;Next) {<br />
push @Equiv, $tick;<br />
}<br />
}<br />
<br />
<br />
return (<br />
$args{'Principal'}-&gt;HasRight(<br />
Object =&gt; $self,<br />
EquivObjects =&gt; \@Equiv,<br />
Right =&gt; $args{'Right'}<br />
)<br />
);<br />
}<br />
<br />
1;<br />
<br />
<br />
This could be extended to recursively add all tickets in a dependency chain. Note that this does not give the user rights to the transaction, but that can be accomplished in a similar manner.<br />
<br />
--Todd Chapman</div>Admin