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
46d76120
Unverified
Commit
46d76120
authored
2 years ago
by
colemanw
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #23764 from eileenmcnaughton/activity_update_mutli
#2706
#2308
fix activity import to update multi-select fields
parents
18409515
81882fd1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Activity/Import/Form/MapField.php
+39
-38
39 additions, 38 deletions
CRM/Activity/Import/Form/MapField.php
CRM/Activity/Import/Parser/Activity.php
+3
-2
3 additions, 2 deletions
CRM/Activity/Import/Parser/Activity.php
with
42 additions
and
40 deletions
CRM/Activity/Import/Form/MapField.php
+
39
−
38
View file @
46d76120
...
...
@@ -25,6 +25,42 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
*/
public
$submitOnce
=
TRUE
;
/**
* Validate that required fields are present.
*
* @param array $importKeys
*
* return string|null
*/
protected
static
function
validateRequiredFields
(
array
$importKeys
):
?string
{
$fieldMessage
=
NULL
;
if
(
in_array
(
'activity_id'
,
$importKeys
,
TRUE
))
{
return
NULL
;
}
$requiredFields
=
[
'target_contact_id'
=>
ts
(
'Contact ID'
),
'activity_date_time'
=>
ts
(
'Activity Date'
),
'activity_subject'
=>
ts
(
'Activity Subject'
),
'activity_type_id'
=>
ts
(
'Activity Type ID'
),
];
$contactFieldsBelowWeightMessage
=
self
::
validateRequiredContactMatchFields
(
'Individual'
,
$importKeys
);
foreach
(
$requiredFields
as
$field
=>
$title
)
{
if
(
!
in_array
(
$field
,
$importKeys
))
{
if
(
$field
===
'target_contact_id'
)
{
if
(
!
$contactFieldsBelowWeightMessage
||
in_array
(
'external_identifier'
,
$importKeys
))
{
continue
;
}
$fieldMessage
.
=
ts
(
'Missing required contact matching fields.'
)
.
$contactFieldsBelowWeightMessage
.
'<br />'
;
}
$fieldMessage
.
=
ts
(
'Missing required field: %1'
,
[
1
=>
$title
])
.
'<br />'
;
}
}
return
$fieldMessage
;
}
/**
* Build the form object.
*
...
...
@@ -121,49 +157,14 @@ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField {
// define so we avoid notices below
$errors
[
'_qf_default'
]
=
''
;
$fieldMessage
=
NULL
;
if
(
!
array_key_exists
(
'savedMapping'
,
$fields
))
{
$importKeys
=
[];
foreach
(
$fields
[
'mapper'
]
as
$mapperPart
)
{
$importKeys
[]
=
$mapperPart
[
0
];
}
// FIXME: should use the schema titles, not redeclare them
$requiredFields
=
[
'target_contact_id'
=>
ts
(
'Contact ID'
),
'activity_date_time'
=>
ts
(
'Activity Date'
),
'activity_subject'
=>
ts
(
'Activity Subject'
),
'activity_type_id'
=>
ts
(
'Activity Type ID'
),
];
$contactFieldsBelowWeightMessage
=
self
::
validateRequiredContactMatchFields
(
'Individual'
,
$importKeys
);
foreach
(
$requiredFields
as
$field
=>
$title
)
{
if
(
!
in_array
(
$field
,
$importKeys
))
{
if
(
$field
===
'target_contact_id'
)
{
if
(
!
$contactFieldsBelowWeightMessage
||
in_array
(
'external_identifier'
,
$importKeys
))
{
continue
;
}
else
{
$errors
[
'_qf_default'
]
.
=
ts
(
'Missing required contact matching fields.'
)
.
$contactFieldsBelowWeightMessage
.
'<br />'
;
}
}
elseif
(
$field
===
'activity_type_id'
)
{
if
(
in_array
(
'activity_label'
,
$importKeys
))
{
continue
;
}
else
{
$errors
[
'_qf_default'
]
.
=
ts
(
'Missing required field: Provide %1 or %2'
,
[
1
=>
$title
,
2
=>
'Activity Type Label'
,
])
.
'<br />'
;
}
}
else
{
$errors
[
'_qf_default'
]
.
=
ts
(
'Missing required field: %1'
,
[
1
=>
$title
])
.
'<br />'
;
}
}
$missingFields
=
self
::
validateRequiredFields
(
$importKeys
);
if
(
$missingFields
)
{
$errors
[
'_qf_default'
]
=
$missingFields
;
}
}
...
...
This diff is collapsed.
Click to expand it.
CRM/Activity/Import/Parser/Activity.php
+
3
−
2
View file @
46d76120
...
...
@@ -103,8 +103,9 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Import_Parser {
$disp
=
$params
[
'external_identifier'
];
}
}
throw
new
CRM_Core_Exception
(
'No matching Contact found for ('
.
$disp
.
')'
);
if
(
empty
(
$params
[
'id'
]))
{
throw
new
CRM_Core_Exception
(
'No matching Contact found for ('
.
$disp
.
')'
);
}
}
if
(
!
empty
(
$params
[
'external_identifier'
]))
{
$targetContactId
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Contact_DAO_Contact'
,
...
...
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