else {
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
$cacheKey = "civicrm search {$qfKey}";
- $allCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey, "getall");
+ $allCids = Civi::service('prevnext')->getSelection($cacheKey, "getall");
$ids = array_keys($allCids[$cacheKey]);
$this->assign('totalSelectedVoters', count($ids));
}
if ($qfKeyParam && ($this->get('component_mode') <= CRM_Contact_BAO_Query::MODE_CONTACTS || $this->get('component_mode') == CRM_Contact_BAO_Query::MODE_CONTACTSRELATED)) {
$this->addClass('crm-ajax-selection-form');
$qfKeyParam = "civicrm search {$qfKeyParam}";
- $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
+ $selectedContactIdsArr = Civi::service('prevnext')->getSelection($qfKeyParam);
$selectedContactIds = array_keys($selectedContactIdsArr[$qfKeyParam]);
}
// rather than prevnext cache table for most of the task actions except export where we rebuild query to fetch
// final result set
if ($useTable) {
- $allCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey, "getall");
+ $allCids = Civi::service('prevnext')->getSelection($cacheKey, "getall");
}
else {
$allCids[$cacheKey] = self::getContactIds($form);
}
else {
// fetching selected contact ids of passed cache key
- $selectedCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey);
+ $selectedCids = Civi::service('prevnext')->getSelection($cacheKey);
foreach ($selectedCids[$cacheKey] as $selectedCid => $ignore) {
if ($useTable) {
$insertString[] = " ( {$selectedCid} ) ";
$action = ($state == 'checked') ? 'select' : 'unselect';
Civi::service('prevnext')->markSelection($cacheKey, $action, $cId);
}
- $contactIds = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey);
+ $contactIds = Civi::service('prevnext')->getSelection($cacheKey);
$countSelectionCids = count($contactIds[$cacheKey]);
$arrRet = array('getCount' => $countSelectionCids);
CRM_Core_DAO::executeQuery($sql, $params);
}
+
/**
* Get the selections.
*
- * @param string $cacheKey
- * Cache key.
- * @param string $action
- * Action.
- * $action : get - get only selection records
- * getall - get all the records of the specified cache key
- * @param string $entity_table
- * Entity table.
+ * NOTE: This stub has been preserved because one extension in `universe`
+ * was referencing the function.
*
- * @return array|NULL
+ * @deprecated
+ * @see CRM_Core_PrevNextCache_Sql::getSelection()
*/
public static function getSelection($cacheKey, $action = 'get', $entity_table = 'civicrm_contact') {
- if (!$cacheKey) {
- return NULL;
- }
- $params = array();
-
- $entity_whereClause = " AND entity_table = '{$entity_table}'";
- if ($cacheKey && ($action == 'get' || $action == 'getall')) {
- $actionGet = ($action == "get") ? " AND is_selected = 1 " : "";
- $sql = "
-SELECT entity_id1, entity_id2 FROM civicrm_prevnext_cache
-WHERE cacheKey LIKE %1
- $actionGet
- $entity_whereClause
-ORDER BY id
-";
- $params[1] = array("{$cacheKey}%", 'String');
-
- $contactIds = array($cacheKey => array());
- $cIdDao = CRM_Core_DAO::executeQuery($sql, $params);
- while ($cIdDao->fetch()) {
- if ($cIdDao->entity_id1 == $cIdDao->entity_id2) {
- $contactIds[$cacheKey][$cIdDao->entity_id1] = 1;
- }
- }
- return $contactIds;
- }
+ return Civi::service('prevnext')->getSelection($cacheKey, $action, $entity_table);
}
/**
*/
public function markSelection($cacheKey, $action = 'unselect', $cIds = NULL, $entity_table = 'civicrm_contact');
+ /**
+ * Get the selections.
+ *
+ * @param string $cacheKey
+ * Cache key.
+ * @param string $action
+ * Action.
+ * $action : get - get only selection records
+ * getall - get all the records of the specified cache key
+ * @param string $entity_table
+ * Entity table.
+ *
+ * @return array|NULL
+ */
+ public function getSelection($cacheKey, $action = 'get', $entity_table = 'civicrm_contact');
+
}
CRM_Core_DAO::executeQuery($sql, $params);
}
+ /**
+ * Get the selections.
+ *
+ * @param string $cacheKey
+ * Cache key.
+ * @param string $action
+ * Action.
+ * $action : get - get only selection records
+ * getall - get all the records of the specified cache key
+ * @param string $entity_table
+ * Entity table.
+ *
+ * @return array|NULL
+ */
+ public function getSelection($cacheKey, $action = 'get', $entity_table = 'civicrm_contact') {
+ if (!$cacheKey) {
+ return NULL;
+ }
+ $params = array();
+
+ $entity_whereClause = " AND entity_table = '{$entity_table}'";
+ if ($cacheKey && ($action == 'get' || $action == 'getall')) {
+ $actionGet = ($action == "get") ? " AND is_selected = 1 " : "";
+ $sql = "
+SELECT entity_id1, entity_id2 FROM civicrm_prevnext_cache
+WHERE cacheKey LIKE %1
+ $actionGet
+ $entity_whereClause
+ORDER BY id
+";
+ $params[1] = array("{$cacheKey}%", 'String');
+
+ $contactIds = array($cacheKey => array());
+ $cIdDao = CRM_Core_DAO::executeQuery($sql, $params);
+ while ($cIdDao->fetch()) {
+ if ($cIdDao->entity_id1 == $cIdDao->entity_id2) {
+ $contactIds[$cacheKey][$cIdDao->entity_id1] = 1;
+ }
+ }
+ return $contactIds;
+ }
+ }
+
}