[Rt-commit] r3567 - in rt/branches/3.5-TESTING: . html/Elements

trs at bestpractical.com trs at bestpractical.com
Sun Jul 31 12:27:42 EDT 2005


Author: trs
Date: Sun Jul 31 12:27:38 2005
New Revision: 3567

Modified:
   rt/branches/3.5-TESTING/   (props changed)
   rt/branches/3.5-TESTING/html/Elements/SelectNewTicketQueue
   rt/branches/3.5-TESTING/html/Elements/SelectQueue
Log:
 r5491 at wintermute:  tom | 2005-07-31 12:25:15 -0400
 * Cleaned up SelectQueue and added caching for performance
 * Made SelectNewTicketQueue use SelectQueue to be standard


Modified: rt/branches/3.5-TESTING/html/Elements/SelectNewTicketQueue
==============================================================================
--- rt/branches/3.5-TESTING/html/Elements/SelectNewTicketQueue	(original)
+++ rt/branches/3.5-TESTING/html/Elements/SelectNewTicketQueue	Sun Jul 31 12:27:38 2005
@@ -44,31 +44,5 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 <label accesskey="9">
-<select name="<%$Name%>" class="field">
-% foreach my $queue (@{$session{'create_in_queues'}}) {
-<option value="<%$queue->{'id'}%>" <%($Default && ($queue->{'id'} == $Default)) ? 'SELECTED': ''%>><%$queue->{'Name'}%><%($Verbose && $queue->{'Description'} )? "(".$queue->{'Description'}.")": ''%></option>
-% }
-</select>
+  <& /Elements/SelectQueue, Name => 'Queue', %ARGS, ShowNullOption => 0, ShowAllQueues => 0 &>
 </label>
-
-<%INIT>
-unless ($session{'create_in_queues'}) { 
-
-@{$session{'create_in_queues'}} = ();
-my $q=new RT::Queues($session{'CurrentUser'});
-$q->UnLimit;
-while (my $queue=$q->Next) {
-        if ($queue->CurrentUserHasRight('CreateTicket')) {
-                my $ds = { Name => $queue->Name, Description => $queue->Description, id => $queue->id };
-                push (@{$session{'create_in_queues'}}, $ds);
-        }        
-}
-}
-</%INIT>
-
-
-<%ARGS>
-$Name => 'Queue'
-$Verbose =>  0
-$Default => 0
-</%ARGS>

Modified: rt/branches/3.5-TESTING/html/Elements/SelectQueue
==============================================================================
--- rt/branches/3.5-TESTING/html/Elements/SelectQueue	(original)
+++ rt/branches/3.5-TESTING/html/Elements/SelectQueue	Sun Jul 31 12:27:38 2005
@@ -44,26 +44,29 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 % if ($Lite) {
-% my $d = new RT::Queue($session{'CurrentUser'});
-% $d->Load($Default);
-<input name="<%$Name%>" size="25" default="<%$d->Name%>">
-% } else {
-<select NAME ="<%$Name%>">
-% if ($ShowNullOption) {
-<option value="">-</option>
-% }
-% while (my $queue=$q->Next) {
-% if ($ShowAllQueues || $queue->CurrentUserHasRight($CheckQueueRight)) {
-<option value="<%($NamedValues ? $queue->Name : $queue->Id) %>" <%( $queue->Id eq $Default ? 'SELECTED' : '')%>><%$queue->Name%>
-%   if (($Verbose) and ($queue->Description) ){
-(<%$queue->Description%>)
-%  }
-</option>
-% }
+%     my $d = new RT::Queue($session{'CurrentUser'});
+%     $d->Load($Default);
+<input name="<%$Name%>" size="25" value="<%$d->Name%>" />
 % }
+% else {
+<select name="<%$Name%>">
+%     if ($ShowNullOption) {
+  <option value="">-</option>
+%     }
+%     for my $queue (@{$cache{$cache_key}}) {
+  <option value="<% ($NamedValues ? $queue->{Name} : $queue->{Id}) %>" <% ($queue->{Id} eq $Default ? 'selected="selected"' : '') |n %>>
+    <%$queue->{Name}%>
+%             if ($Verbose and $queue->{Description}) {
+    (<%$queue->{Description}%>)
+%             }
+  </option>
+%     }
 </select>
 % }
-<%ARGS>
+<%once>
+my %cache;
+</%once>
+<%args>
 $CheckQueueRight => 'CreateTicket'
 $ShowNullOption => 1
 $ShowAllQueues => 1
@@ -72,11 +75,24 @@
 $NamedValues => 0
 $Default => 0
 $Lite => 0
-</%ARGS>
-
-<%INIT>
-
-my $q=new RT::Queues($session{'CurrentUser'});
-$q->UnLimit;
+</%args>
+<%init>
+my $cache_key = "SelectQueue---"
+                . $session{'CurrentUser'}->Id
+                . "---$CheckQueueRight---$ShowAllQueues";
 
-</%INIT>
+if (not defined $cache{$cache_key} and not $Lite) {
+    my $q = new RT::Queues($session{'CurrentUser'});
+    $q->UnLimit;
+    
+    while (my $queue = $q->Next) {
+        if ($ShowAllQueues || $queue->CurrentUserHasRight($CheckQueueRight)) {
+            push @{$cache{$cache_key}}, {
+                Id          => $queue->Id,
+                Name        => $queue->Name,
+                Description => $queue->Description,
+            };
+        }
+    }
+}
+</%init>


More information about the Rt-commit mailing list