From 100afa30eedff7f5e321161ed07e1e639c2bac88 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Mon, 29 Apr 2013 15:11:00 -0700 Subject: [PATCH] worked on CRM-12357, fixed sorting of columns --- CRM/Mailing/Page/AJAX.php | 2 +- api/v3/MailingContact.php | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CRM/Mailing/Page/AJAX.php b/CRM/Mailing/Page/AJAX.php index 3032533d66..8d19c6eade 100644 --- a/CRM/Mailing/Page/AJAX.php +++ b/CRM/Mailing/Page/AJAX.php @@ -68,7 +68,7 @@ class CRM_Mailing_Page_AJAX { //$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String'); $sortMapper = array( - 0 => 'subject', 1 => 'mailing_creator', 2 => 'start_date', 3 => 'links', + 0 => 'subject', 1 => 'creator_name', 2 => 'start_date', 3 => 'links', ); $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); diff --git a/api/v3/MailingContact.php b/api/v3/MailingContact.php index f62b04c3d4..889f1b946f 100644 --- a/api/v3/MailingContact.php +++ b/api/v3/MailingContact.php @@ -80,7 +80,8 @@ function civicrm_api3_mailing_contact_get($params) { return $fnName( $params['contact_id'], $params['offset'], - $params['limit'] + $params['limit'], + CRM_Utils_Array::value('sort', $params) ); } @@ -91,7 +92,8 @@ function _civicrm_api3_mailing_contact_query( $limit, $selectFields, $fromClause, - $whereClause + $whereClause, + $sort ) { $defaultFields = array( 'm.id' => 'mailing_id', @@ -113,6 +115,11 @@ function _civicrm_api3_mailing_contact_query( } $select = implode(', ', $select); + $orderBy = 'ORDER BY j.start_date'; + if ($sort) { + $orderBy = "ORDER BY $sort"; + } + $sql = " SELECT $select FROM civicrm_mailing m @@ -124,7 +131,7 @@ WHERE j.is_test = 0 AND meq.contact_id = %1 $whereClause GROUP BY m.id -ORDER BY j.start_date +{$orderBy} "; if ($limit > 0) { @@ -159,7 +166,8 @@ LIMIT %2, %3 function _civicrm_api3_mailing_contact_get_delivered( $contactID, $offset, - $limit + $limit, + $sort ) { $selectFields = array('med.time_stamp' => 'start_date'); @@ -179,14 +187,16 @@ AND meb.id IS NULL $limit, $selectFields, $fromClause, - $whereClause + $whereClause, + $sort ); } function _civicrm_api3_mailing_contact_get_bounced( $contactID, $offset, - $limit + $limit, + $sort ) { $fromClause = " INNER JOIN civicrm_mailing_event_bounce meb ON meb.event_queue_id = meq.id @@ -199,6 +209,7 @@ INNER JOIN civicrm_mailing_event_bounce meb ON meb.event_queue_id = meq.id $limit, NULL, $fromClause, - NULL + NULL, + $sort ); } -- 2.25.1