Skip to content

Commit 0efd1a6

Browse files
committed
Only display status rights that are registered by the current lifecycle
Previously on queue/catalog rights pages, all ticket/asset status rights were displayed, which was confusing and unnecessary.
1 parent 062ef25 commit 0efd1a6

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-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

0 commit comments

Comments
 (0)