From 4e1ffd14b4d84e2940f9e6ca4f01c01e4b902a50 Mon Sep 17 00:00:00 2001 From: abijah Date: Sun, 23 Aug 2009 04:16:43 +0000 Subject: [PATCH] Fixed the links and sorting for the contacts grid git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@741 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/controllers/contacts_controller.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/site/controllers/contacts_controller.php b/site/controllers/contacts_controller.php index f9cb4e2..8d24e38 100644 --- a/site/controllers/contacts_controller.php +++ b/site/controllers/contacts_controller.php @@ -25,17 +25,19 @@ class ContactsController extends AppController { function gridDataOrder(&$params, &$model, $index, $direction) { $order = parent::gridDataOrder($params, $model, $index, $direction); - if ($index === 'Contact.last_name') { - $order[] = 'Contact.first_name ' . $direction; - } - if ($index === 'Contact.first_name') { - $order[] = 'Contact.last_name ' . $direction; - } + + // After sorting by whatever the user wants, add these + // defaults into the sort mechanism. If we're already + // sorting by one of them, it will only be redundant, + // and should cause no harm (possible a longer query?) + $order[] = 'Contact.last_name ' . $direction; + $order[] = 'Contact.first_name ' . $direction; + return $order; } function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { - $links['Contact'] = array('id'); + $links['Contact'] = array('last_name', 'first_name'); return parent::gridDataPostProcessLinks($params, $model, $records, $links); }