Skip to content

Commit 2bac74b

Browse files
author
Marc Nilius
committed
Fixed bug#10961 - Adding email recipients via addressbook does not update customer information.
1 parent f0d28b4 commit 2bac74b

File tree

5 files changed

+67
-19
lines changed

5 files changed

+67
-19
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- 2015-01-06 Added ACLs handling for Owner and Responsible on screen load for AgentTicketOwner and AgentTicketResponsible.
2222

2323
#4.0.8 2015-??-??
24+
- 2015-04-20 Fixed bug#[10961](http://bugs.otrs.org/show_bug.cgi?id=10961) - Adding email recipients via addressbook does not update customer information.
2425
- 2015-04-17 Fixed bug#[11244](http://bugs.otrs.org/show_bug.cgi?id=11244) - Slave database not used in OTRS 4.
2526
- 2015-04-16 Fixed bug#[11123](http://bugs.otrs.org/show_bug.cgi?id=11123) - DynamicFieldText RegEx message problem on create and edit.
2627
- 2015-04-14 Fixed bug#[11226](http://bugs.otrs.org/show_bug.cgi?id=11226) - Tags in transition actions work only if there is only a tag in the field.

Kernel/Modules/AgentBook.pm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sub Run {
3131
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
3232

3333
# get params
34-
for my $Recipient (qw(ToCustomer CcCustomer BccCustomer)) {
34+
for my $Recipient (qw(ToCustomer CcCustomer BccCustomer CustomerData)) {
3535
$Param{$Recipient} = $ParamObject->GetParam( Param => $Recipient );
3636
}
3737

@@ -53,7 +53,10 @@ sub Run {
5353
User => $CustomerUser,
5454
);
5555
if ( $CustomerUserData{UserEmail} ) {
56-
$List{ $CustomerUserData{UserEmail} } = $CustomerUserList{$CustomerUser};
56+
$List{ $CustomerUserData{UserEmail} } = {
57+
Email => $CustomerUserList{$CustomerUser},
58+
CustomerKey => $CustomerUser,
59+
};
5760
}
5861
}
5962

@@ -71,13 +74,15 @@ sub Run {
7174
);
7275

7376
my $Count = 1;
74-
for ( reverse sort { $List{$b} cmp $List{$a} } keys %List ) {
77+
for ( reverse sort { $List{$b}->{Email} cmp $List{$a}->{Email} } keys %List ) {
7578
$LayoutObject->Block(
7679
Name => 'Row',
7780
Data => {
78-
Name => $List{$_},
79-
Email => $_,
81+
Email => $List{$_}->{Email},
8082
Count => $Count,
83+
CustomerDataJSON =>
84+
$Kernel::OM->Get('Kernel::System::JSON')
85+
->Encode( Data => { $List{$_}->{Email} => $List{$_}->{CustomerKey} } ),
8186
},
8287
);
8388
$Count++;

Kernel/Output/HTML/Standard/AgentBook.tt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<table id="SearchResult" class="DataTable SpacingTop">
2222
<thead>
2323
<tr>
24-
<th>[% Translate("Name") | html %]</th>
24+
<th>[% Translate("Email") | html %]</th>
2525
<th>[% Translate("To") | html %]</th>
2626
<th>[% Translate("Cc") | html %]</th>
2727
<th>[% Translate("Bcc") | html %]</th>
@@ -30,8 +30,8 @@
3030
<tbody>
3131
[% RenderBlockStart("Row") %]
3232
<tr id="Row[% Data.Count | html %]">
33-
<td>[% Data.Name | html %]</td>
34-
<td><a href="" rel="ToCustomer" title="[% Translate("Add email address %s to the To field", Data.Email) | html %]">[% Translate("To") | html %]</a></td>
33+
<td>[% Data.Email | html %]</td>
34+
<td><a href="" data-customerdatajson="[% Data.CustomerDataJSON | html %]" rel="ToCustomer" title="[% Translate("Add email address %s to the To field", Data.Email) | html %]">[% Translate("To") | html %]</a></td>
3535
<td><a href="" rel="CcCustomer" title="[% Translate("Add email address %s to the Cc field", Data.Email) | html %]">[% Translate("Cc") | html %]</a></td>
3636
<td><a href="" rel="BccCustomer" title="[% Translate("Add email address %s to the Bcc field", Data.Email) | html %]">[% Translate("Bcc") | html %]</a></td>
3737
</tr>
@@ -48,17 +48,18 @@
4848
<fieldset class="TableLike FixedLabel SpacingTop">
4949
<label for="To">[% Translate("To") | html %]:</label>
5050
<div class="Field">
51-
<input type="text" name="ToCustomer" id="ToCustomer" value="[% Data.ToCustomer | html %]" class="W75pc CustomerAutoComplete" />
51+
<input type="hidden" name="CustomerData" id="CustomerData" value="[% Data.CustomerData | html %]" />
52+
<input type="text" name="ToCustomer" id="ToCustomer" value="[% Data.ToCustomer | html %]" class="W75pc" />
5253
</div>
5354
<div class="Clear"></div>
5455
<label for="Cc">[% Translate("Cc") | html %]:</label>
5556
<div class="Field">
56-
<input type="text" name="CcCustomer" id="CcCustomer" value="[% Data.CcCustomer | html %]" class="W75pc CustomerAutoComplete" />
57+
<input type="text" name="CcCustomer" id="CcCustomer" value="[% Data.CcCustomer | html %]" class="W75pc" />
5758
</div>
5859
<div class="Clear"></div>
5960
<label for="Bcc">[% Translate("Bcc") | html %]:</label>
6061
<div class="Field">
61-
<input type="text" name="BccCustomer" id="BccCustomer" value="[% Data.BccCustomer | html %]" class="W75pc CustomerAutoComplete" />
62+
<input type="text" name="BccCustomer" id="BccCustomer" value="[% Data.BccCustomer | html %]" class="W75pc" />
6263
</div>
6364
</fieldset>
6465
</form>

Kernel/Output/HTML/Standard/FooterJS.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Core.App.Ready(function () {
4040
AnimationEnabled: parseInt('[% Config("Frontend::AnimationEnabled") %]', 10),
4141
MenuDragDropEnabled: parseInt('[% Config("Frontend::MenuDragDropEnabled") %]', 10),
4242
OpenMainMenuOnHover: parseInt('[% Config("OpenMainMenuOnHover") %]', 10),
43+
CustomerInfoSet: parseInt('[% Config("Ticket::Frontend::CustomerInfoCompose") %]', 10),
4344
[% RenderBlockStart("AutoCompleteConfig") %]
4445
Autocomplete: [% Data.AutocompleteConfig %],
4546
[% RenderBlockEnd("AutoCompleteConfig") %]

var/httpd/htdocs/js/Core.Agent.TicketAction.js

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,40 @@ Core.Agent.TicketAction = (function (TargetNS) {
103103
*/
104104
function AddMailAddress($Link) {
105105
var $Element = $('#' + $Link.attr('rel')),
106-
NewValue = $Element.val();
106+
NewValue = $Element.val(),NewData,NewDataItem,Length;
107+
107108
if (NewValue.length) {
108109
NewValue = NewValue + ', ';
109110
}
110-
NewValue = NewValue + Core.Data.Get($Link.closest('tr'), 'Email');
111-
$Element.val(NewValue);
111+
NewValue = NewValue +
112+
Core.Data.Get($Link.closest('tr'), 'Email')
113+
.replace(/&quot;/g, '"')
114+
.replace(/&lt;/g, '<')
115+
.replace(/&gt;/g, '>');
116+
$Element.val( NewValue );
117+
118+
Length= $Element.val().length;
119+
$Element.focus();
120+
$Element[0].setSelectionRange(Length, Length);
121+
122+
// set customer data for customer user information (AgentTicketEmail) in the compose screen
123+
if ( $Link.attr('rel') === 'ToCustomer' && Core.Config.Get('CustomerInfoSet') ){
124+
125+
NewData = $('#CustomerData').val();
126+
NewDataItem = Core.Data.Get($Link.closest('a'), 'customerdatajson');
127+
128+
if(NewData){
129+
NewData = Core.JSON.Parse(NewData);
130+
$.each(NewDataItem, function(CustomerMail, CustomerKey) {
131+
NewData[CustomerMail] = CustomerKey;
132+
});
133+
$('#CustomerData').val(Core.JSON.Stringify(NewData));
134+
}
135+
else
136+
{
137+
$('#CustomerData').val(Core.JSON.Stringify(NewDataItem));
138+
}
139+
}
112140
}
113141

114142
/**
@@ -264,7 +292,7 @@ Core.Agent.TicketAction = (function (TargetNS) {
264292
// Register Apply button event
265293
$('#Apply').bind('click', function (Event) {
266294
// Update ticket action popup fields
267-
var $To, $Cc, $Bcc;
295+
var $To, $Cc, $Bcc, CustomerData;
268296

269297
// Because we are in an iframe, we need to call the parent frames javascript function
270298
// with a jQuery object which is in the parent frames context
@@ -286,10 +314,22 @@ Core.Agent.TicketAction = (function (TargetNS) {
286314
$Cc = $('#CcCustomer', parent.document);
287315
$Bcc = $('#BccCustomer', parent.document);
288316

289-
$.each($('#ToCustomer').val().split(/, ?/), function(Index, Value){
290-
$To.val(Value);
291-
parent.Core.Agent.CustomerSearch.AddTicketCustomer( 'ToCustomer', Value );
292-
});
317+
// check is set customer data for customer user information
318+
// it will not be set if it is used CustomerAutoComplete ( e.g for forwrad, reply ticket )
319+
if ($('#CustomerData').val()) {
320+
CustomerData =Core.JSON.Parse($('#CustomerData').val());
321+
$.each(CustomerData, function(CustomerMail, CustomerKey) {
322+
$To.val(CustomerMail);
323+
parent.Core.Agent.CustomerSearch.AddTicketCustomer( 'ToCustomer',CustomerMail , CustomerKey );
324+
325+
});
326+
}
327+
else{
328+
$.each($('#ToCustomer').val().split(/, ?/), function(Index, Value){
329+
$To.val(Value);
330+
parent.Core.Agent.CustomerSearch.AddTicketCustomer( 'ToCustomer', Value );
331+
});
332+
}
293333

294334
$.each($('#CcCustomer').val().split(/, ?/), function(Index, Value){
295335
$Cc.val(Value);

0 commit comments

Comments
 (0)