[rt-commit] [svn] r493 - in rt/branches/rt-3.1: bin html html/REST/1.0/Forms/ticket html/SelfService html/Ticket html/Ticket/Elements lib/RT

jesse at fsck.com jesse at fsck.com
Sun Mar 7 16:10:16 EST 2004


Author: jesse
Date: Sun Mar  7 16:10:15 2004
New Revision: 493

Added:
   rt/branches/rt-3.1/html/Ticket/Elements/FindAttachments   (contents, props changed)
Modified:
   rt/branches/rt-3.1/bin/webmux.pl.in
   rt/branches/rt-3.1/html/REST/1.0/Forms/ticket/default
   rt/branches/rt-3.1/html/SelfService/Display.html
   rt/branches/rt-3.1/html/Ticket/Display.html
   rt/branches/rt-3.1/html/Ticket/Elements/ShowAttachments
   rt/branches/rt-3.1/html/Ticket/Elements/ShowHistory
   rt/branches/rt-3.1/html/Ticket/Elements/ShowSummary
   rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction
   rt/branches/rt-3.1/html/Ticket/History.html
   rt/branches/rt-3.1/html/autohandler
   rt/branches/rt-3.1/html/index.html
   rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm
Log:
Merged forward changes from 3.0.10pre2



Modified: rt/branches/rt-3.1/bin/webmux.pl.in
==============================================================================
--- rt/branches/rt-3.1/bin/webmux.pl.in	(original)
+++ rt/branches/rt-3.1/bin/webmux.pl.in	Sun Mar  7 16:10:15 2004
@@ -32,6 +32,10 @@
     $ENV{'ENV'}    = '' if defined $ENV{'ENV'};
     $ENV{'IFS'}    = '' if defined $ENV{'IFS'};
     @ORACLE_ENV_PREF@
+
+    eval { require Apache2; require Apache::compat }
+        if $ENV{'MOD_PERL'} and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:2|1\.9)};
+
 }
 
 use lib ("@LOCAL_LIB_PATH@", "@RT_LIB_PATH@");

Modified: rt/branches/rt-3.1/html/REST/1.0/Forms/ticket/default
==============================================================================
--- rt/branches/rt-3.1/html/REST/1.0/Forms/ticket/default	(original)
+++ rt/branches/rt-3.1/html/REST/1.0/Forms/ticket/default	Sun Mar  7 16:10:15 2004
@@ -177,8 +177,8 @@
             $key = $simple{$key};
             $set = "Set$key";
 
-            next if $val eq $ticket->$key;
-            ($n, $s) = $ticket->$set($val);
+            next if (($val eq $ticket->$key)|| ($ticket->$key =~ /^\d+$/ && $val == $ticket->$key));
+            ($n, $s) = $ticket->$set("$val");
         }
         elsif (exists $dates{$key}) {
             $key = $dates{$key};
@@ -226,7 +226,7 @@
                 $s =~ s/^# //;
             }
         }
-        elsif ($key ne 'id' && $key ne 'type') {
+        elsif ($key ne 'id' && $key ne 'type' && $key ne 'creator') {
             $n = 0;
             $s = "Unknown field.";
         }

Modified: rt/branches/rt-3.1/html/SelfService/Display.html
==============================================================================
--- rt/branches/rt-3.1/html/SelfService/Display.html	(original)
+++ rt/branches/rt-3.1/html/SelfService/Display.html	Sun Mar  7 16:10:15 2004
@@ -46,7 +46,9 @@
 
 
 
-<& /Ticket/Elements/ShowHistory, Ticket => $Ticket, AttachPath => "Attachment" &>
+%#!!pape: selfservice_find_attachments.patch {{
+<& /Ticket/Elements/ShowHistory, Ticket => $Ticket, AttachPath => "Attachment", Attachments => $attachments &>
+%#!!pape: selfservice_find_attachments.patch }}
 
 
 
@@ -171,6 +173,10 @@
 # }}}
 
 my $Transactions = $Ticket->Transactions;
+
+#!!pape: selfservice_find_attachments.patch {{
+my $attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
+#!!pape: selfservice_find_attachments.patch }}
 
 </%INIT>
 

Modified: rt/branches/rt-3.1/html/Ticket/Display.html
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Display.html	(original)
+++ rt/branches/rt-3.1/html/Ticket/Display.html	Sun Mar  7 16:10:15 2004
@@ -32,14 +32,17 @@
 
 <& /Elements/TitleBoxStart, title => loc('Ticket metadata'), contentbg =>
 '#ffffff' &>
-<& /Ticket/Elements/ShowSummary,  Ticket => $TicketObj &>
+<& /Ticket/Elements/ShowSummary,  Ticket => $TicketObj, Attachments => $attachments &>
 <& /Elements/TitleBoxEnd &>
 
 <BR>
 <& /Ticket/Elements/ShowHistory , 
       Ticket => $TicketObj, 
       Collapsed => $ARGS{'Collapsed'}, 
-      ShowHeaders => $ARGS{'ShowHeaders'} &> 
+      ShowHeaders => $ARGS{'ShowHeaders'},
+      Attachments => $attachments 
+      
+      &> 
 
   
 <%ARGS>
@@ -113,6 +116,10 @@
 
     push (@Actions, @BasicActions, @results);
 }
