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
58e7f004
Unverified
Commit
58e7f004
authored
5 years ago
by
Seamus Lee
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #15519 from eileenmcnaughton/dedupe
[REF] minor extraction with code to build dedupe arrays
parents
86d75e4b
6704a926
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/Dedupe/Merger.php
+52
-37
52 additions, 37 deletions
CRM/Dedupe/Merger.php
with
52 additions
and
37 deletions
CRM/Dedupe/Merger.php
+
52
−
37
View file @
58e7f004
...
...
@@ -1092,43 +1092,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m
continue
;
}
foreach
([
'main'
=>
$main
,
'other'
=>
$other
]
as
$moniker
=>
$contact
)
{
$value
=
$label
=
CRM_Utils_Array
::
value
(
$field
,
$contact
);
$fieldSpec
=
$fields
[
$field
];
if
(
!
empty
(
$fieldSpec
[
'serialize'
])
&&
is_array
(
$value
))
{
// In practice this only applies to preferred_communication_method as the sub types are skipped above
// and no others are serialized.
$labels
=
[];
foreach
(
$value
as
$individualValue
)
{
$labels
[]
=
CRM_Core_PseudoConstant
::
getLabel
(
'CRM_Contact_BAO_Contact'
,
$field
,
$individualValue
);
}
$label
=
implode
(
', '
,
$labels
);
// We serialize this due to historic handling but it's likely that if we just left it as an
// array all would be well & we would have less code.
$value
=
CRM_Core_DAO
::
serializeField
(
$value
,
$fieldSpec
[
'serialize'
]);
}
elseif
(
!
empty
(
$fieldSpec
[
'type'
])
&&
$fieldSpec
[
'type'
]
==
CRM_Utils_Type
::
T_DATE
)
{
if
(
$value
)
{
$value
=
str_replace
(
'-'
,
''
,
$value
);
$label
=
CRM_Utils_Date
::
customFormat
(
$label
);
}
else
{
$value
=
"null"
;
}
}
elseif
(
!
empty
(
$fields
[
$field
][
'type'
])
&&
$fields
[
$field
][
'type'
]
==
CRM_Utils_Type
::
T_BOOLEAN
)
{
if
(
$label
===
'0'
)
{
$label
=
ts
(
'[ ]'
);
}
if
(
$label
===
'1'
)
{
$label
=
ts
(
'[x]'
);
}
}
elseif
(
!
empty
(
$fieldSpec
[
'pseudoconstant'
]))
{
$label
=
CRM_Core_PseudoConstant
::
getLabel
(
'CRM_Contact_BAO_Contact'
,
$field
,
$value
);
}
elseif
(
$field
==
'current_employer_id'
&&
!
empty
(
$value
))
{
$label
=
"
$value
("
.
CRM_Contact_BAO_Contact
::
displayName
(
$value
)
.
")"
;
}
list
(
$label
,
$value
)
=
self
::
getFieldValueAndLabel
(
$field
,
$contact
);
$rows
[
"move_
$field
"
][
$moniker
]
=
$label
;
if
(
$moniker
==
'other'
)
{
//CRM-14334
...
...
@@ -2550,4 +2514,55 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m
return
$keysToIgnore
;
}
/**
* Get the field value & label for the given field.
*
* @param $field
* @param $contact
*
* @return array
* @throws \Exception
*/
private
static
function
getFieldValueAndLabel
(
$field
,
$contact
):
array
{
$fields
=
self
::
getMergeFieldsMetadata
();
$value
=
$label
=
CRM_Utils_Array
::
value
(
$field
,
$contact
);
$fieldSpec
=
$fields
[
$field
];
if
(
!
empty
(
$fieldSpec
[
'serialize'
])
&&
is_array
(
$value
))
{
// In practice this only applies to preferred_communication_method as the sub types are skipped above
// and no others are serialized.
$labels
=
[];
foreach
(
$value
as
$individualValue
)
{
$labels
[]
=
CRM_Core_PseudoConstant
::
getLabel
(
'CRM_Contact_BAO_Contact'
,
$field
,
$individualValue
);
}
$label
=
implode
(
', '
,
$labels
);
// We serialize this due to historic handling but it's likely that if we just left it as an
// array all would be well & we would have less code.
$value
=
CRM_Core_DAO
::
serializeField
(
$value
,
$fieldSpec
[
'serialize'
]);
}
elseif
(
!
empty
(
$fieldSpec
[
'type'
])
&&
$fieldSpec
[
'type'
]
==
CRM_Utils_Type
::
T_DATE
)
{
if
(
$value
)
{
$value
=
str_replace
(
'-'
,
''
,
$value
);
$label
=
CRM_Utils_Date
::
customFormat
(
$label
);
}
else
{
$value
=
"null"
;
}
}
elseif
(
!
empty
(
$fields
[
$field
][
'type'
])
&&
$fields
[
$field
][
'type'
]
==
CRM_Utils_Type
::
T_BOOLEAN
)
{
if
(
$label
===
'0'
)
{
$label
=
ts
(
'[ ]'
);
}
if
(
$label
===
'1'
)
{
$label
=
ts
(
'[x]'
);
}
}
elseif
(
!
empty
(
$fieldSpec
[
'pseudoconstant'
]))
{
$label
=
CRM_Core_PseudoConstant
::
getLabel
(
'CRM_Contact_BAO_Contact'
,
$field
,
$value
);
}
elseif
(
$field
==
'current_employer_id'
&&
!
empty
(
$value
))
{
$label
=
"
$value
("
.
CRM_Contact_BAO_Contact
::
displayName
(
$value
)
.
")"
;
}
return
[
$label
,
$value
];
}
}
This diff is collapsed.
Click to expand it.
Rich
@artfulrobot
mentioned in issue
#1321 (closed)
·
5 years ago
mentioned in issue
#1321 (closed)
mentioned in issue #1321
Toggle commit list
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