X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FElements%2FSelectStatus;h=33d20643c3a1511e2c5345f4f67c52fa1174e760;hb=HEAD;hp=7e3e0cc67c7586587d8fa4f4e0347b7b84010cdc;hpb=7588a4ac90a9b07c08a3107cd1107d773be1c991;p=freeside.git diff --git a/rt/share/html/Elements/SelectStatus b/rt/share/html/Elements/SelectStatus index 7e3e0cc67..33d20643c 100755 --- a/rt/share/html/Elements/SelectStatus +++ b/rt/share/html/Elements/SelectStatus @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -55,7 +55,7 @@ % } % foreach my $status (@{$statuses_by_lifecycle{$lifecycle}}) { -% next if ($SkipDeleted && $status eq 'deleted'); +% next if ($SkipDeleted && lc $status eq 'deleted'); % my $selected = defined $Default && $status eq $Default ? 'selected="selected"' : ''; % } @@ -70,39 +70,35 @@ my %statuses_by_lifecycle; if ( @Statuses ) { $statuses_by_lifecycle{''} = \@Statuses; -} -elsif ( $TicketObj ) { - my @status; - my $current = $TicketObj->Status; - push @status, $current; - - my $lifecycle = $TicketObj->QueueObj->Lifecycle; +} else { + if ( $Object ) { + my $lifecycle = $Object->LifecycleObj; + if ($Object->_Accessible("Status", "read")) { + my $current = $Object->Status; + my @status; + push @status, $current; - my %has = (); - foreach my $next ( $lifecycle->Transitions( $current ) ) { - my $check = $lifecycle->CheckRight( $current => $next ); - $has{ $check } = $TicketObj->CurrentUserHasRight( $check ) - unless exists $has{ $check }; - push @status, $next if $has{ $check }; + my %has = (); + foreach my $next ( $lifecycle->Transitions( $current ) ) { + my $check = $lifecycle->CheckRight( $current => $next ); + $has{ $check } = $Object->CurrentUserHasRight( $check ) + unless exists $has{ $check }; + push @status, $next if $has{ $check }; + } + $statuses_by_lifecycle{$lifecycle->Name} = \@status; + } else { + $statuses_by_lifecycle{$lifecycle->Name} = [ $lifecycle->Transitions('') ]; + } } - $statuses_by_lifecycle{$lifecycle->Name} = \@status; -} -elsif ( $QueueObj ) { - my $lifecycle = $QueueObj->Lifecycle; - $statuses_by_lifecycle{$lifecycle->Name} = [ $lifecycle->Transitions('') ]; -} elsif ( %Queues ) { - for my $id (keys %Queues) { - my $queue = RT::Queue->new($session{'CurrentUser'}); - $queue->Load($id); - if ($queue->id) { - my $lifecycle = $queue->Lifecycle; + for my $lifecycle ( @Lifecycles ) { + $statuses_by_lifecycle{$lifecycle->Name} ||= [ $lifecycle->Valid ]; + } + + if (not keys %statuses_by_lifecycle) { + for my $lifecycle (map { RT::Lifecycle->Load($_) } RT::Lifecycle->List($Type)) { $statuses_by_lifecycle{$lifecycle->Name} = [ $lifecycle->Valid ]; } } -} else { - for my $lifecycle (map { RT::Lifecycle->Load($_) } RT::Lifecycle->List) { - $statuses_by_lifecycle{$lifecycle->Name} = [ $lifecycle->Valid ]; - } } if (keys %statuses_by_lifecycle) { @@ -132,11 +128,11 @@ my $group_by_lifecycle = keys %statuses_by_lifecycle > 1; <%ARGS> $Name => undef +$Type => undef, @Statuses => () -$TicketObj => undef -$QueueObj => undef -%Queues => () +$Object => undef, +@Lifecycles => (), $Default => '' $SkipDeleted => 0