Hi,
Here is a patch to create a customerUser if it does not already exist, so
that it  appears in the customers list and can be edited afterwards.


Cheers,
Thomas

On Wed, Nov 2, 2011 at 7:32 PM, Carlos Andrés Gallego Arboleda <
[email protected]> wrote:

> Hi Thomas,
>
> When the tickets are created by e-mail OTRS allow everyone mails and
> create a tickets, don't validate if the customer exists on customers Admin
> or not.
>
> The only way to edit the preferences is to add the customer information on
> Admin>>Customer Users.
>
> 2011/11/2 Thomas Bouffon <[email protected]>
>
>> Hi,
>> I am new to OTRS, and after a lot of googling, I cannot find why what I'm
>> trying to do does not work.
>>
>> I have set up ticket creation through email via pop3. That works fine.
>> But the customer created via this process does not apper in the main
>> customers list, so I cannot edit its information.
>>
>> What am  I doing wrong ?
>>
>> Thanks,
>> Thomas
>>
>>
>> ---------------------------------------------------------------------
>> OTRS mailing list: otrs - Webpage: http://otrs.org/
>> Archive: http://lists.otrs.org/pipermail/otrs
>> To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs
>>
> the
>
> ---------------------------------------------------------------------
> OTRS mailing list: otrs - Webpage: http://otrs.org/
> Archive: http://lists.otrs.org/pipermail/otrs
> To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs
>
--- Kernel/System/PostMaster/NewTicket.pm	2011-11-02 19:16:58.000000000 +0100
+++ Custom/Kernel/System/PostMaster/NewTicket.pm	2011-11-03 17:06:32.000000000 +0100
@@ -28,6 +28,7 @@
     bless( $Self, $Type );
 
     $Self->{Debug} = $Param{Debug} || 0;
+    $Self->{Debug} = 1;
 
     # get all objects
     for (qw(DBObject ConfigObject TicketObject LogObject ParserObject TimeObject QueueObject)) {
@@ -74,6 +75,7 @@
     for (@EmailAddresses) {
         $GetParam{SenderEmailAddress} = $Self->{ParserObject}->GetEmailAddress( Email => $_, );
     }
+    my $CustomerExists=0;
 
     # get customer id (sender email) if there is no customer id given
     if ( !$GetParam{'X-OTRS-CustomerNo'} && $GetParam{'X-OTRS-CustomerUser'} ) {
@@ -83,6 +85,8 @@
             User => $GetParam{'X-OTRS-CustomerUser'},
         );
         if (%CustomerData) {
+ 
+	    $CustomerExists=1;
             $GetParam{'X-OTRS-CustomerNo'} = $CustomerData{UserCustomerID};
         }
     }
@@ -111,6 +115,7 @@
 
         # take CustomerID from customer backend lookup or from from field
         if ( $CustomerData{UserLogin} && !$GetParam{'X-OTRS-CustomerUser'} ) {
+	    $CustomerExists=1;
             $GetParam{'X-OTRS-CustomerUser'} = $CustomerData{UserLogin};
 
             # notice that UserLogin is form customer source backend
@@ -121,6 +126,7 @@
             );
         }
         if ( $CustomerData{UserCustomerID} && !$GetParam{'X-OTRS-CustomerNo'} ) {
+	    $CustomerExists=1;
             $GetParam{'X-OTRS-CustomerNo'} = $CustomerData{UserCustomerID};
 
             # notice that UserCustomerID is form customer source backend
@@ -142,9 +148,30 @@
     if ( !$GetParam{'X-OTRS-CustomerUser'} ) {
         $GetParam{'X-OTRS-CustomerUser'} = $GetParam{SenderEmailAddress};
     }
+    if ($GetParam{SenderEmailAddress} eq "publitheque\@meteo.fr" && $GetParam{'X-OTRS-CustomerUser'}) {$GetParam{SenderEmailAddress}=$GetParam{'X-OTRS-CustomerUser'};}
+     $Self->{TicketObject}->{ConfigObject}->Set(
+            Key   => 'Ticket::Queue',
+            Value => $Queue,
+        );
+    if (!$CustomerExists && $Queue eq "Demandes" ) {
+      $Self->{CustomerUserObject}->CustomerUserAdd(
+        Source         => 'CustomerUser', # CustomerUser source config
+        UserFirstname  => 'prenom',
+        UserLastname   => 'nom',
+        UserCustomerID => $GetParam{'X-OTRS-CustomerNo'},
+        UserLogin      => $GetParam{'X-OTRS-CustomerUser'},
+        #UserPassword   => 'some-pass', # not required
+        UserEmail      => $GetParam{SenderEmailAddress},
+        ValidID        => 1,
+        UserID         => '000',
+      );
+    }
 
     # create new ticket
-    my $NewTn    = $Self->{TicketObject}->TicketCreateNumber();
+
+    my $NewTn = $Self->{TicketObject}->TicketCreateNumber();
+    unless ($Queue eq "Demandes" ) {$NewTn="X".$NewTn;}
+
     my $TicketID = $Self->{TicketObject}->TicketCreate(
         TN           => $NewTn,
         Title        => $GetParam{Subject},
---------------------------------------------------------------------
OTRS mailing list: otrs - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/otrs

Reply via email to