summaryrefslogtreecommitdiff
path: root/roundcubemail/program/include/rcube_contacts.php
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2012-02-02 22:18:10 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2012-02-02 22:18:10 +0000
commit4f19c51b60bfb40122ff577883c613741572b5d5 (patch)
tree7223a68e6c57e49c42dc3aac7f13107668303496 /roundcubemail/program/include/rcube_contacts.php
parentdb8183565ca9b5cb1e1b534efa94f77345781599 (diff)
Allow users to choose cols for contacts list sorting
git-svn-id: https://svn.roundcube.net/trunk@5850 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_contacts.php')
-rw-r--r--roundcubemail/program/include/rcube_contacts.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/roundcubemail/program/include/rcube_contacts.php b/roundcubemail/program/include/rcube_contacts.php
index 1cfebb503..1a4950d84 100644
--- a/roundcubemail/program/include/rcube_contacts.php
+++ b/roundcubemail/program/include/rcube_contacts.php
@@ -5,7 +5,7 @@
| program/include/rcube_contacts.php |
| |
| This file is part of the Roundcube Webmail client |
- | Copyright (C) 2006-2011, The Roundcube Dev Team |
+ | Copyright (C) 2006-2012, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@@ -217,6 +217,16 @@ class rcube_contacts extends rcube_addressbook
$join = " LEFT JOIN ".get_table_name($this->db_groupmembers)." AS m".
" ON (m.contact_id = c.".$this->primary_key.")";
+ $order_col = (in_array($this->sort_col, $this->table_cols) ? $this->sort_col : 'name');
+ $order_cols = array('c.'.$order_col);
+ if ($order_col == 'firstname')
+ $order_cols[] = 'c.surname';
+ else if ($order_col == 'surname')
+ $order_cols[] = 'c.firstname';
+ if ($order_col != 'name')
+ $order_cols[] = 'c.name';
+ $order_cols[] = 'c.email';
+
$sql_result = $this->db->limitquery(
"SELECT * FROM ".get_table_name($this->db_name)." AS c" .
$join .
@@ -224,7 +234,8 @@ class rcube_contacts extends rcube_addressbook
" AND c.user_id=?" .
($this->group_id ? " AND m.contactgroup_id=?" : "").
($this->filter ? " AND (".$this->filter.")" : "") .
- " ORDER BY ". $this->db->concat('c.name', 'c.email'),
+ " ORDER BY ". $this->db->concat($order_cols) .
+ " " . $this->sort_order,
$start_row,
$length,
$this->user_id,