Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Extensions
dataprocessor
Commits
1b3e7d5f
Commit
1b3e7d5f
authored
Mar 31, 2020
by
jaapjansma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with configuration contact source sub type filter.
parent
d72d732a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
1 deletion
+202
-1
CHANGELOG.md
CHANGELOG.md
+1
-0
Civi/DataProcessor/Source/Contact/ACLContactSource.php
Civi/DataProcessor/Source/Contact/ACLContactSource.php
+40
-0
Civi/DataProcessor/Source/Contact/ContactSource.php
Civi/DataProcessor/Source/Contact/ContactSource.php
+41
-1
Civi/DataProcessor/Source/Contact/HouseholdSource.php
Civi/DataProcessor/Source/Contact/HouseholdSource.php
+40
-0
Civi/DataProcessor/Source/Contact/IndividualSource.php
Civi/DataProcessor/Source/Contact/IndividualSource.php
+40
-0
Civi/DataProcessor/Source/Contact/OrganizationSource.php
Civi/DataProcessor/Source/Contact/OrganizationSource.php
+40
-0
No files found.
CHANGELOG.md
View file @
1b3e7d5f
...
...
@@ -14,6 +14,7 @@
*
Added Age field.
*
Added current user to contact filter.
*
Added data source for permissioned contact (#25).
*
Fixed issue with configuration contact source sub type filter.
# Version 1.3.0
...
...
Civi/DataProcessor/Source/Contact/ACLContactSource.php
View file @
1b3e7d5f
...
...
@@ -8,6 +8,9 @@ namespace Civi\DataProcessor\Source\Contact;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\DataFlowDescription
;
use
Civi\DataProcessor\DataFlow\MultipleDataFlows\PureSqlStatementJoin
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\AndClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\OrClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\SimpleWhereClause
;
use
Civi\DataProcessor\DataFlow\SqlTableDataFlow
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\PureSqlStatementClause
;
...
...
@@ -53,4 +56,41 @@ class ACLContactSource extends ContactSource {
$this
->
primaryDataFlow
->
addWhereClause
(
$clause
);
}
/**
* Adds an inidvidual filter to the data source
*
* @param $filter_field_alias
* @param $op
* @param $values
*
* @throws \Exception
*/
protected
function
addFilter
(
$filter_field_alias
,
$op
,
$values
)
{
if
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
OrClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
elseif
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'NOT IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'NOT LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
AndClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
else
{
parent
::
addFilter
(
$filter_field_alias
,
$op
,
$values
);
}
}
}
Civi/DataProcessor/Source/Contact/ContactSource.php
View file @
1b3e7d5f
...
...
@@ -6,6 +6,9 @@
namespace
Civi\DataProcessor\Source\Contact
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\AndClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\OrClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\SimpleWhereClause
;
use
Civi\DataProcessor\DataSpecification\DataSpecification
;
use
Civi\DataProcessor\Source\AbstractCivicrmEntitySource
;
...
...
@@ -60,4 +63,41 @@ class ContactSource extends AbstractCivicrmEntitySource {
);
}
}
\ No newline at end of file
/**
* Adds an inidvidual filter to the data source
*
* @param $filter_field_alias
* @param $op
* @param $values
*
* @throws \Exception
*/
protected
function
addFilter
(
$filter_field_alias
,
$op
,
$values
)
{
if
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
OrClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
elseif
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'NOT IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'NOT LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
AndClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
else
{
parent
::
addFilter
(
$filter_field_alias
,
$op
,
$values
);
}
}
}
Civi/DataProcessor/Source/Contact/HouseholdSource.php
View file @
1b3e7d5f
...
...
@@ -6,6 +6,9 @@
namespace
Civi\DataProcessor\Source\Contact
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\AndClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\OrClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\SimpleWhereClause
;
use
Civi\DataProcessor\DataSpecification\DataSpecification
;
use
Civi\DataProcessor\Source\AbstractCivicrmEntitySource
;
...
...
@@ -123,5 +126,42 @@ class HouseholdSource extends AbstractCivicrmEntitySource {
$this
->
addFilter
(
'contact_type'
,
'='
,
'Household'
);
}
/**
* Adds an inidvidual filter to the data source
*
* @param $filter_field_alias
* @param $op
* @param $values
*
* @throws \Exception
*/
protected
function
addFilter
(
$filter_field_alias
,
$op
,
$values
)
{
if
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
OrClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
elseif
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'NOT IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'NOT LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
AndClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
else
{
parent
::
addFilter
(
$filter_field_alias
,
$op
,
$values
);
}
}
}
Civi/DataProcessor/Source/Contact/IndividualSource.php
View file @
1b3e7d5f
...
...
@@ -6,6 +6,9 @@
namespace
Civi\DataProcessor\Source\Contact
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\AndClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\OrClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\SimpleWhereClause
;
use
Civi\DataProcessor\DataSpecification\DataSpecification
;
use
Civi\DataProcessor\Source\AbstractCivicrmEntitySource
;
...
...
@@ -103,5 +106,42 @@ class IndividualSource extends AbstractCivicrmEntitySource {
$this
->
addFilter
(
'contact_type'
,
'='
,
'Individual'
);
}
/**
* Adds an inidvidual filter to the data source
*
* @param $filter_field_alias
* @param $op
* @param $values
*
* @throws \Exception
*/
protected
function
addFilter
(
$filter_field_alias
,
$op
,
$values
)
{
if
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
OrClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
elseif
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'NOT IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'NOT LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
AndClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
else
{
parent
::
addFilter
(
$filter_field_alias
,
$op
,
$values
);
}
}
}
Civi/DataProcessor/Source/Contact/OrganizationSource.php
View file @
1b3e7d5f
...
...
@@ -6,6 +6,9 @@
namespace
Civi\DataProcessor\Source\Contact
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\AndClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\OrClause
;
use
Civi\DataProcessor\DataFlow\SqlDataFlow\SimpleWhereClause
;
use
Civi\DataProcessor\DataSpecification\DataSpecification
;
use
Civi\DataProcessor\Source\AbstractCivicrmEntitySource
;
...
...
@@ -115,5 +118,42 @@ class OrganizationSource extends AbstractCivicrmEntitySource {
$this
->
addFilter
(
'contact_type'
,
'='
,
'Organization'
);
}
/**
* Adds an inidvidual filter to the data source
*
* @param $filter_field_alias
* @param $op
* @param $values
*
* @throws \Exception
*/
protected
function
addFilter
(
$filter_field_alias
,
$op
,
$values
)
{
if
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
OrClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
elseif
(
$filter_field_alias
==
'contact_sub_type'
&&
$op
==
'NOT IN'
)
{
$contactTypeClauses
=
[];
foreach
(
$values
as
$value
)
{
$contactTypeSearchName
=
'%'
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
$value
.
\
CRM_Core_DAO
::
VALUE_SEPARATOR
.
'%'
;
$contactTypeClauses
[]
=
new
SimpleWhereClause
(
$this
->
getSourceName
(),
'contact_sub_type'
,
'NOT LIKE'
,
$contactTypeSearchName
,
'String'
,
TRUE
);
}
if
(
count
(
$contactTypeClauses
))
{
$contactTypeClause
=
new
AndClause
(
$contactTypeClauses
);
$entityDataFlow
=
$this
->
ensureEntity
();
$entityDataFlow
->
addWhereClause
(
$contactTypeClause
);
}
}
else
{
parent
::
addFilter
(
$filter_field_alias
,
$op
,
$values
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment