[freeside-commits] freeside/FS/FS/TicketSystem RT_Internal.pm, 1.20, 1.21

Mark Wells mark at wavetail.420.am
Fri Dec 31 16:47:02 PST 2010


Update of /home/cvs/cvsroot/freeside/FS/FS/TicketSystem
In directory wavetail.420.am:/tmp/cvs-serv23310/FS/FS/TicketSystem

Modified Files:
	RT_Internal.pm 
Log Message:
limit ticket creation queue dropdowns based on ACL, RT#7778

Index: RT_Internal.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem/RT_Internal.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -w -d -r1.20 -r1.21
--- RT_Internal.pm	23 Dec 2010 17:52:21 -0000	1.20
+++ RT_Internal.pm	1 Jan 2011 00:46:59 -0000	1.21
@@ -301,6 +301,35 @@
   $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 {



More information about the freeside-commits mailing list