X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FGroupContactCache.php;h=bd0115dc10fcd4013a82122a0107e7559dd5c276;hb=6594935cdf40a89db938cab053596b776e011bc7;hp=a88d317325675d0aa44f7623b0036b4d1ed86331;hpb=c6d1eb051796a391308b48dda2f02523a3123258;p=civicrm-core.git diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index a88d317325..bd0115dc10 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -40,9 +40,7 @@ class CRM_Contact_BAO_GroupContactCache extends CRM_Contact_DAO_GroupContactCach * Check to see if we have cache entries for this group * if not, regenerate, else return * - * @param $groupIDs - * - * @internal param int $groupID groupID of group that we are checking against + * @param $groupIDs of group that we are checking against * * @return boolean true if we did not regenerate, false if we did */ @@ -200,7 +198,7 @@ AND g.refresh_date IS NULL } /** - * @param $groupID + * @param int $groupID */ static function add($groupID) { // first delete the current cache @@ -218,7 +216,7 @@ AND g.refresh_date IS NULL } /** - * @param $groupID + * @param int $groupID * @param $values */ static function store(&$groupID, &$values) { @@ -387,7 +385,31 @@ WHERE id = %1 } /** - * load the smart group cache for a saved search + * Removes one or more contacts from the smart group cache + * @param int|array $cid + * @param int $groupId + * @return bool - true if successful + */ + static function removeContact($cid, $groupId = NULL) { + $cids = array(); + // sanitize input + foreach ((array) $cid as $c) { + $cids[] = CRM_Utils_Type::escape($c, 'Integer'); + } + if ($cids) { + $condition = count($cids) == 1 ? "= {$cids[0]}" : "IN (" . implode(',', $cids) . ")"; + if ($groupId) { + $condition .= " AND group_id = " . CRM_Utils_Type::escape($groupId, 'Integer'); + } + $sql = "DELETE FROM civicrm_group_contact_cache WHERE contact_id $condition"; + CRM_Core_DAO::executeQuery($sql); + return TRUE; + } + return FALSE; + } + + /** + * Load the smart group cache for a saved search * * @param object $group - the smart group that needs to be loaded * @param boolean $force - should we force a search through