Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-19435: IncludeSmartGroups Option added #9156

Merged
merged 2 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CRM/Contact/BAO/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ public static function getContactGroup(
$ignorePermission = FALSE,
$onlyPublicGroups = FALSE,
$excludeHidden = TRUE,
$groupId = NULL
$groupId = NULL,
$includeSmartGroups = FALSE
Copy link
Member

@monishdeb monishdeb Oct 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jainabhishek14 you need to also document the new parameter $includeSmartGroups in the function description as

 @param bool $includeSmartGroups 
                     [short description]

Everything else is working fine :)

) {
if ($count) {
$select = 'SELECT count(DISTINCT civicrm_group_contact.id)';
Expand All @@ -357,12 +358,13 @@ public static function getContactGroup(
civicrm_subscription_history.method as method';
}

$where = " WHERE contact_a.id = %1 AND civicrm_group.is_active = 1 AND saved_search_id IS NULL";

$where = " WHERE contact_a.id = %1 AND civicrm_group.is_active = 1";
if (!$includeSmartGroups) {
$where .= " AND saved_search_id IS NULL";
}
if ($excludeHidden) {
$where .= " AND civicrm_group.is_hidden = 0 ";
}

$params = array(1 => array($contactId, 'Integer'));
if (!empty($status)) {
$where .= ' AND civicrm_group_contact.status = %2';
Expand Down
8 changes: 4 additions & 4 deletions CRM/Contact/Page/View/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class CRM_Contact_Page_View_GroupContact extends CRM_Core_Page {
*/
public function browse() {

$count = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, NULL, NULL, TRUE);
$count = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, NULL, NULL, TRUE, FALSE, FALSE, TRUE, NULL, TRUE);

$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
$pending = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Pending');
$out = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Removed');
$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added', NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE);
$pending = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Pending', NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE);
$out = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Removed', NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE);

// keep track of all 'added' contact groups so we can remove them from the smart group
// section
Expand Down