+
+my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj);
+
+
 </%INIT>
 
 

Added: rt/branches/rt-3.1/html/Ticket/Elements/FindAttachments
==============================================================================
--- (empty file)
+++ rt/branches/rt-3.1/html/Ticket/Elements/FindAttachments	Sun Mar  7 16:10:15 2004
@@ -0,0 +1,46 @@
+<%INIT>
+my %documents;
+
+#A default implementation here loops through all transactions and pulls out all their attachments.
+# We end up doing an end-run around that to get a bit more performance
+
+# We force the cache of ticket transactions to get populated up front. otherwise, the 
+# code that looks at attachments will look at each one in turn.
+my $transactions = $Ticket->Transactions->First;
+
+
+my $attachments = RT::Attachments->new( $session{'CurrentUser'} );
+
+$attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId Created));
+
+if ( $Ticket->CurrentUserHasRight('ShowTicket') ) {
+    my $transactions = $attachments->NewAlias('Transactions');
+    $attachments->Join( ALIAS1 => 'main',
+                                           FIELD1 => 'TransactionId',
+                                           ALIAS2 => $transactions,
+                                           FIELD2 => 'id' );
+    
+    my $tickets = $attachments->NewAlias('Tickets');
+
+    $attachments->Join( ALIAS1 => $transactions,
+                        FIELD1 => 'Ticket',
+                        ALIAS2 => $tickets,
+                        FIELD2 => 'id' );
+
+    $attachments->Limit( ALIAS => $tickets,
+                         FIELD => 'EffectiveId',
+                         VALUE => $Ticket->id() );
+    # if the user may not see comments do not return them
+    unless ( $Ticket->CurrentUserHasRight('ShowTicketComments') ) {
+        $attachments->Limit( ALIAS    => $transactions,
+                             FIELD    => 'Type',
+                             OPERATOR => '!=',
+                             VALUE    => "Comment" );
+    }
+}
+return ($attachments);
+</%INIT>
+<%ARGS>
+$Ticket => undef
+</%ARGS>
+

Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowAttachments
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowAttachments	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowAttachments	Sun Mar  7 16:10:15 2004
@@ -47,7 +47,7 @@
 </%PERL>
 
 <li><font <%$fontsize%>>
-        <A HREF="<%$RT::WebPath%>/Ticket/Attachment/<%$rev->TransactionObj->Id%>/<%$rev->Id%>/<%$rev->Filename | u%>"><%$rev->CreatedAsString%> (<% $size %>)</a></font></li>
+        <A HREF="<%$RT::WebPath%>/Ticket/Attachment/<%$rev->TransactionId%>/<%$rev->Id%>/<%$rev->Filename | u%>"><%$rev->CreatedAsString%> (<% $size %>)</a></font></li>
 % }
 % $fontsize='size="-2"';
 % }
@@ -60,20 +60,15 @@
 
 <%INIT>
 my %documents;
-my $transactions = $Ticket->Transactions();
-while (my $trans = $transactions->Next()) {
-        my $attachments = $trans->Attachments();
-	$attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
-        $attachments->Limit(FIELD => 'Filename', OPERATOR => 'IS NOT', VALUE => 'NULL', QUOTEVALUE => 0, ENTRYAGGREGATOR => 'AND');
-        $attachments->Limit(FIELD => 'Filename', OPERATOR => '!=', VALUE => '', ENTRYAGGREGATOR => 'AND');
-        while (my $attach = $attachments->Next()) {
-              next unless ($attach->Filename());
-              # most recent at the top
-              unshift (@{$documents{$attach->Filename}}, $attach);
-        }
+
+while ( my $attach = $Attachments->Next() ) {
+    next unless ($attach->Filename());
+   unshift( @{ $documents{ $attach->Filename } }, $attach );
 }
+
 </%INIT>
 <%ARGS>
 $Ticket => undef
+$Attachments => undef
 </%ARGS>
 

Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowHistory
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowHistory	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowHistory	Sun Mar  7 16:10:15 2004
@@ -54,16 +54,43 @@
 % }
 
 <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=2 BORDER=0>
