X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=program%2Finclude%2Frcube_contacts.php;fp=program%2Finclude%2Frcube_contacts.php;h=fecbfd152e2a400e93075b74b43003b4c066b4eb;hb=7033aedb93d429abdeccf3bceb7152b5f91dc104;hp=f695abf7db2676740e63125a9193f6c7083d226b;hpb=a6cc1ac49674e1902dbb9a2c34f22408471bc4d3;p=roundcube.git diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php index f695abf..fecbfd1 100644 --- a/program/include/rcube_contacts.php +++ b/program/include/rcube_contacts.php @@ -15,7 +15,7 @@ | Author: Thomas Bruederli | +-----------------------------------------------------------------------+ - $Id: rcube_contacts.php 5712 2012-01-05 08:50:07Z alec $ + $Id: rcube_contacts.php 5873 2012-02-11 13:50:04Z thomasb $ */ @@ -213,6 +213,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 . @@ -220,7 +230,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, @@ -239,13 +250,6 @@ class rcube_contacts extends rcube_addressbook $sql_arr['email'] = array_map('trim', $sql_arr['email']); } - // make sure we have a name to display - if (empty($sql_arr['name'])) { - if (empty($sql_arr['email'])) - $sql_arr['email'] = $this->get_col_values('email', $sql_arr, true); - $sql_arr['name'] = $sql_arr['email'][0]; - } - $this->result->add($sql_arr); }