First WIP for AJAX cleanup.
[civicrm-core.git] / CRM / Group / Page / AJAX.php
index 045e6119148ec7a4b5a91b780171cb5a85737421..2050348fa90b03bffabe6be09f346a31b3da6cdf 100644 (file)
@@ -50,24 +50,7 @@ class CRM_Group_Page_AJAX {
       CRM_Utils_JSON::output($groups);
     }
     else {
-
-      $sortMapper = array();
-      $columns = CRM_Utils_Array::value('columns', $params, array());
-      foreach ($columns as $key => $value) {
-        $sortMapper[$key] = $value['data'];
-      }
-
-      $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0;
-      $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25;
-      $sort = isset($_GET['order'][0]['column']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_GET['order'][0]['column'], 'Integer'), $sortMapper) : NULL;
-      $sortOrder = isset($_GET['order'][0]['dir']) ? CRM_Utils_Type::escape($_GET['order'][0]['dir'], 'String') : 'asc';
-
-      if ($sort && $sortOrder) {
-        $params['sortBy'] = $sort . ' ' . $sortOrder;
-      }
-
-      $params['page'] = ($offset / $rowCount) + 1;
-      $params['rp'] = $rowCount;
+      $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
 
       // get group list
       $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);