[rt-users] Web UI - limit tickets/page ability?

Jan Okrouhly okrouhly at civ.zcu.cz
Tue Mar 6 15:59:32 EST 2001


I've currently finished up functionality cleaning of the old Rich's patch
+ added two minor and one major bug corrections of rt-1.0.7 - all is
prepared together for Jesse as a (patchable output of) unified diff which 
I hope make an rt-1.0.8pre1 from the rt-1.0.7...

Description of changes:
lib/rt/database.pm
 - major bug - merged tickets history is actually visible...
 - 'Display Queue' query corrected to work well with Rich's LIMIT
   (it may not work well due the output was post-filtered [by perl code])
lib/rt/ui/cli/query.pm
 - minor bug - rtq help describing 'orderby' function was mistyped
lib/rt/ui/web/forms.pm
 - fixed Rich's handling with 'q_limit' and 'q_range' to allow right
   functions of sorting buttons
 - changed bahavior of 'Display Queue' to allow to the 'RT Admin' user
   selection of all queues
 - fixed Rich's handling of 'Area' to allow selection of all Areas
   accessible to given user from actually displayed queues
 - added Rich's q_limits
lib/rt/ui/web/manipulate.pm
 - changed Rich's area testing to strict and fixed "None" option
 - added rest of Rich's area a q_limis core implementation
lib/rt/ui/web/support.pm 
 - minor bug fix - when using external auth and no parse header CGI,
   there was missing print "HTTP/1.0 200 Ok\n"; code...

That should be all. Enjoy!

On Fri, 2 Mar 2001, Othmar Pasteka wrote:

> hi,
> 
> On Thu, Mar 01, 2001 at 03:47:44PM +0000, Jan Okrouhly wrote:
> > I've finaly found it...it was sent by Rich West on 25 May 1999 to
> > rt-users... working pretty well with 0.99.8pre4, but there were no
> > problems getting into the current 1.0.7 stable version.
> > I just make some modifications to correct work of his links (Next xx,
> > Previos xx) to preserve actual setting of sort criteria...
> > Both are in attachments.
> 
> cool, is it possible that oyu send me a unified diff? would be
> great.
> 
> so long
> Othmar
 
Greets

Jan Okrouhly
---------------------------------------\-\-\+\-\-\---okrouhly at civ.zcu.cz---
Laboratory for Computer Science             |    phone: (420 19) 7491588
University of West Bohemia                  | location: Univerzitni 22
Americka 42, 306 14 Pilsen, Czech Republic  |     room: UI404
------------------------------------------73!-de-OK1INC at OK0PPL.#BOH.CZE.EU-

-------------- next part --------------
diff -ru rt-1.0.7/lib/rt/database.pm rt-1.0.8pre1/lib/rt/database.pm
--- rt-1.0.7/lib/rt/database.pm	Fri Oct  1 06:22:15 1999
+++ rt-1.0.8pre1/lib/rt/database.pm	Tue Mar  6 21:20:14 2001
@@ -198,7 +198,7 @@
     $effective_sn=&normalize_sn($in_serial_num);
     $sth = $dbh->Query("SELECT id, actor, type, trans_data, trans_date, serial_num, effective_sn from transactions WHERE effective_sn = $effective_sn ORDER BY id") or warn "Query had some problem: $Msql::db_errstr\n";
     while (@row=$sth->FetchRow) {
-	&parse_transaction_row($counter, $in_current_user, @row);
+	&parse_transaction_row($counter, $in_current_user, $row[6], @row);
 	$counter++;
     }
     return ($counter);
