Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dataprocessor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Extensions
dataprocessor
Commits
cccab2c3
Commit
cccab2c3
authored
4 months ago
by
Klaas Eikelboom
Browse files
Options
Downloads
Patches
Plain Diff
Make the 'Display the groups of a contact' output format resilient against empty inputs.
parent
a0342dbe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
Civi/DataProcessor/FieldOutputHandler/GroupsOfContactFieldOutputHandler.php
+28
-22
28 additions, 22 deletions
.../FieldOutputHandler/GroupsOfContactFieldOutputHandler.php
with
29 additions
and
22 deletions
CHANGELOG.md
+
1
−
0
View file @
cccab2c3
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
*
Fixed issue with certain multi value fields on the filter configuration of a data source.
*
Fixed issue with certain multi value fields on the filter configuration of a data source.
*
Fixed issue with navigation menu.
*
Fixed issue with navigation menu.
*
Make the 'Display the groups of a contact' output format resilient against empty inputs.
# Version 1.115
# Version 1.115
...
...
This diff is collapsed.
Click to expand it.
Civi/DataProcessor/FieldOutputHandler/GroupsOfContactFieldOutputHandler.php
+
28
−
22
View file @
cccab2c3
...
@@ -6,11 +6,11 @@
...
@@ -6,11 +6,11 @@
namespace
Civi\DataProcessor\FieldOutputHandler
;
namespace
Civi\DataProcessor\FieldOutputHandler
;
use
Civi\DataProcessor\FieldOutputHandler\FieldOutput
;
use
Civi\DataProcessor\ProcessorType\AbstractProcessorType
;
use
Civi\DataProcessor\ProcessorType\AbstractProcessorType
;
use
CRM_Dataprocessor_ExtensionUtil
as
E
;
use
CRM_Dataprocessor_ExtensionUtil
as
E
;
use
Civi\DataProcessor\Source\SourceInterface
;
use
Civi\DataProcessor\Source\SourceInterface
;
use
Civi\DataProcessor\DataSpecification\FieldSpecification
;
use
Civi\DataProcessor\DataSpecification\FieldSpecification
;
use
Civi\DataProcessor\FieldOutputHandler\FieldOutput
;
use
Civi\DataProcessor\Exception\DataSourceNotFoundException
;
use
Civi\DataProcessor\Exception\DataSourceNotFoundException
;
use
Civi\DataProcessor\Exception\FieldNotFoundException
;
use
Civi\DataProcessor\Exception\FieldNotFoundException
;
...
@@ -66,7 +66,7 @@ class GroupsOfContactFieldOutputHandler extends AbstractFieldOutputHandler {
...
@@ -66,7 +66,7 @@ class GroupsOfContactFieldOutputHandler extends AbstractFieldOutputHandler {
* @param \Civi\DataProcessor\ProcessorType\AbstractProcessorType $processorType
* @param \Civi\DataProcessor\ProcessorType\AbstractProcessorType $processorType
*/
*/
public
function
initialize
(
$alias
,
$title
,
$configuration
)
{
public
function
initialize
(
$alias
,
$title
,
$configuration
)
{
list
(
$this
->
contactIdSource
,
$this
->
contactIdField
)
=
$this
->
initializeField
(
$configuration
[
'field'
],
$configuration
[
'datasource'
],
$alias
);
[
$this
->
contactIdSource
,
$this
->
contactIdField
]
=
$this
->
initializeField
(
$configuration
[
'field'
],
$configuration
[
'datasource'
],
$alias
);
$this
->
outputFieldSpecification
=
new
FieldSpecification
(
$this
->
contactIdField
->
name
,
'String'
,
$title
,
null
,
$alias
);
$this
->
outputFieldSpecification
=
new
FieldSpecification
(
$this
->
contactIdField
->
name
,
'String'
,
$title
,
null
,
$alias
);
if
(
isset
(
$configuration
[
'parent_group'
])
&&
$configuration
[
'parent_group'
])
{
if
(
isset
(
$configuration
[
'parent_group'
])
&&
$configuration
[
'parent_group'
])
{
$this
->
parent_group_id
=
civicrm_api3
(
'Group'
,
'getvalue'
,
array
(
'return'
=>
'id'
,
'name'
=>
$configuration
[
'parent_group'
]));
$this
->
parent_group_id
=
civicrm_api3
(
'Group'
,
'getvalue'
,
array
(
'return'
=>
'id'
,
'name'
=>
$configuration
[
'parent_group'
]));
...
@@ -83,29 +83,35 @@ class GroupsOfContactFieldOutputHandler extends AbstractFieldOutputHandler {
...
@@ -83,29 +83,35 @@ class GroupsOfContactFieldOutputHandler extends AbstractFieldOutputHandler {
*/
*/
public
function
formatField
(
$rawRecord
,
$formattedRecord
)
{
public
function
formatField
(
$rawRecord
,
$formattedRecord
)
{
$contactId
=
$rawRecord
[
$this
->
contactIdField
->
alias
];
$contactId
=
$rawRecord
[
$this
->
contactIdField
->
alias
];
$sql
=
"SELECT g.title, g.id
if
(
$contactId
)
{
$sql
=
"SELECT g.title, g.id
FROM civicrm_group g
FROM civicrm_group g
INNER JOIN civicrm_group_contact gc ON gc.group_id = g.id
INNER JOIN civicrm_group_contact gc ON gc.group_id = g.id
WHERE gc.status = 'Added' AND gc.contact_id = %1"
;
WHERE gc.status = 'Added' AND gc.contact_id = %1"
;
if
(
$this
->
parent_group_id
)
{
if
(
$this
->
parent_group_id
)
{
$childGroupIds
=
\CRM_Contact_BAO_GroupNesting
::
getDescendentGroupIds
([
$this
->
parent_group_id
],
FALSE
);
$childGroupIds
=
\CRM_Contact_BAO_GroupNesting
::
getDescendentGroupIds
([
$this
->
parent_group_id
],
FALSE
);
$sql
.
=
" AND gc.group_id IN ("
.
implode
(
", "
,
$childGroupIds
)
.
")"
;
$sql
.
=
" AND gc.group_id IN ("
.
implode
(
", "
,
$childGroupIds
)
.
")"
;
}
}
$sql
.
=
" ORDER BY g.title"
;
$sql
.
=
" ORDER BY g.title"
;
$sqlParams
[
1
]
=
array
(
$contactId
,
'Integer'
);
$sqlParams
[
1
]
=
[
$contactId
,
'Integer'
];
$dao
=
\CRM_Core_DAO
::
executeQuery
(
$sql
,
$sqlParams
);
$dao
=
\CRM_Core_DAO
::
executeQuery
(
$sql
,
$sqlParams
);
$rawValues
=
array
();
$rawValues
=
[];
$formattedValues
=
array
();
$formattedValues
=
[];
while
(
$dao
->
fetch
())
{
while
(
$dao
->
fetch
())
{
$rawValues
[]
=
array
(
$rawValues
[]
=
[
'group_id'
=>
$dao
->
id
,
'group_id'
=>
$dao
->
id
,
'group'
=>
$dao
->
title
,
'group'
=>
$dao
->
title
,
);
];
$formattedValues
[]
=
$dao
->
title
;
$formattedValues
[]
=
$dao
->
title
;
}
$output
=
new
FieldOutput
(
$rawValues
);
$output
->
formattedValue
=
implode
(
", "
,
$formattedValues
);
return
$output
;
}
else
{
// no contact id, show no groups.
return
new
FieldOutput
();
}
}
$output
=
new
FieldOutput
(
$rawValues
);
$output
->
formattedValue
=
implode
(
", "
,
$formattedValues
);
return
$output
;
}
}
/**
/**
...
@@ -175,7 +181,7 @@ class GroupsOfContactFieldOutputHandler extends AbstractFieldOutputHandler {
...
@@ -175,7 +181,7 @@ class GroupsOfContactFieldOutputHandler extends AbstractFieldOutputHandler {
* @return array
* @return array
*/
*/
public
function
processConfiguration
(
$submittedValues
)
{
public
function
processConfiguration
(
$submittedValues
)
{
list
(
$datasource
,
$field
)
=
explode
(
'::'
,
$submittedValues
[
'contact_id_field'
],
2
);
[
$datasource
,
$field
]
=
explode
(
'::'
,
$submittedValues
[
'contact_id_field'
],
2
);
$configuration
[
'field'
]
=
$field
;
$configuration
[
'field'
]
=
$field
;
$configuration
[
'datasource'
]
=
$datasource
;
$configuration
[
'datasource'
]
=
$datasource
;
$configuration
[
'parent_group'
]
=
isset
(
$submittedValues
[
'parent_group'
])
?
$submittedValues
[
'parent_group'
]
:
false
;
$configuration
[
'parent_group'
]
=
isset
(
$submittedValues
[
'parent_group'
])
?
$submittedValues
[
'parent_group'
]
:
false
;
...
...
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