Skip to content

Commit 7afee33

Browse files
committed
Merge branch '6.0/lifecycle-status-rights' into 6.0-trunk
2 parents 5338745 + 0efd1a6 commit 7afee33

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

lib/RT/Lifecycle.pm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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
463463
Returns hash with description of rights that are defined for
464464
particular transitions.
@@ -468,11 +468,17 @@ particular transitions.
468468
sub 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'} } ) {

lib/RT/Record/Role/Rights.pm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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

t/web/lifecycle_rights.t

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
86106
done_testing;

0 commit comments

Comments
 (0)