Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Usha Matisson
Core
Commits
87a12723
Commit
87a12723
authored
11 years ago
by
Kurund Jalmi
Browse files
Options
Downloads
Plain Diff
Merge pull request #2264 from dlobo/CRM-13606
CRM-13606 - Include / Exclude custom Search does not work properly
parents
109a3089
811a3ea4
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/Contact/Form/Search/Custom/Group.php
+24
-17
24 additions, 17 deletions
CRM/Contact/Form/Search/Custom/Group.php
with
24 additions
and
17 deletions
CRM/Contact/Form/Search/Custom/Group.php
+
24
−
17
View file @
87a12723
...
...
@@ -303,16 +303,19 @@ class CRM_Contact_Form_Search_Custom_Group
//search for smart group contacts
foreach
(
$this
->
_excludeGroups
as
$keys
=>
$values
)
{
if
(
in_array
(
$values
,
$smartGroup
))
{
$ssId
=
CRM_Utils_Array
::
key
(
$values
,
$smartGroup
);
$smartSql
=
CRM_Contact_BAO_SavedSearch
::
contactIDsSQL
(
$ssId
);
$smartSql
=
$smartSql
.
" AND contact_a.id NOT IN (
SELECT contact_id FROM civicrm_group_contact
WHERE civicrm_group_contact.group_id =
{
$values
}
AND civicrm_group_contact.status = 'Removed')"
;
$ssGroup
=
new
CRM_Contact_DAO_Group
();
$ssGroup
->
id
=
$values
;
if
(
!
$ssGroup
->
find
(
TRUE
))
{
CRM_Core_Error
::
fatal
();
}
CRM_Contact_BAO_GroupContactCache
::
load
(
$ssGroup
);
$smartSql
=
"
SELECT gcc.contact_id
FROM civicrm_group_contact_cache gcc
WHERE gcc.group_id =
{
$ssGroup
->
id
}
"
;
$smartGroupQuery
=
" INSERT IGNORE INTO Xg_
{
$this
->
_tableName
}
(contact_id)
$smartSql
"
;
CRM_Core_DAO
::
executeQuery
(
$smartGroupQuery
);
}
}
...
...
@@ -366,18 +369,22 @@ class CRM_Contact_Form_Search_Custom_Group
foreach
(
$this
->
_includeGroups
as
$keys
=>
$values
)
{
if
(
in_array
(
$values
,
$smartGroup
))
{
$ssGroup
=
new
CRM_Contact_DAO_Group
();
$ssGroup
->
id
=
$values
;
if
(
!
$ssGroup
->
find
(
TRUE
))
{
CRM_Core_Error
::
fatal
();
}
CRM_Contact_BAO_GroupContactCache
::
load
(
$ssGroup
);
$ssId
=
CRM_Utils_Array
::
key
(
$values
,
$smartGroup
);
$smartSql
=
CRM_Contact_BAO_SavedSearch
::
contactIDsSQL
(
$ssId
);
$smartSql
.
=
" AND contact_a.id NOT IN (
SELECT contact_id FROM civicrm_group_contact
WHERE civicrm_group_contact.group_id =
{
$values
}
AND civicrm_group_contact.status = 'Removed')"
;
$smartSql
=
"
SELECT gcc.contact_id
FROM civicrm_group_contact_cache gcc
WHERE gcc.group_id =
{
$ssGroup
->
id
}
"
;
//used only when exclude group is selected
if
(
$xGroups
!=
0
)
{
$smartSql
.
=
" AND contact_
a.
id NOT IN (SELECT contact_id FROM Xg_
{
$this
->
_tableName
}
)"
;
$smartSql
.
=
" AND
gcc.
contact_id NOT IN (SELECT contact_id FROM Xg_
{
$this
->
_tableName
}
)"
;
}
$smartGroupQuery
=
" INSERT IGNORE INTO Ig_
{
$this
->
_tableName
}
(contact_id)
...
...
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