-% while (my $Transaction = $Transactions->Next) {
-% my $skip = 0;
-% $m->comp('/Elements/Callback', _CallbackName => 'SkipTransaction', Transaction => $Transaction, skip => \$skip, %ARGS);
-% next if $skip;
-% $i++;
-%	if ($Transactions->IsLast) {
-	<a name="lasttrans"></a>
-% 	}
-	    <& ShowTransaction, Ticket => $Ticket, Transaction => $Transaction, ShowHeaders => $ShowHeaders, Collapsed => $Collapsed, RowNum => $i, ShowTitleBarCommands => $ShowTitleBarCommands, %ARGS &>
-% }
+<%perl>
+my @attachments = @{$Attachments->ItemsArrayRef()};
+
+
+
+
+
+while ( my $Transaction = $Transactions->Next ) {
+    my $skip = 0;
+    $m->comp( '/Elements/Callback',
+              _CallbackName => 'SkipTransaction',
+              Transaction   => $Transaction,
+              skip          => \$skip,
+              %ARGS );
+    next if $skip;
+    $i++;
+
+    $m->out('<a name="lasttrans"></a>') if ( $Transactions->IsLast );
+
+    my @trans_attachments = grep { $_->TransactionId == $Transaction->Id } @attachments;
+
+   
+    #Args is first because we're clobbering the "Attachments" parameter 
+    $m->comp( 'ShowTransaction',
+            %ARGS,
+
+              Ticket               => $Ticket,
+              Transaction          => $Transaction,
+              ShowHeaders          => $ShowHeaders,
+              Collapsed            => $Collapsed,
+              RowNum               => $i,
+              ShowTitleBarCommands => $ShowTitleBarCommands,
+              Attachments          => \@trans_attachments,
+ );
+}
+
+</%perl>
 </TABLE>
 % if ($ShowDisplayModes or $ShowTitle) {
 <& /Elements/TitleBoxEnd &>
@@ -74,10 +101,13 @@
 my $i;
 
 
+$Attachments ||=  $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
+
 </%INIT>
 <%ARGS>
 $URIFile => 'Display.html'
 $Ticket => undef
+$Attachments => undef
 $ShowHeaders => undef
 $Collapsed => undef
 $ShowTitle => 1

Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowSummary
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowSummary	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowSummary	Sun Mar  7 16:10:15 2004
@@ -65,7 +65,7 @@
 	        <& /Ticket/Elements/ShowLinks, Ticket => $Ticket &>
 	<& /Elements/TitleBoxEnd &>
         <BR>
-	  <& /Ticket/Elements/ShowAttachments, Ticket => $Ticket &>
+	  <& /Ticket/Elements/ShowAttachments, Ticket => $Ticket, Attachments => $Attachments &>
 
 	  <& /Ticket/Elements/ShowRequestor, Ticket => $Ticket &>
 
@@ -75,6 +75,7 @@
     </TABLE>
 <%ARGS>
 $Ticket => undef
+$Attachments => undef
 </%ARGS>
 
 

Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction	Sun Mar  7 16:10:15 2004
@@ -36,8 +36,7 @@
 <%PERL>
 
 unless ($Collapsed) {
-    $attachments->GotoFirstItem;
-    while ( my $message = $attachments->Next ) {
+ foreach my $message (@$Attachments) { 
 
         my $quoted;
         my $headers = $message->Headers;
@@ -111,6 +110,7 @@
 $ShowTitleBarCommands => 1
 $RowNum => 1
 $AttachPath => $RT::WebPath."/Ticket/Attachment"
+$Attachments => undef
 $ShowBody => 1
 </%ARGS>
 
@@ -156,10 +156,12 @@
 if ( $Transaction->TimeTaken > 0 ) {
     $TimeTaken = $Transaction->TimeTaken . " min";
 }
-my $attachments = $Transaction->Attachments;
-$attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId)
-);
 
+unless ($Attachments) { 
+    my $attachments = $Transaction->Attachments;
+    $attachments->Columns( qw( Id Filename ContentType Headers Subject Parent ContentEncoding ContentType TransactionId) );
+    $Attachments = $attachments->ItemsArrayRef();
+}
 my $titlebar_commands = '&nbsp;';
 
 my @DisplayHeaders=qw ( _all);

Modified: rt/branches/rt-3.1/html/Ticket/History.html
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/History.html	(original)
+++ rt/branches/rt-3.1/html/Ticket/History.html	Sun Mar  7 16:10:15 2004
@@ -28,7 +28,7 @@
 
 <BR>
       
-<& /Ticket/Elements/ShowHistory , Ticket => $Ticket, ShowHeaders => $ARGS{'ShowHeaders'}, URIFile => 'History.html' &> 
+<& /Ticket/Elements/ShowHistory , Ticket => $Ticket, ShowHeaders => $ARGS{'ShowHeaders'}, URIFile => 'History.html', Attachments => $attachments &> 
 
 
 <%ARGS>
@@ -44,6 +44,8 @@
 unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
 	Abort("No permission to view ticket");
 }
+
+my $attachments = $m->comp('Elements/FindAttachments', Ticket => $Ticket);
 
 </%INIT>
 

Modified: rt/branches/rt-3.1/html/autohandler
==============================================================================
--- rt/branches/rt-3.1/html/autohandler	(original)
+++ rt/branches/rt-3.1/html/autohandler	Sun Mar  7 16:10:15 2004
@@ -117,6 +117,7 @@
 				       'HomePhone', 'WorkPhone', 'MobilePhone',
 				       'PagerPhone', 'Address1', 'Address2', 'City',
 				       'State', 'Zip', 'Country') {
+               $m->comp('/Elements/Callback', %ARGS, _CallbackName => 'NewUser');
 		    
 		    my $method = "Set$attribute";
 		    $UserObj->$method($new_user_info->{$attribute}) 

Modified: rt/branches/rt-3.1/html/index.html
==============================================================================
--- rt/branches/rt-3.1/html/index.html	(original)
+++ rt/branches/rt-3.1/html/index.html	Sun Mar  7 16:10:15 2004
@@ -64,7 +64,8 @@
     my $query = $ARGS{'q'};
 
     if ( $query =~ m/^\s*(\d+)\s*$/ ) {
-        $m->redirect("$RT::WebPath/Ticket/Display.html?id=$1");
+        $m->comp("/Ticket/Display.html" , id=> $1);
+        return();
     }
 
     $session{'tickets'} = RT::Tickets->new( $session{'CurrentUser'} );
@@ -73,26 +74,36 @@
         $session{'tickets'}->LimitWatcher( VALUE    => $query,
                                             TYPE => 'Requestor',
                                              OPERATOR => '=', );
-        $m->redirect("$RT::WebPath/Search/Listing.html");
+        $m->comp("/Search/Listing.html");
+
+        return();
     }
 
     #
     # Any search on queue name or subject will be for new/open tickets
     # only.
     #
