Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
a343ef28
Unverified
Commit
a343ef28
authored
5 years ago
by
Monish Deb
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #15950 from eileenmcnaughton/export_ref
[REF] Further cleanup on address handling in merge code.
parents
af8faeb1
d183e23a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Export/BAO/ExportProcessor.php
+51
-20
51 additions, 20 deletions
CRM/Export/BAO/ExportProcessor.php
with
51 additions
and
20 deletions
CRM/Export/BAO/ExportProcessor.php
+
51
−
20
View file @
a343ef28
...
...
@@ -91,6 +91,16 @@ class CRM_Export_BAO_ExportProcessor {
*/
protected
$ids
=
[];
/**
* Greeting options mapping to various greeting ids.
*
* This stores the option values for the addressee, postal_greeting & email_greeting
* option groups.
*
* @var array
*/
protected
$greetingOptions
=
[];
/**
* Get additional non-visible fields for address merge purposes.
*
...
...
@@ -390,6 +400,17 @@ class CRM_Export_BAO_ExportProcessor {
$this
->
setAdditionalFieldsForPostalExport
();
$this
->
setHouseholdMergeReturnProperties
();
$this
->
setGreetingStringsForSameAddressMerge
(
$formValues
);
$this
->
setGreetingOptions
();
}
/**
* Set the greeting options, if relevant.
*/
public
function
setGreetingOptions
()
{
if
(
$this
->
isMergeSameAddress
())
{
$this
->
greetingOptions
[
'addressee'
]
=
CRM_Core_OptionGroup
::
values
(
'addressee'
);
$this
->
greetingOptions
[
'postal_greeting'
]
=
CRM_Core_OptionGroup
::
values
(
'postal_greeting'
);
}
}
/**
...
...
@@ -1905,23 +1926,15 @@ class CRM_Export_BAO_ExportProcessor {
*/
public
function
buildMasterCopyArray
(
$sql
,
$sharedAddress
=
FALSE
)
{
$addresseeOptions
=
CRM_Core_OptionGroup
::
values
(
'addressee'
);
$postalOptions
=
CRM_Core_OptionGroup
::
values
(
'postal_greeting'
);
$merge
=
$parents
=
[];
$dao
=
CRM_Core_DAO
::
executeQuery
(
$sql
);
while
(
$dao
->
fetch
())
{
$masterID
=
$dao
->
master_id
;
$copyID
=
$dao
->
copy_id
;
$copyAddressee
=
$dao
->
copy_addressee
;
$this
->
cacheContactGreetings
((
int
)
$dao
->
master_contact_id
);
$this
->
cacheContactGreetings
((
int
)
$dao
->
copy_contact_id
);
$masterPostalGreeting
=
$this
->
getContactGreeting
((
int
)
$dao
->
master_contact_id
,
'postal_greeting'
,
$dao
->
master_postal_greeting
);
$masterAddressee
=
$this
->
getContactGreeting
((
int
)
$dao
->
master_contact_id
,
'addressee'
,
$dao
->
master_addressee
);
$copyPostalGreeting
=
$this
->
getContactGreeting
((
int
)
$dao
->
copy_contact_id
,
'postal_greeting'
,
$dao
->
copy_postal_greeting
);
$copyAddressee
=
$this
->
getContactGreeting
((
int
)
$dao
->
copy_contact_id
,
'addressee'
,
$dao
->
copy_addressee
);
if
(
!
isset
(
$merge
[
$masterID
]))
{
// check if this is an intermediate child
...
...
@@ -1934,9 +1947,9 @@ class CRM_Export_BAO_ExportProcessor {
}
else
{
$merge
[
$masterID
]
=
[
'addressee'
=>
$
masterA
ddressee
,
'addressee'
=>
$
this
->
getContactGreeting
((
int
)
$dao
->
master_contact_id
,
'addressee'
,
$dao
->
master_a
ddressee
)
,
'copy'
=>
[],
'postalGreeting'
=>
$
masterP
ostal
G
reeting
,
'postalGreeting'
=>
$
this
->
getContactGreeting
((
int
)
$dao
->
master_contact_id
,
'p
ostal
_g
reeting
'
,
$dao
->
master_postal_greeting
)
,
];
$merge
[
$masterID
][
'emailGreeting'
]
=
&
$merge
[
$masterID
][
'postalGreeting'
];
}
...
...
@@ -1944,26 +1957,19 @@ class CRM_Export_BAO_ExportProcessor {
$parents
[
$copyID
]
=
$masterID
;
if
(
!
$sharedAddress
&&
!
array_key_exists
(
$copyID
,
$merge
[
$masterID
][
'copy'
]))
{
$copyPostalGreeting
=
$this
->
getContactPortionOfGreeting
((
int
)
$dao
->
copy_contact_id
,
(
int
)
$dao
->
copy_postal_greeting_id
,
'postal_greeting'
,
$dao
->
copy_postal_greeting
);
if
(
$copyPostalGreeting
)
{
$this
->
trimNonTokensFromAddressString
(
$copyPostalGreeting
,
$postalOptions
[
$dao
->
copy_postal_greeting_id
],
$this
->
getPostalGreetingTemplate
()
);
$merge
[
$masterID
][
'postalGreeting'
]
=
"
{
$merge
[
$masterID
][
'postalGreeting'
]
}
,
{
$copyPostalGreeting
}
"
;
// if there happens to be a duplicate, remove it
$merge
[
$masterID
][
'postalGreeting'
]
=
str_replace
(
"
{
$copyPostalGreeting
}
,"
,
""
,
$merge
[
$masterID
][
'postalGreeting'
]);
}
$copyAddressee
=
$this
->
getContactPortionOfGreeting
((
int
)
$dao
->
copy_contact_id
,
(
int
)
$dao
->
copy_addressee_id
,
'addressee'
,
$dao
->
copy_addressee
);
if
(
$copyAddressee
)
{
$this
->
trimNonTokensFromAddressString
(
$copyAddressee
,
$addresseeOptions
[
$dao
->
copy_addressee_id
],
$this
->
getAddresseeGreetingTemplate
()
);
$merge
[
$masterID
][
'addressee'
]
=
"
{
$merge
[
$masterID
][
'addressee'
]
}
, "
.
trim
(
$copyAddressee
);
}
}
$merge
[
$masterID
][
'copy'
][
$copyID
]
=
$copyAddressee
;
$merge
[
$masterID
][
'copy'
][
$copyID
]
=
$copyAddressee
??
$dao
->
copy_addressee
;
}
return
$merge
;
...
...
@@ -2426,4 +2432,29 @@ LIMIT $offset, $limit
);
}
/**
* Get the portion of the greeting string that relates to the contact.
*
* For example if the greeting id 'Dear Sarah' we are going to combine it with 'Dear Mike'
* so we want to strip the 'Dear ' and just get 'Sarah
* @param int $contactID
* @param int $greetingID
* @param string $type
* postal_greeting, addressee (email_greeting not currently implemented for unknown reasons.
* @param string $defaultGreeting
*
* @return mixed|string
*/
protected
function
getContactPortionOfGreeting
(
int
$contactID
,
int
$greetingID
,
string
$type
,
string
$defaultGreeting
)
{
$copyPostalGreeting
=
$this
->
getContactGreeting
(
$contactID
,
$type
,
$defaultGreeting
);
$template
=
$type
===
'postal_greeting'
?
$this
->
getPostalGreetingTemplate
()
:
$this
->
getAddresseeGreetingTemplate
();
if
(
$copyPostalGreeting
)
{
$copyPostalGreeting
=
$this
->
trimNonTokensFromAddressString
(
$copyPostalGreeting
,
$this
->
greetingOptions
[
$type
][
$greetingID
],
$template
);
}
return
$copyPostalGreeting
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment