From 912d9c102ffc1f9826a2ba353e40d1dfbc5bd7b5 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 27 Jul 2010 09:02:48 +0000 Subject: [PATCH] should fix customer #1 getting added if i set myself as a requestor on ticket creation, RT#6640 --- rt/lib/RT/Ticket_Overlay.pm | 125 ++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/rt/lib/RT/Ticket_Overlay.pm b/rt/lib/RT/Ticket_Overlay.pm index 83737c168..cde2a893c 100644 --- a/rt/lib/RT/Ticket_Overlay.pm +++ b/rt/lib/RT/Ticket_Overlay.pm @@ -560,68 +560,6 @@ sub Create { # }}} - # {{{ 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; - - } - - } - - # }}} - # {{{ Add all the custom fields foreach my $arg ( keys %args ) { @@ -693,6 +631,69 @@ sub Create { } # }}} + + # {{{ 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; + + } + + } + + # }}} + # Now that we've created the ticket and set up its metadata, we can actually go and check OwnTicket on the ticket itself. # This might be different than before in cases where extensions like RTIR are doing clever things with RT's ACL system if ( $DeferOwner ) { -- 2.11.0