@@ -212,15 +212,15 @@
     $sth = $dbh->Query($query_string) or return( "Query had some problem: $Mysql::db_errstr\nThe query was $query_string");
     
     while (@row=$sth->FetchRow) {
-	&parse_transaction_row($trans, $in_current_user, @row);
+	&parse_transaction_row($trans, $in_current_user, $row[5], @row);
     }
     return ($trans);
 }
 
 sub parse_transaction_row {
-    my ($in_id, $in_current_user, @row) = @_;
+    my ($in_id, $in_current_user, $in_serial_num, @row) = @_;
     my ($success,$content,$wday, $mon, $mday, $hour, $min, $sec, $TZ, $year);
-    $serial_num=$row[6];
+    $serial_num=$in_serial_num;
 
     $rt::req[$serial_num]{'trans'}[$in_id]{'id'}	       	=	$row[0];
     $rt::req[$serial_num]{'trans'}[$in_id]{'serial_num'}		=	$row[5];
@@ -371,7 +371,16 @@
     my ($in_criteria,$in_current_user) =@_;
     my $temp=0;
     
+   $in_criteria = "serial_num=effective_sn AND $in_criteria";
+   if (!$rt::users{$in_current_user}{admin_rt}) {
+    $in_criteria =~ s/queue_id/each_req.queue_id/;
+    $in_criteria = "queue_acl.queue_id=each_req.queue_id and queue_acl.user_id=\"$in_current_user\" and queue_acl.display=1 AND $in_criteria"; 
+    $query_string = "SELECT serial_num, effective_sn,  each_req.queue_id, area,  alias,  requestors,  owner,  subject,  initial_priority,  final_priority,  priority,  status,  date_created,  date_told,  date_acted,  date_due FROM each_req, queue_acl WHERE $in_criteria";
+   }
+   else
+    {
     $query_string = "SELECT serial_num, effective_sn,  queue_id, area,  alias,  requestors,  owner,  subject,  initial_priority,  final_priority,  priority,  status,  date_created,  date_told,  date_acted,  date_due FROM each_req WHERE $in_criteria";
+    }
     $sth = $dbh->Query($query_string)
 	or warn "Query had some problem: $Msql::db_errstr\n$query_string\n";
 
diff -ru rt-1.0.7/lib/rt/ui/cli/query.pm rt-1.0.8pre1/lib/rt/ui/cli/query.pm
--- rt-1.0.7/lib/rt/ui/cli/query.pm	Tue Feb 29 04:49:55 2000
+++ rt-1.0.8pre1/lib/rt/ui/cli/query.pm	Tue Mar  6 21:20:14 2001
@@ -281,12 +281,12 @@
 	   -area <area>	     lists requests in the area <area>
            -orderby <crit>   Sorts requests by <crit>  (one of serial_num, 
                              queue_id, requestors, owner, subject, priority, 
+                             status, date_created, date_due, area)
            -export           Outputs selected requests in tab-delimited format,
                              including all fields.  Embedded tabs and newlines
                              are translated to \\t and \\n.  A header record is
                              written.
            -all              Export all requests
-                             status, date_created, date_due, area)
            -format <format> allows you to specify the output of rtq.
                              <format> is a string of the form %xn%xn%xn.  
                              x is any of the commands associated below.  
