[Rt-commit] [svn] r1832 - in rt/branches/PLATANO-EXPERIMENTAL-CSS: . html/Search html/Ticket html/Ticket/Elements lib/RT lib/RT/Interface

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Thu Nov 11 03:31:19 EST 2004


Author: jesse
Date: Thu Nov 11 03:31:11 2004
New Revision: 1832

Modified:
   rt/branches/PLATANO-EXPERIMENTAL-CSS/   (props changed)
   rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Bulk.html
   rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Create.html
   rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Elements/ShowSummary
   rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/ModifyAll.html
   rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Update.html
   rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Web.pm
   rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Queue_Overlay.pm
   rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Ticket_Overlay.pm
   rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Transaction_Overlay.pm
Log:
 r9094 at tinbook:  jesse | 2004-11-11T02:59:58.447349Z
  r6113 at tinbook:  jesse | 2004-10-27T04:31:13.448231Z
  Added support for recording transaction custom fields on ticket creation.
  
 


Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Bulk.html
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Bulk.html	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Bulk.html	Thu Nov 11 03:31:11 2004
@@ -156,7 +156,7 @@
 % while (my $CF = $TxnCFs->Next()) {
 <TR>
 <TD ALIGN=RIGHT><% $CF->Name %>:</TD>
-<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
+<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "Object-RT::Transaction--CustomField-" &><em><% $CF->FriendlyType %></em></TD>
 </TD></TR>
 % } # end if while
  <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="UpdateAttachment" type="file"></td></tr>
@@ -229,7 +229,7 @@
     unless ( exists $cfqs{$cfqid} ) {
 	$cfqs{$cfqid} = 1;
 	$count++;
-	my $cfs = $cfq->CustomFields;
+	my $cfs = $cfq->TicketCustomFields;
 	while (my $cf = $cfs->Next) {
 	    $allcfs{$cf->Id} = $cf;
 	    $cfqnames{$cf->Id} = $cfqn;

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Create.html
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Create.html	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Create.html	Thu Nov 11 03:31:11 2004
@@ -117,7 +117,8 @@
 % while (my $CF = $TxnCFs->Next()) {
 <TR>
 <TD ALIGN=RIGHT><% $CF->Name %>:</TD>
-<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
+<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix =>
+    "Object-RT::Transaction--CustomField-" &><em><% $CF->FriendlyType %></em></TD>
 </TD></TR>
 % }
 % }

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Elements/ShowSummary
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Elements/ShowSummary	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Elements/ShowSummary	Thu Nov 11 03:31:11 2004
@@ -53,7 +53,7 @@
 	        <& /Ticket/Elements/ShowBasics, Ticket => $Ticket &>
 	  <& /Elements/TitleBoxEnd &>
           <br>
-% if ($Ticket->QueueObj->CustomFields()->First) {
+% if ($Ticket->QueueObj->TicketCustomFields->First) {
 	  <& /Elements/TitleBoxStart, title => loc('Custom Fields'), 
 		title_href =>"$RT::WebPath/Ticket/Modify.html?id=".$Ticket->Id, 
 		title_class=> 'inverse',  

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/ModifyAll.html
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/ModifyAll.html	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/ModifyAll.html	Thu Nov 11 03:31:11 2004
@@ -104,7 +104,7 @@
 %    while (my $CF = $TxnCFs->Next()) {
 <TR>
 <TD class="label"><% $CF->Name %>:</TD>
-<TD class="entry"><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
+<TD class="entry"><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "Object-RT::Transaction--CustomField-" &><em><% $CF->FriendlyType %></em></TD>
 </TD></TR>
 %    } # end if while
 % } # end of if

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Update.html
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Update.html	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Ticket/Update.html	Thu Nov 11 03:31:11 2004
@@ -105,7 +105,8 @@
 %    while (my $CF = $TxnCFs->Next()) {
 <TR>
 <TD ALIGN=RIGHT><% $CF->Name %>:</TD>
-<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
+<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix =>
+    "Object-RT::Transaction--CustomField-" &><em><% $CF->FriendlyType %></em></TD>
 </TD></TR>
 %    } # end if while
 % } # end of if
@@ -132,7 +133,6 @@
 % }
 </FORM>
 <%INIT>
-
 my $CanRespond = 0;
 my $CanComment = 0;
 my $title;
@@ -178,6 +178,7 @@
     }
     $session{'Attachments'} = { %{$session{'Attachments'} || {}} };
 }
+# }}}
 
 # {{{ store the uploaded attachment in session
 if ($ARGS{'Attach'}) {			# attachment?
@@ -190,7 +191,7 @@
     $subject =~ s#^.*[\\/]##;
 
     my $attachment = MakeMIMEEntity(
-        Subject             => $subject,
+        Filename             => $subject,
         Body                => "",
         AttachmentFieldName => 'Attach'
     );

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Web.pm	Thu Nov 11 03:31:11 2004
@@ -310,12 +310,15 @@
         Starts          => $starts->ISO,
         MIMEObj         => $MIMEObj
     );
