Unverified Commit f9a004f3 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub

Merge pull request #16659 from demeritcowboy/name-label-print-report

Alternate to #16650 - On Case Audit/Print Report richtext details field is getting escaped when system is non-english
parents 8abebe2f 1474f129
......@@ -58,6 +58,9 @@ class CRM_Case_Audit_Audit {
$datatype_elements = $field->getElementsByTagName("Type");
$datatype = $datatype_elements->item(0)->nodeValue;
$name_elements = $field->getElementsByTagName("Name");
$name = $name_elements->item(0)->nodeValue;
$label_elements = $field->getElementsByTagName("Label");
$label = $label_elements->item(0)->nodeValue;
......@@ -89,6 +92,7 @@ class CRM_Case_Audit_Audit {
if ($this->auditConfig->includeInRegion($label, $region)) {
$retval[$activityindex][$region][$fieldindex] = [];
$retval[$activityindex][$region][$fieldindex]['name'] = $name;
$retval[$activityindex][$region][$fieldindex]['label'] = $label;
$retval[$activityindex][$region][$fieldindex]['datatype'] = $datatype;
$retval[$activityindex][$region][$fieldindex]['value'] = $value;
......@@ -104,12 +108,14 @@ class CRM_Case_Audit_Audit {
])
) {
$caseActivities[$activityindex][$fieldindex] = [];
$caseActivities[$activityindex][$fieldindex]['name'] = $name;
$caseActivities[$activityindex][$fieldindex]['label'] = $label;
$caseActivities[$activityindex][$fieldindex]['datatype'] = $datatype;
$caseActivities[$activityindex][$fieldindex]['value'] = $value;
}
else {
$activityStatusType[$activityindex][$fieldindex] = [];
$activityStatusType[$activityindex][$fieldindex]['name'] = $name;
$activityStatusType[$activityindex][$fieldindex]['label'] = $label;
$activityStatusType[$activityindex][$fieldindex]['datatype'] = $datatype;
$activityStatusType[$activityindex][$fieldindex]['value'] = $value;
......
......@@ -294,7 +294,8 @@ WHERE a.id = %1
}
$activity['fields'][] = array(
'label' => 'Client',
'name' => 'Client',
'label' => ts('Client'),
'value' => $this->redact($client),
'type' => 'String',
);
......@@ -308,9 +309,11 @@ WHERE a.id = %1
// Maybe not the best solution.
$targetNames = CRM_Activity_BAO_ActivityContact::getNames($activityDAO->id, $targetID);
$processTarget = FALSE;
$name = 'With Contact(s)';
$label = ts('With Contact(s)');
if (in_array($activityTypeInfo['name'], array('Email', 'Inbound Email'))) {
$processTarget = TRUE;
$name = 'Recipient';
$label = ts('Recipient');
}
if (!$processTarget) {
......@@ -340,6 +343,7 @@ WHERE a.id = %1
}
$activity['fields'][] = array(
'name' => $name,
'label' => $label,
'value' => implode('; ', $targetRedacted),
'type' => 'String',
......@@ -349,13 +353,20 @@ WHERE a.id = %1
// Activity Type info is a special field
$activity['fields'][] = array(
'name' => 'Activity Type',
'label' => ts('Activity Type'),
'value' => $activityTypeInfo['label'],
'type' => 'String',
);
$activity['fields'][] = array(
'name' => 'Subject',
'label' => ts('Subject'),
// TODO: Why is this being escaped at this point in the flow? Should
// this just be done in the tpl where all the other fields get escaped?
// Is anything depending on this currently or is it just a result of
// the see-sawing and some double-escaping that went back and forth
// for a few years?
'value' => htmlspecialchars($this->redact($activityDAO->subject)),
'type' => 'Memo',
);
......@@ -368,6 +379,7 @@ WHERE a.id = %1
);
}
$activity['fields'][] = array(
'name' => 'Created By',
'label' => ts('Created By'),
'value' => $this->redact($creator),
'type' => 'String',
......@@ -397,6 +409,7 @@ WHERE a.id = %1
}
$activity['fields'][] = array(
'name' => 'Reported By',
'label' => ts('Reported By'),
'value' => $this->redact($reporter),
'type' => 'String',
......@@ -415,6 +428,7 @@ WHERE a.id = %1
}
$assigneeContacts = implode(', ', $assignee_contact_names);
$activity['fields'][] = array(
'name' => 'Assigned to',
'label' => ts('Assigned to'),
'value' => $assigneeContacts,
'type' => 'String',
......@@ -423,6 +437,7 @@ WHERE a.id = %1
if ($activityDAO->medium_id) {
$activity['fields'][] = array(
'name' => 'Medium',
'label' => ts('Medium'),
'value' => CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'medium_id', $activityDAO->medium_id),
'type' => 'String',
......@@ -430,18 +445,21 @@ WHERE a.id = %1
}
$activity['fields'][] = array(
'name' => 'Location',
'label' => ts('Location'),
'value' => $activityDAO->location,
'type' => 'String',
);
$activity['fields'][] = array(
'name' => 'Date and Time',
'label' => ts('Date and Time'),
'value' => $activityDAO->activity_date_time,
'type' => 'Date',
);
$activity['fields'][] = array(
'name' => 'Details',
'label' => ts('Details'),
'value' => $this->redact(CRM_Utils_String::stripAlternatives($activityDAO->details)),
'type' => 'Memo',
......@@ -450,12 +468,14 @@ WHERE a.id = %1
// Skip Duration field if empty (to avoid " minutes" output). Might want to do this for all fields at some point. dgg
if ($activityDAO->duration) {
$activity['fields'][] = array(
'name' => 'Duration',
'label' => ts('Duration'),
'value' => $activityDAO->duration . ' ' . ts('minutes'),
'type' => 'Int',
);
}
$activity['fields'][] = array(
'name' => 'Status',
'label' => ts('Status'),
'value' => CRM_Core_PseudoConstant::getLabel('CRM_Activity_DAO_Activity', 'activity_status_id',
$activityDAO->status_id
......@@ -464,6 +484,7 @@ WHERE a.id = %1
);
$activity['fields'][] = array(
'name' => 'Priority',
'label' => ts('Priority'),
'value' => CRM_Core_PseudoConstant::getLabel('CRM_Activity_DAO_Activity', 'priority_id',
$activityDAO->priority_id
......
......@@ -132,12 +132,14 @@
<h2>{ts}Case Activities{/ts}</h2>
{foreach from=$activities item=activity key=key}
<table class ="report-layout">
{foreach from=$activity item=field name=fieldloop}
<tr class="crm-case-report-activity-{$field.label}">
{foreach from=$activity item=field}
{* TODO: Using an unmunged field in the css class would have always been problematic? Since it sometimes has spaces. *}
<tr class="crm-case-report-activity-{$field.name}">
<th scope="row" class="label">{$field.label|escape}</th>
{if $field.label eq 'Activity Type' or $field.label eq 'Status'}
{if $field.name eq 'Activity Type' or $field.name eq 'Status'}
<td class="bold">{$field.value|escape}</td>
{elseif $field.label eq 'Details' or $field.label eq 'Subject'}
{* TODO: See note in CRM/Case/XMLProcessor/Report.php: Subject is already escaped in the php file so that's why it's not escaped here, but should that be reversed? *}
{elseif $field.name eq 'Details' or $field.name eq 'Subject'}
<td>{$field.value}</td>
{else}
<td>{$field.value|escape}</td>
......
......@@ -25,6 +25,7 @@
<Fields>
{foreach from=$activity.fields item=field}
<Field>
<Name>{$field.name|escape}</Name>
<Label>{$field.label|escape}</Label>
{if $field.category}
<Category>{$field.category|escape}</Category>
......@@ -40,6 +41,7 @@
<GroupName>{$customGroupName|escape}</GroupName>
{foreach from=$customGroup item=field}
<Field>
<Name>{*TODO*}</Name>
<Label>{$field.label|escape}</Label>
<Value>{$field.value|escape}</Value>
<Type>{$field.type}</Type>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment