[freeside-commits] freeside/rt/lib/RT Ticket_Overlay.pm,1.9,1.10

Ivan,,, ivan at wavetail.420.am
Thu Mar 25 18:06:02 PDT 2010


Update of /home/cvs/cvsroot/freeside/rt/lib/RT
In directory wavetail.420.am:/tmp/cvs-serv16873

Modified Files:
	Ticket_Overlay.pm 
Log Message:
ticket auto-association in the correct spot.  how the hell did it get merged there?  RT#7882

Index: Ticket_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Ticket_Overlay.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- Ticket_Overlay.pm	31 Dec 2009 14:00:28 -0000	1.9
+++ Ticket_Overlay.pm	26 Mar 2010 01:06:00 -0000	1.10
@@ -556,6 +556,76 @@
 
     # }}}
 
+    # {{{ Deal with auto-customer association
+
+    #unless we already have (a) customer(s)...
+    unless ( $self->Customers->Count ) {
+
+      #first find any requestors with emails but *without* customer targets
+      my @NoCust_Requestors =
+        grep { $_->EmailAddress && ! $_->Customers->Count }
+             @{ $self->_Requestors->UserMembersObj->ItemsArrayRef };
+
+      for my $Requestor (@NoCust_Requestors) {
+
+         #perhaps the stuff in here should be in a User method??
+         my @Customers =
+           &RT::URI::freeside::email_search( email=>$Requestor->EmailAddress );
+
+         foreach my $custnum ( map $_->{'custnum'}, @Customers ) {
+
+           ## false laziness w/RT/Interface/Web_Vendor.pm
+           my @link = ( 'Type'   => 'MemberOf',
+                        'Target' => "freeside://freeside/cust_main/$custnum",
+                      );
+
+           my( $val, $msg ) = $Requestor->_AddLink(@link);
+           #XXX should do something with $msg# push @non_fatal_errors, $msg;
+
+         }
+
+      }
+
+      #find any requestors with customer targets
+  
+      my %cust_target = ();
+
+      use Data::Dumper;
+      $RT::Logger->info( Dumper( $self->_Requestors ) );
+      $RT::Logger->info( Dumper( $self->_Requestors->UserMembersObj ) );
+      $RT::Logger->info( Dumper( $self->_Requestors->UserMembersObj->ItemsArrayRef ) );
+
+      my @Requestors =
+        grep { $_->Customers->Count }
+             @{ $self->_Requestors->UserMembersObj->ItemsArrayRef };
+  
+      foreach my $Requestor ( @Requestors ) {
+        foreach my $cust_link ( @{ $Requestor->Customers->ItemsArrayRef } ) {
+          $cust_target{ $cust_link->Target } = 1;
+        }
+      }
+  
+      #and then auto-associate this ticket with those customers
+  
+      foreach my $cust_target ( keys %cust_target ) {
+  
+        my @link = ( 'Type'   => 'MemberOf',
+                     #'Target' => "freeside://freeside/cust_main/$custnum",
+                     'Target' => $cust_target,
+                   );
+  
+        my( $val, $msg ) = $self->_AddLink(@link);
+        push @non_fatal_errors, $msg;
+  
+      }
+
+    } else {
+      $RT::Logger->info( "ticket already has customer links; not auto-associating" );
+
+    }
+
+    # }}}
+
     # {{{ Add all the custom fields
 
     foreach my $arg ( keys %args ) {
@@ -642,69 +712,6 @@
         } else {
             $Owner = $DeferOwner;
             $self->__Set(Field => 'Owner', Value => $Owner->id);
-
-    # {{{ Deal with auto-customer association
-
-    #unless we already have (a) customer(s)...
-    unless ( $self->Customers->Count ) {
-
-      #first find any requestors with emails but *without* customer targets
-      my @NoCust_Requestors =
-        grep { $_->EmailAddress && ! $_->Customers->Count }
-             @{ $self->_Requestors->UserMembersObj->ItemsArrayRef };
-
-      for my $Requestor (@NoCust_Requestors) {
-
-         #perhaps the stuff in here should be in a User method??
-         my @Customers =
-           &RT::URI::freeside::email_search( email=>$Requestor->EmailAddress );
-
-         foreach my $custnum ( map $_->{'custnum'}, @Customers ) {
-
-           ## false laziness w/RT/Interface/Web_Vendor.pm
-           my @link = ( 'Type'   => 'MemberOf',
-                        'Target' => "freeside://freeside/cust_main/$custnum",
-                      );
-
-           my( $val, $msg ) = $Requestor->_AddLink(@link);
-           #XXX should do something with $msg# push @non_fatal_errors, $msg;
-
-         }
-
-      }
-
-      #find any requestors with customer targets
-  
-      my %cust_target = ();
-  
-      my @Requestors =
-        grep { $_->Customers->Count }
-             @{ $self->_Requestors->UserMembersObj->ItemsArrayRef };
-  
-      foreach my $Requestor ( @Requestors ) {
-        foreach my $cust_link ( @{ $Requestor->Customers->ItemsArrayRef } ) {
-          $cust_target{ $cust_link->Target } = 1;
-        }
-      }
-  
-      #and then auto-associate this ticket with those customers
-  
-      foreach my $cust_target ( keys %cust_target ) {
-  
-        my @link = ( 'Type'   => 'MemberOf',
-                     #'Target' => "freeside://freeside/cust_main/$custnum",
-                     'Target' => $cust_target,
-                   );
-  
-        my( $val, $msg ) = $self->_AddLink(@link);
-        push @non_fatal_errors, $msg;
-  
-      }
-
-    }
-
-    # }}}
-
         }
         $self->OwnerGroup->_AddMember(
             PrincipalId       => $Owner->PrincipalId,



More information about the freeside-commits mailing list