-    foreach my $arg (%ARGS) {
-        if ($arg =~ /^CustomField-(\d+)(.*?)$/) {
-            my $cfid = $1;
-
+    foreach my $arg (keys %ARGS) {
             next if ($arg =~ /-Magic$/);
-            my $cf = new RT::CustomField( $RT::SystemUser );
+       #Object-RT::Ticket--CustomField-3-Values
+        if ($arg =~ /^Object-RT::Transaction--CustomField-/) {
+            $create_args{$arg} = $ARGS{$arg};
+        }
+        elsif ($arg =~ /^Object-RT::Ticket--CustomField-(\d+)(.*?)$/) {
+            my $cfid = $1;
+            my $cf = RT::CustomField->new( $session{'CurrentUser'});
             $cf->Load($cfid);
 
             if ($cf->Type eq 'FreeformMultiple') {
@@ -327,10 +330,11 @@
         }
     }
 
-    # turn new link lists into arrays, and pass in the proper arguments
-    my (@dependson, @dependedonby, 
-	@parents, @children, 
-	@refersto, @referredtoby);
+
+    # XXX TODO This code should be about six lines. and badly needs refactoring.
+ 
+    # {{{ turn new link lists into arrays, and pass in the proper arguments
+    my (@dependson, @dependedonby, @parents, @children, @refersto, @referredtoby);
 
     foreach my $luri ( split ( / /, $ARGS{"new-DependsOn"} ) ) {
 	$luri =~ s/\s*$//;    # Strip trailing whitespace
@@ -364,7 +368,9 @@
 	push @referredtoby, $luri;
     }
     $create_args{'ReferredToBy'} = \@referredtoby;
-
+    # }}}
+  
+ 
     my ( $id, $Trans, $ErrMsg ) = $Ticket->Create(%create_args);
     unless ( $id && $Trans ) {
         Abort($ErrMsg);

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Queue_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Queue_Overlay.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Queue_Overlay.pm	Thu Nov 11 03:31:11 2004
@@ -497,7 +497,7 @@
 
 =cut
 
-# XXX XXX - this should become TicketCustomFields
+# XXX TODO - this should become TicketCustomFields
 
 sub CustomFields {
     my $self = shift;

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Ticket_Overlay.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Ticket_Overlay.pm	Thu Nov 11 03:31:11 2004
@@ -380,8 +380,7 @@
         $QueueObj->Load( $args{'Queue'}->Id );
     }
     else {
-        $RT::Logger->debug(
-            $args{'Queue'} . " not a recognised queue object." );
+        $RT::Logger->debug( $args{'Queue'} . " not a recognised queue object." );
     }
 
     #Can't create a ticket without a queue.
@@ -400,11 +399,7 @@
     {
         return (
             0, 0,
-            $self->loc(
-                "No permission to create tickets in the queue '[_1]'",
-                $QueueObj->Name
-            )
-        );
+            $self->loc( "No permission to create tickets in the queue '[_1]'", $QueueObj->Name));
     }
 
     unless ( $QueueObj->IsValidStatus( $args{'Status'} ) ) {
@@ -718,6 +713,8 @@
 
         if ( $self->Id && $Trans ) {
 
+            $TransObj->UpdateCustomFields(ARGSRef => \%args);
+
             $RT::Logger->info( "Ticket " . $self->Id . " created in queue '" . $QueueObj->Name . "' by " . $self->CurrentUser->Name );
             $ErrStr = $self->loc( "Ticket [_1] created in queue '[_2]'", $self->Id, $QueueObj->Name );
             $ErrStr = join( "\n", $ErrStr, @non_fatal_errors );
@@ -727,11 +724,7 @@
 
             $ErrStr = join( "\n", $ErrStr, @non_fatal_errors );
             $RT::Logger->error("Ticket couldn't be created: $ErrStr");
-            return (
-                0, 0,
-                $self->loc(
-                    "Ticket could not be created due to an internal error")
-            );
+            return ( 0, 0, $self->loc( "Ticket could not be created due to an internal error"));
         }
 
         $RT::Handle->Commit();

Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Transaction_Overlay.pm	(original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Transaction_Overlay.pm	Thu Nov 11 03:31:11 2004
@@ -922,21 +922,27 @@
 }
 
 sub UpdateCustomFields {
-    my ($self, %args) = @_;
+    my $self = shift;
+    my (%args) = @_;
+
     my $args_ref = $args{ARGSRef} or return;
 
     foreach my $arg ( keys %$args_ref ) {
-        $arg =~ /^(?:Transaction)?CustomField-(\d+).*?(?<!-Magic)$/ or next;
-	my $cfid = $1;
-	my $values = $args_ref->{$arg};
-	foreach my $value ( UNIVERSAL::isa($values, 'ARRAY') ? @$values : $values ) {
-	    next unless length($value);
-	    $self->_AddCustomFieldValue(
-		Field => $cfid,
-		Value => $value,
-		RecordTransaction => 0,
-	    );
-	}
+        next
+          unless ( $arg =~
+            /^(?:Object-RT::Transaction--)?CustomField-(\d+).*?(?<!-Magic)$/ );
+        my $cfid   = $1;
+        my $values = $args_ref->{$arg};
+        foreach
+          my $value ( UNIVERSAL::isa( $values, 'ARRAY' ) ? @$values : $values )
+        {
+            next unless length($value);
+            $self->_AddCustomFieldValue(
+                Field             => $cfid,
+                Value             => $value,
+                RecordTransaction => 0,
+            );
+        }
     }
 }
 


More information about the Rt-commit mailing list