+
     $session{'tickets'}->LimitStatus( VALUE    => $_,
                                       OPERATOR => '=', ) for qw(open new);
 
+
+
     my $queue = RT::Queue->new( $session{'CurrentUser'} );
     if ( $queue->Load($query) && $queue->Id ) {
         $session{'tickets'}->LimitQueue( VALUE    => $queue->Id,
                                          OPERATOR => '=', );
-        $m->redirect("$RT::WebPath/Search/Listing.html");
+
+
+        $m->comp("/Search/Listing.html");
+        return();
     }
-    $session{'tickets'}->LimitSubject( VALUE    =>  $query,
+    $session{'tickets'}->LimitSubject( VALUE    =>  $query, 
                                        OPERATOR => 'LIKE' );
+        $m->comp("/Search/Listing.html");
+
+    return();
 
-    $m->redirect("$RT::WebPath/Search/Listing.html");
 }
 
 if ($ARGS{'HomeRefreshInterval'}) {

Modified: rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm	Sun Mar  7 16:10:15 2004
@@ -158,6 +158,8 @@
                    Mode => 'Target', },
     DependedOnBy => { Type => 'DependsOn',
                       Mode => 'Base', },
+    MergedInto => { Type => 'MergedInto',
+                   Mode => 'Target', },
 
 );
 
@@ -176,6 +178,8 @@
                 Target => 'ReferredToBy', },
     DependsOn => { Base => 'DependsOn',
                    Target => 'DependedOnBy', },
+    MergedInto => { Base => 'MergedInto',
+                   Target => 'MergedInto', },
 
 );
 
@@ -1837,6 +1841,8 @@
 
 Returns true if the specified principal (or the one corresponding to the
 specified address) is a member of the group Type for this ticket.
+
+XX TODO: This should be Memoized. 
 
 =cut
 

Modified: rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm	Sun Mar  7 16:10:15 2004
@@ -633,6 +633,9 @@
             elsif ( $self->Field eq 'HasMember' ) {
                 return $self->loc( "Member [_1] added", $value );
             }
+            elsif ( $self->Field eq 'MergedInto' ) {
+                return $self->loc( "Merged into [_1]", $value );
+            }
         }
         else {
             return ( $self->Data );



More information about the Rt-commit mailing list