}
if ($output == CRM_Core_Selector_Controller::EXPORT) {
- $csvHeaders = array(ts('Contact Id'), ts('Contact Type'));
+ $csvHeaders = array(ts('Contact ID'), ts('Contact Type'));
foreach ($this->getColHeads($action, $output) as $column) {
if (array_key_exists('name', $column)) {
$csvHeaders[] = $column['name'];
function buildPrevNextCache($sort) {
$cacheKey = 'civicrm search ' . $this->_key;
- // Get current page requested
+ // We should clear the cache in following conditions:
+ // 1. when starting from scratch, i.e new search
+ // 2. if records are sorted
+
+ // get current page requested
$pageNum = CRM_Utils_Request::retrieve('crmPID', 'Integer', CRM_Core_DAO::$_nullObject);
- // When starting from scratch, clear any old cache
- if (!$pageNum) {
+
+ // get the current sort order
+ $currentSortID = CRM_Utils_Request::retrieve('crmSID', 'String', CRM_Core_DAO::$_nullObject);
+
+ $session = CRM_Core_Session::singleton();
+
+ // get previous sort id
+ $previousSortID = $session->get('previousSortID');
+
+ // check for current != previous to ensure cache is not reset if paging is done without changing
+ // sort criteria
+ if (!$pageNum || (!empty($currentSortID) && $currentSortID != $previousSortID) ) {
CRM_Core_BAO_PrevNextCache::deleteItem(NULL, $cacheKey, 'civicrm_contact');
- $pageNum = 1;
+ // this means it's fresh search, so set pageNum=1
+ if (!$pageNum) {
+ $pageNum = 1;
+ }
+ }
+
+ // set the current sort as previous sort
+ if (!empty($currentSortID)) {
+ $session->set('previousSortID', $currentSortID);
}
$pageSize = CRM_Utils_Request::retrieve('crmRowCount', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, 50);
$this->fillupPrevNextCache($sort, $cacheKey);
}
elseif ($firstRecord >= $countRow) {
- $this->fillupPrevNextCache($sort, $cacheKey, $countRow, $firstRecord + 500);
+ $this->fillupPrevNextCache($sort, $cacheKey, $countRow, 500);
}
return $cacheKey;
}
'name' => ts('View'),
'url' => 'civicrm/contact/view',
'qs' => 'reset=1&cid=%%id%%',
+ 'class' => 'no-popup',
'title' => ts('View Contact Details'),
),
array(
$insertSQL = "
INSERT INTO civicrm_prevnext_cache ( entity_table, entity_id1, entity_id2, cacheKey, data )
-SELECT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name
+SELECT DISTINCT 'civicrm_contact', contact_a.id, contact_a.id, '$cacheKey', contact_a.display_name
";
$sql = str_replace($replaceSQL, $insertSQL, $sql);