CRM-15301 - Sorted order is not respected in 'Export Contacts' csv
authoratif-shaikh <shaikh388@gmail.com>
Thu, 16 Oct 2014 14:05:35 +0000 (19:35 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Thu, 16 Oct 2014 14:05:35 +0000 (19:35 +0530)
https://issues.civicrm.org/jira/browse/CRM-15301

CRM/Activity/Selector/Search.php
CRM/Case/Selector/Search.php
CRM/Contact/Form/Search.php
CRM/Contribute/Selector/Search.php
CRM/Event/Selector/Search.php
CRM/Export/BAO/Export.php
CRM/Member/Selector/Search.php

index 0bd140e84d3dadcfcfbaa3d88652b43b2e50cb5f..7b69027c095bec2a7df19fe677a54b2eb308e075 100644 (file)
@@ -396,7 +396,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
         ),
         array(
           'name' => ts('Status'),
-          'sort' => 'status_id',
+          'sort' => 'activity_status',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array(
index 72b8c74453089cc156731f045ca088eea99d9297..cc97a36e66050982b9bd58390fa637704dfcbf3e 100644 (file)
@@ -449,7 +449,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
         ),
         array(
           'name' => ts('Case Type'),
-          'sort' => 'case_type_id',
+          'sort' => 'case_type',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array(
index 2f422efb05e8ed96f840595d77570b7291387234..f9d1d1717803787fe780d2d1629515019bd668f1 100644 (file)
@@ -461,7 +461,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search {
     $selectedContactIds = array();
     $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues);
     // We use ajax to handle selections only if the search results component_mode is set to "contacts"
-    if ($qfKeyParam && $this->get('component_mode') <= 1) {
+    if ($qfKeyParam && ($this->get('component_mode') <= 1 || $this->get('component_mode') == 7)) {
       $this->addClass('crm-ajax-selection-form');
       $qfKeyParam = "civicrm search {$qfKeyParam}";
       $selectedContactIdsArr = CRM_Core_BAO_PrevNextCache::getSelection($qfKeyParam);
index 7166d025e448b9dcde094008517e0dce02065db1..6c96eba78e13d803dcdec2a193a37834019d360f 100644 (file)
@@ -477,7 +477,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
         array(
           array(
             'name' => ts('Type'),
-            'sort'      => 'financial_type_id',
+            'sort'      => 'financial_type',
             'direction' => CRM_Utils_Sort::DONTCARE,
           ),
           array(
@@ -497,7 +497,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
           ),
           array(
             'name' => ts('Status'),
-            'sort' => 'contribution_status_id',
+            'sort' => 'contribution_status',
             'direction' => CRM_Utils_Sort::DONTCARE,
           ),
           array(
index c81664a5583665cb60e8c888de79c20076fd72e0..c3709486e77570cbe9bdc2551cac00ce9e5a46be 100644 (file)
@@ -464,12 +464,12 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
         ),
         array(
           'name' => ts('Fee Level'),
-          'sort' => 'fee_level',
+          'sort' => 'participant_fee_level',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array(
           'name' => ts('Amount'),
-          'sort' => 'fee_amount',
+          'sort' => 'participant_fee_amount',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array(
index 0ceeb076a6fde4c7807e0df800c8852d7c82f6db..1da2248ba1a66eeabdfcbf03aed616c83beb95a7 100644 (file)
@@ -400,6 +400,9 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
       FALSE, TRUE, TRUE, NULL, $queryOperator
     );
 
+    //sort by state
+    //CRM-15301
+    $query->_sort = $order;
     list($select, $from, $where, $having) = $query->query();
 
     if ($mergeSameHousehold == 1) {
@@ -590,11 +593,20 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
       $groupBy = " GROUP BY civicrm_activity.id ";
     }
     $queryString .= $groupBy;
+
+    // always add contact_a.id to the ORDER clause
+    // so the order is deterministic
+    //CRM-15301
+    if (strpos('contact_a.id', $order) === FALSE) {
+      $order .= ", contact_a.id";
+    }
+
     if ($order) {
       list($field, $dir) = explode(' ', $order, 2);
       $field = trim($field);
       if (!empty($returnProperties[$field])) {
-        // $queryString .= " ORDER BY $order";
+        //CRM-15301
+        $queryString .= " ORDER BY $order";
       }
     }
 
index 813a6fe5e02946feaa6f66349c19e485a329d7fe..9e21b4cb4daa4d0ed15802dba7fbfd1fd3721596 100644 (file)
@@ -477,7 +477,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C
       self::$_columnHeaders = array(
         array(
           'name' => ts('Type'),
-          'sort' => 'membership_type_id',
+          'sort' => 'membership_type',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array('name' => ts('Member Since'),
@@ -501,7 +501,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C
         ),
         array(
           'name' => ts('Status'),
-          'sort' => 'status_id',
+          'sort' => 'membership_status',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ),
         array(