File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed
Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -458,7 +458,7 @@ sub CheckRight {
458458 return $to eq ' deleted' ? ' DeleteTicket' : ' ModifyTicket' ;
459459}
460460
461- =head3 RightsDescription [TYPE]
461+ =head3 RightsDescription [TYPE] [LIFECYCLE]
462462
463463Returns hash with description of rights that are defined for
464464particular transitions.
@@ -468,11 +468,17 @@ particular transitions.
468468sub RightsDescription {
469469 my $self = shift ;
470470 my $type = shift ;
471+ my $lifecycle_name = shift ;
471472
472473 $self -> FillCache unless keys %LIFECYCLES_CACHE ;
473474
475+ if ( $lifecycle_name && !exists $LIFECYCLES_CACHE {$lifecycle_name } ) {
476+ RT-> Logger-> warning(" Lifecycle '$lifecycle_name ' not found in LIFECYCLES_CACHE, ignoring" );
477+ undef $lifecycle_name ;
478+ }
479+
474480 my %tmp ;
475- foreach my $lifecycle ( values %LIFECYCLES_CACHE ) {
481+ foreach my $lifecycle ( $lifecycle_name ? $LIFECYCLES_CACHE { $lifecycle_name } : values %LIFECYCLES_CACHE ) {
476482 next unless exists $lifecycle -> {' rights' };
477483 next if $type and $lifecycle -> {type } ne $type ;
478484 while ( my ($transition , $right ) = each %{ $lifecycle -> {' rights' } } ) {
Original file line number Diff line number Diff line change @@ -108,8 +108,13 @@ sub AvailableRights {
108108 my $class = ref ($self ) || $self ;
109109
110110 my %rights ;
111- $rights {$_ -> {Name }} = $_ -> {Description }
112- for values %{$RT::ACE::RIGHTS {$class } || {} };
111+ if ( blessed $self && $self -> DOES(' RT::Record::Role::Lifecycle' ) ) {
112+ %rights = RT::Lifecycle-> RightsDescription( $self -> LifecycleType, $self -> Lifecycle );
113+ }
114+
115+ $rights { $_ -> {Name } } = $_ -> {Description }
116+ for grep { $_ -> {Category } ne ' Status' } values %{ $RT::ACE::RIGHTS {$class } || {} };
117+
113118 return \%rights ;
114119}
115120
Original file line number Diff line number Diff line change @@ -83,4 +83,24 @@ diag 'Test status rights cleanup';
8383 $agent -> text_lacks(' StallTicket' , ' Deleted right is gone on Rights page' );
8484}
8585
86+ diag ' Test that queue rights page only shows rights for its lifecycle' ;
87+ {
88+ # General queue uses 'default' lifecycle which has no custom status rights
89+ # The 'triage' lifecycle defines 'EscalateTicket' right
90+ # That right should NOT appear on General queue's rights page
91+
92+ $agent -> get_ok(' /Admin/Queues/GroupRights.html?id=1' );
93+ $agent -> text_lacks( ' EscalateTicket' , ' Rights from other lifecycles should not appear on queue rights page' );
94+
95+ # Now test a queue using the 'triage' lifecycle DOES show EscalateTicket
96+ my $triage_queue = RT::Test-> load_or_create_queue(
97+ Name => ' triage' ,
98+ Lifecycle => ' triage' ,
99+ );
100+ ok $triage_queue && $triage_queue -> id, ' loaded or created triage queue' ;
101+
102+ $agent -> get_ok(' /Admin/Queues/GroupRights.html?id=' . $triage_queue -> id);
103+ $agent -> text_contains( ' EscalateTicket' , ' Rights from queue lifecycle should appear on queue rights page' );
104+ }
105+
86106done_testing;
You can’t perform that action at this time.
0 commit comments