Note that I added a group refresh to pick up the 'hard-adds'. I think the correct place to deal with this is in fact to alter the GroupContact Add functionality - ie.
IF (CRM_Core_DAO::executeQuery('SELECT id FROM civicrm_group_contact_cache WHERE group_id = 1 LIMIT 1)) {
// Add the contact just added to the group to the group_contact_cache table.
}
I started that a bit but I think it should be dealt with separately after this is resolved
}
if (!empty($params['organization_id'])) {
- $groupOrg = array();
$groupOrg = $params;
$groupOrg['group_id'] = $group->id;
CRM_Contact_BAO_GroupOrganization::add($groupOrg);
if (!array_key_exists($value[0], $this->_paramLookup)) {
$this->_paramLookup[$value[0]] = array();
}
- $this->_paramLookup[$value[0]][] = $value;
+ if ($value[0] !== 'group') {
+ // Just trying to unravel how group interacts here! This whole function is wieid.
+ $this->_paramLookup[$value[0]][] = $value;
+ }
}
}
$groupIds = NULL;
- $isSmart = FALSE;
$isNotOp = ($op == 'NOT IN' || $op == '!=');
$statii = array();
$statii[] = '"Added"';
}
- $skipGroup = FALSE;
+ $ssClause = $this->addGroupContactCache($value, NULL, "contact_a", $op);
+ $isSmart = (!$ssClause) ? FALSE : TRUE;
if (!is_array($value) &&
count($statii) == 1 &&
$statii[0] == '"Added"' &&
$isSmart = TRUE;
}
}
-
- $ssClause = $this->addGroupContactCache($value, NULL, "contact_a", $op);
- $isSmart = (!$ssClause) ? FALSE : $isSmart;
$groupClause = NULL;
if (!$isSmart) {
CRM_Contact_BAO_GroupContactCache::load($group);
}
}
+ if ($group->N == 0) {
+ return NULL;
+ }
if (!$tableAlias) {
$tableAlias = "`civicrm_group_contact_cache_";
'title' => 'Child Group',
'description' => 'Child Group',
'visibility' => 'User and User Admin Only',
- 'parents' => $parentGroup->id,
+ 'parents' => $parentGroup['id'],
'is_active' => 1,
);
$childGroup = $this->callAPISuccess('Group', 'create', $groupParams2);
$parentContactParams = array(
'first_name' => 'Parent1 Fname',
'last_name' => 'Parent1 Lname',
- 'group' => array($parentGroup->id => 1),
+ 'group' => array($parentGroup['id'] => 1),
);
$parentContact = Contact::createIndividual($parentContactParams);
$childContactParams = array(
'first_name' => 'Child1 Fname',
'last_name' => 'Child2 Lname',
- 'group' => array($childGroup->id => 1),
+ 'group' => array($childGroup['id'] => 1),
);
$childContact = Contact::createIndividual($childContactParams);
// Check if searching by parent group returns both parent and child group contacts
$searchParams = array(
- 'group' => $parentGroup->id,
+ 'group' => $parentGroup['id'],
);
$result = $this->callAPISuccess('contact', 'get', $searchParams);
$validContactIds = array($parentContact, $childContact);
// Check if searching by child group returns just child group contacts
$searchParams = array(
- 'group' => $childGroup->id,
+ 'group' => $childGroup['id'],
);
$result = $this->callAPISuccess('contact', 'get', $searchParams);
$validChildContactIds = array($childContact);
$this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupID, 'contact_id' => $individualID, 'status' => 'Added'));
$this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupID, 'contact_id' => $householdID, 'status' => 'Added'));
+ // Refresh the cache for test purposes. It would be better to alter to alter the GroupContact add function to add contacts to the cache.
+ CRM_Contact_BAO_GroupContactCache::remove($groupID, FALSE);
$query = new CRM_Contact_BAO_Query(
array(array('group', 'IN', array($groupID), 0, 0)),
array('contact_id')
$queryString = implode(' ', $sql);
$dao = CRM_Core_DAO::executeQuery($queryString);
$this->assertEquals(3, $dao->N);
+ $this->assertFalse(strstr(implode(' ', $sql), ' OR '));
}
}