diff -ru rt-1.0.7/lib/rt/ui/web/forms.pm rt-1.0.8pre1/lib/rt/ui/web/forms.pm
--- rt-1.0.7/lib/rt/ui/web/forms.pm	Thu Jun  1 08:56:27 2000
+++ rt-1.0.8pre1/lib/rt/ui/web/forms.pm	Tue Mar  6 21:20:14 2001
@@ -8,7 +8,53 @@
 sub FormQueueOptions{
     local($^W) = 0; # Lots of form fields that may or may not exist give bogus errors
     my @qs;
-    
+    my $pa;#flag, that printing ampersand is needed
+
+    if ($rt::ui::web::FORM{'q_limit'}) {
+
+      #$query=$query;
+      $query = $ENV{'QUERY_STRING'};
+      $query =~ s/&?q_limit=[0-9]+(&?)/\1/;
+      $query =~ s/&?q_range=[0-9]+(&?)/\1/;
+      $query =~ s/&&/&/;
+      $query =~ s/^&//;
+       print "<CENTER>";
+       $range=$rt::ui::web::FORM{'q_limit'} + $rt::ui::web::FORM{'q_range'};
+       print "<A HREF=\"$ScriptURL?";
+       if ($query) {
+          print "$query";
+          $pa=1;
+       }
+       if ($frames) {
+          print "&" if ($pa);
+          print "display=Queue";
+          $pa=1;
+       }
+       print "&" if ($pa);
+       print "q_limit=$rt::ui::web::FORM{'q_limit'}&q_range=$range\">Next $rt::ui::web::FORM{'q_limit'}</A>";
+       print "     ";
+       $pa=0;
+ 
+       $range=$rt::ui::web::FORM{'q_range'} - $rt::ui::web::FORM{'q_limit'};
+       if ($range >= 0) {
+          print "<A HREF=\"$ScriptURL?";
+          $pa=0;
+          if ($query) {
+            print "$query";
+            $pa=1;
+          }
+          if ($frames) {
+            print "&" if ($pa);
+            print "display=Queue";
+            $pa=1;
+          }
+          print "&" if ($pa);
+          print "q_limit=$rt::ui::web::FORM{'q_limit'}&q_range=$range\">Previous $rt::ui::web::FORM{'q_limit'}</A>";
+       }
+       else {
+          print " None Previous";
+       }
+    }
 
     print "<form action=\"$ScriptURL\" method=\"get\"";
     if ($frames){ 
@@ -43,7 +89,7 @@
 <option value=\"\">Any\n";
     foreach $queue (sort keys %rt::queues) {
         if ($queue) {
-        if (&rt::can_display_queue($queue, $current_user) == 1 ) {
+        if (&rt::can_display_queue($queue, $current_user) != 0 ) {
 	    push @qs, $queue;
 
 
@@ -84,14 +130,14 @@
     foreach $user_id (sort keys %rt::users ) {
 	if( $rt::ui::web::FORM{q_queue} )
 	{
-		next if &rt::can_display_queue($rt::ui::web::FORM{q_queue},$user_id) != 1;
+		next if &rt::can_display_queue($rt::ui::web::FORM{q_queue},$user_id) == 0;
 	}
 else
 	{
 		$u = 1;
 		foreach $queue ( @qs )
 		{
-			next if &rt::can_display_queue($queue, $user_id) != 1;
+			next if &rt::can_display_queue($queue, $user_id) == 0;
 			$u = 0;
 			last;
 		}
@@ -159,15 +205,65 @@
 </font>
 
 
-</td></tr></table></center>
-<B>
-<center><input type=\"submit\" value =\"Update Queue Filters\"></center>
-</B>
-
+</td></tr>
+<tr><td>
+       <font size=\"-1\">
+       <b>Area</b>:
+       <SELECT NAME=\"q_area\">
+       <option value=\"\">Any
+       <option ";
+         print "SELECTED" if ($rt::ui::web::FORM{'q_area'} eq "None");
+         print ">None ";
+         my %areas;
+         foreach $queue_id (sort keys %rt::queues) {
+          next if (($rt::ui::web::FORM{q_queue}) && ("$rt::ui::web::FORM{q_queue}" ne "$queue_id"));
+          if (&rt::can_display_queue($queue_id,$current_user)!=0 ) {
+           foreach $area (keys % {$rt::queues{$queue_id}{areas}} ) {
+            $areas{$area}=1;
+           }
+          }
+         }
+         foreach $area (sort keys %areas) {
+           print "<option ";
+           print "SELECTED" if ($rt::ui::web::FORM{'q_area'} eq $area);
+           print ">$area\n";
+         }
+         print "</select></font>";
+         print "</td><td>
+ <font size=\"-1\"><b>Length</b>:
+ <SELECT NAME=\"q_limit\">";
+         print "<OPTION VALUE=0 ";
+         if ($rt::ui::web::FORM{'q_limit'} == 0 ) { print "SELECTED " ;}
+         print "> All";
+ 
+         print "<OPTION VALUE=25 ";
+         if ($rt::ui::web::FORM{'q_limit'} == 25 ) { print "SELECTED " ;}
+         print "> 25";
+ 
+         print "<OPTION VALUE=50 ";
+         if ($rt::ui::web::FORM{'q_limit'} == 50 ) { print "SELECTED " ;}
+         print "> 50";
+ 
+         print "<OPTION VALUE=100 ";
+         if ($rt::ui::web::FORM{'q_limit'} == 100 ) { print "SELECTED " ;}
+         print "> 100";
+ 
+         print "<OPTION VALUE=500 ";
+         if ($rt::ui::web::FORM{'q_limit'} == 500 ) { print "SELECTED " ;}
+         print "> 500";
+ 
+         print "<OPTION VALUE=1000 ";
+         if ($rt::ui::web::FORM{'q_limit'} == 1000 ) { print "SELECTED " ;}
+         print "> 1000";
+ 
+     print "</select></font>
+ </td>
+<td><table CELLPADDING=0 CELLSPACING=0 BORDER=0><tr VALIGN=TOP>
+<td BGCOLOR=\"#FBFBFB\"><B><input type=\"submit\" value =\"Update Queue Filters\"></B></td></tr></table></td></tr></table></center>
+  
 <input type=\"hidden\" name=\"display\" value=\"Queue\">
 </form>
 ";
-
 }  
 
 sub FormShowNum{
diff -ru rt-1.0.7/lib/rt/ui/web/manipulate.pm rt-1.0.8pre1/lib/rt/ui/web/manipulate.pm
--- rt-1.0.7/lib/rt/ui/web/manipulate.pm	Mon Jan  8 20:05:11 2001
+++ rt-1.0.8pre1/lib/rt/ui/web/manipulate.pm	Tue Mar  6 21:20:14 2001
@@ -416,7 +416,14 @@
       $status_ops = " status <> \'dead\'";
     } 
   }   
-  
+
+  if ($rt::ui::web::FORM{'q_area'} && $rt::ui::web::FORM{'q_area'} ne "Any") {
+    $area_ops .= " area = \'" . $rt::ui::web::FORM{'q_area'} . "\' ";
+  }
+  if ($rt::ui::web::FORM{'q_area'} eq "None") {
+    $area_ops = "area = \'\' ";
+  }
+ 
   if ($rt::ui::web::FORM{'q_user'} eq 'other') {
     if ($user_ops){
       $user_ops .= " OR ";
@@ -548,6 +555,12 @@
     if ($query_string) {$query_string .= " AND ";}
     $query_string .= "( $user_ops )";
   }
+
+  if ($area_ops) {
+    if ($query_string) {$query_string .= " AND ";}
+    $query_string .= "( $area_ops )";
+  }
+ 
   if ($owner_ops) {
     if ($query_string) {$query_string .= " AND ";}
     $query_string .= "( $owner_ops )";
@@ -566,6 +579,16 @@
   if ($reverse) {
     $query_string .= " DESC";
   }
+  if ($rt::ui::web::FORM{'q_limit'}) {
+    if ($rt::ui::web::FORM{'q_range'}) {
+       $start = $rt::ui::web::FORM{'q_range'};
+    }
+    else {
+       $start = 0;
+    }
+    $query_string .= " LIMIT $start,$rt::ui::web::FORM{'q_limit'}";
+  }
+
   
   
   $count=&rt::get_queue($query_string,$current_user);
diff -ru rt-1.0.7/lib/rt/ui/web/support.pm rt-1.0.8pre1/lib/rt/ui/web/support.pm
--- rt-1.0.7/lib/rt/ui/web/support.pm	Fri Dec  1 20:02:07 2000
+++ rt-1.0.8pre1/lib/rt/ui/web/support.pm	Tue Mar  6 21:20:14 2001
@@ -13,6 +13,10 @@
 
     if ($rt::web_auth_mechanism =~ /external/i) {
 	print STDERR "using external auth\n" if $debug;
+        if ($rt::program =~ /nph-/) {
+ 
+                       print "HTTP/1.0 200 Ok\n";
+        }
       $current_user = $ENV{REMOTE_USER};                                        
       return (0);
     }


More information about the rt-users mailing list