diff options
author | mark <mark> | 2011-01-01 00:47:17 +0000 |
---|---|---|
committer | mark <mark> | 2011-01-01 00:47:17 +0000 |
commit | edd081af5ca8e5fe87a9aaa8d364a70cc4163e74 (patch) | |
tree | ee52fdd0d514aeb178be91b1da1f14d79e82edbd /FS | |
parent | 903bebf00a555e3b285df70d031f158b5f817a16 (diff) |
limit ticket creation queue dropdowns based on ACL, RT#7778
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/TicketSystem/RT_Internal.pm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/FS/FS/TicketSystem/RT_Internal.pm b/FS/FS/TicketSystem/RT_Internal.pm index befafb847..6ae8881a4 100644 --- a/FS/FS/TicketSystem/RT_Internal.pm +++ b/FS/FS/TicketSystem/RT_Internal.pm @@ -301,6 +301,35 @@ sub correspond_ticket { $Ticket->Correspond( Content => $param{'content'} ); } +=item queues SESSION_HASHREF [, ACL ] + +Retrieve a list of queues. Pass the name of an RT access control right, +such as 'CreateTicket', to return only queues on which the current user +has that right. Otherwise this will return all queues with the 'SeeQueue' +right. + +=cut + +sub queues { + my( $self, $session, $acl ) = @_; + $session = $self->session($session); + + my $showall = $acl ? 0 : 1; + my @result = (); + my $q = new RT::Queues($session->{'CurrentUser'}); + $q->UnLimit; + while (my $queue = $q->Next) { + if ($showall || $queue->CurrentUserHasRight($acl)) { + push @result, { + Id => $queue->Id, + Name => $queue->Name, + Description => $queue->Description, + }; + } + } + return map { $_->{Id} => $_->{Name} } @result; +} + #shameless false laziness w/RT::Interface::Web::AttemptExternalAuth # to get logged into RT from afar sub _web_external_auth { |