<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
* Check to see if we have cache entries for this group
* if not, regenerate, else return
*
- * @param $groupIDs 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
*/
- static function check($groupIDs) {
+ public static function check($groupIDs) {
if (empty($groupIDs)) {
return TRUE;
}
* Common function that formulates the query to see which groups needs to be refreshed
* based on their cache date and the smartGroupCacheTimeOut
*
- * @param string $groupIDClause the clause which limits which groups we need to evaluate
- * @param boolean $includeHiddenGroups hidden groups are excluded by default
+ * @param string $groupIDClause
+ * The clause which limits which groups we need to evaluate.
+ * @param bool $includeHiddenGroups
+ * Hidden groups are excluded by default.
*
* @return string the sql query which lists the groups that need to be refreshed
* @static
- * @public
*/
- static function groupRefreshedClause($groupIDClause = null, $includeHiddenGroups = FALSE) {
+ public static function groupRefreshedClause($groupIDClause = null, $includeHiddenGroups = FALSE) {
$smartGroupCacheTimeout = self::smartGroupCacheTimeout();
$now = CRM_Utils_Date::getUTCTime();
* in a locking scenario when some other process might have refreshed things underneath
* this process
*
- * @param int $groupID the group ID
- * @param boolean $includeHiddenGroups hidden groups are excluded by default
+ * @param int $groupID
+ * The group ID.
+ * @param bool $includeHiddenGroups
+ * Hidden groups are excluded by default.
*
* @return string the sql query which lists the groups that need to be refreshed
* @static
- * @public
*/
- static function shouldGroupBeRefreshed($groupID, $includeHiddenGroups = FALSE) {
+ public static function shouldGroupBeRefreshed($groupID, $includeHiddenGroups = FALSE) {
$query = self::groupRefreshedClause("g.id = %1", $includeHiddenGroups);
$params = array(1 => array($groupID, 'Integer'));
*
* @param int/array $groupID groupID of group that we are checking against
* if empty, all groups are checked
- * @param int $limit limits the number of groups we evaluate
+ * @param int $limit
+ * Limits the number of groups we evaluate.
*
* @return boolean true if we did not regenerate, false if we did
*/
- static function loadAll($groupIDs = null, $limit = 0) {
+ public static function loadAll($groupIDs = null, $limit = 0) {
// ensure that all the smart groups are loaded
// this function is expensive and should be sparingly used if groupIDs is empty
if (empty($groupIDs)) {
$groupIDClause = null;
- $groupIDs = array( );
+ $groupIDs = array();
}
else {
if (!is_array($groupIDs)) {
/**
* FIXME: This function should not be needed, because the cache table should not be getting truncated
*/
- static function fillIfEmpty() {
+ public static function fillIfEmpty() {
if (!CRM_Core_DAO::singleValueQuery("SELECT COUNT(id) FROM civicrm_group_contact_cache")) {
self::loadAll();
}
/**
* @param int $groupID
*/
- static function add($groupID) {
+ public static function add($groupID) {
// first delete the current cache
self::remove($groupID);
if (!is_array($groupID)) {
* @param int $groupID
* @param $values
*/
- static function store(&$groupID, &$values) {
+ public static function store(&$groupID, &$values) {
$processed = FALSE;
// sort the values so we put group IDs in front and hence optimize
/**
* Change the cache_date
*
- * @param $groupID array(int)
- * @param $processed bool, whether the cache data was recently modified
+ * @param $groupID
+ * Array(int).
+ * @param $processed
+ * Bool, whether the cache data was recently modified.
*/
- static function updateCacheTime($groupID, $processed) {
+ public static function updateCacheTime($groupID, $processed) {
// only update cache entry if we had any values
if ($processed) {
// also update the group with cache date information
* cache date, i.e. the removal is not done if the group was recently
* loaded into the cache.
*
- * @param $groupID int the groupID to delete cache entries, NULL for all groups
- * @param $onceOnly boolean run the function exactly once for all groups.
+ * @param $groupID
+ * Int the groupID to delete cache entries, NULL for all groups.
+ * @param $onceOnly
+ * Boolean run the function exactly once for all groups.
*
- * @public
* @return void
* @static
*/
- static function remove($groupID = NULL, $onceOnly = TRUE) {
+ public static function remove($groupID = NULL, $onceOnly = TRUE) {
static $invoked = FALSE;
// typically this needs to happy only once per instance
if ($groupID == NULL) {
$invoked = TRUE;
- } else if (is_array($groupID)) {
+ }
+ elseif (is_array($groupID)) {
foreach ($groupID as $gid) {
unset(self::$_alreadyLoaded[$gid]);
}
- } else if ($groupID && array_key_exists($groupID, self::$_alreadyLoaded)) {
+ }
+ elseif ($groupID && array_key_exists($groupID, self::$_alreadyLoaded)) {
unset(self::$_alreadyLoaded[$groupID]);
}
* @param int $groupId
* @return bool - true if successful
*/
- static function removeContact($cid, $groupId = NULL) {
+ public static function removeContact($cid, $groupId = NULL) {
$cids = array();
// sanitize input
foreach ((array) $cid as $c) {
/**
* 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
+ * @param object $group
+ * The smart group that needs to be loaded.
+ * @param bool $force
+ * Should we force a search through.
*
*/
- static function load(&$group, $force = FALSE) {
+ public static function load(&$group, $force = FALSE) {
$groupID = $group->id;
$savedSearchID = $group->saved_search_id;
if (array_key_exists($groupID, self::$_alreadyLoaded) && !$force) {
/**
* @return int
*/
- static function smartGroupCacheTimeout() {
+ public static function smartGroupCacheTimeout() {
$config = CRM_Core_Config::singleton();
if (
* Note that this could potentially be a super slow function since
* it ensure that all contact groups are loaded in the cache
*
- * @param int $contactID
- * @param boolean $showHidden - hidden groups are shown only if this flag is set
+ * @param int $contactID
+ * @param bool $showHidden
+ * Hidden groups are shown only if this flag is set.
*
* @return array an array of groups that this contact belongs to
*/
- static function contactGroup($contactID, $showHidden = FALSE) {
+ public static function contactGroup($contactID, $showHidden = FALSE) {
if (empty($contactID)) {
return;
}
$prevContactID = $dao->contact_id;
if (!array_key_exists($dao->contact_id, $contactGroup)) {
$contactGroup[$dao->contact_id] =
- array( 'group' => array(), 'groupTitle' => array());
+ array('group' => array(), 'groupTitle' => array());
}
$contactGroup[$dao->contact_id]['group'][] =
'id' => $dao->group_id,
'title' => $dao->title,
'description' => $dao->description,
- 'children' => $dao->children
+ 'children' => $dao->children,
);
$contactGroup[$dao->contact_id]['groupTitle'][] = $dao->title;
}
}
}
-