* (reference ) an assoc array to hold the flattened values.
*
* @return CRM_Contact_BAO_Group
- * @static
*/
public static function retrieve(&$params, &$defaults) {
$group = new CRM_Contact_DAO_Group();
* Group id.
*
* @return NULL
- * @static
*/
public static function discard($id) {
CRM_Utils_Hook::pre('delete', 'Group', $id, CRM_Core_DAO::$_nullArray);
*
* @return array
* this array contains the list of members for this group id
- * @static
*/
public static function &getMember($groupID, $useCache = TRUE) {
$params = array(array('group', 'IN', array($groupID => 1), 0, 0));
*
* @return string
* the permission that the user has (or NULL)
- * @static
*/
public static function checkPermission($id) {
$allGroups = CRM_Core_PseudoConstant::allGroup();
*
* @return CRM_Contact_BAO_Group|NULL
* The new group BAO (if created)
- * @static
*/
public static function &create(&$params) {
*
* @return CRM_Contact_BAO_Group|NULL
* The new group BAO (if created)
- * @static
*/
public static function createSmartGroup(&$params) {
if (!empty($params['formValues'])) {
*
* @return CRM_Core_DAO|null
* DAO object on success, NULL otherwise
- * @static
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Group', $id, 'is_active', $isActive);
* @param bool $excludeHidden exclude hidden groups.
*
* @return string
- * @static
*/
public static function groupTypeCondition($groupType = NULL, $excludeHidden = TRUE) {
$value = NULL;
*
* @return array
* ( smartGroupId, ssId ) smart group id and saved search id
- * @static
*/
public static function createHiddenSmartGroup($params) {
$ssId = CRM_Utils_Array::value('saved_search_id', $params);
}
}
- // Get group counts
+ // Get group counts - executes one query for regular groups and another for smart groups
foreach ($groupsToCount as $table => $groups) {
- $where = "group_id IN (" . implode(',', $groups) . ")";
+ $where = "g.group_id IN (" . implode(',', $groups) . ")";
if ($table == 'civicrm_group_contact') {
- $where .= " AND status = 'Added'";
+ $where .= " AND g.status = 'Added'";
}
- $dao = CRM_Core_DAO::executeQuery("SELECT group_id, COUNT(id) as `count` FROM $table WHERE $where GROUP BY group_id");
+ // Exclude deleted contacts
+ $where .= " and c.id = g.contact_id AND c.is_deleted = 0";
+ $dao = CRM_Core_DAO::executeQuery("SELECT g.group_id, COUNT(g.id) as `count` FROM $table g, civicrm_contact c WHERE $where GROUP BY g.group_id");
while ($dao->fetch()) {
$values[$dao->group_id]['count'] = $dao->count;
}