summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2012-02-11 13:32:10 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2012-02-11 13:32:10 (GMT)
commit145258abf79c09178742ce4a10f1dac44cf5f3b9 (patch)
treef206b3f04638ec79e55058958b7cbdd2ce7300e2
parentead334f895b2db3ea17a7930aeb7bfa8e43367da (diff)
downloadroundcubemail-plugins-kolab-145258abf79c09178742ce4a10f1dac44cf5f3b9.tar.gz
Better fix for #577
-rw-r--r--plugins/kolab_addressbook/lib/rcube_kolab_contacts.php36
1 files changed, 22 insertions, 14 deletions
diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
index 531eec7..f028f52 100644
--- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
@@ -1017,22 +1017,30 @@ class rcube_kolab_contacts extends rcube_addressbook
*/
private function _sort_contacts_comp($a, $b)
{
- $a_value = $a[$this->sort_col];
- $b_value = $b[$this->sort_col];
-
- if (!$a_value && $this->sort_col == 'name') {
- $a_value = join(' ', array_filter(array($a['firstname'], $a['middlename'], $a['surname'])));
- }
- if (!$a_value) {
- $a_value = is_array($a['email']) ? $a['email'][0] : $a['email'];
+ $a_value = $b_value = '';
+
+ switch ($this->sort_col) {
+ case 'name':
+ $a_value = $a['name'] . $a['prefix'];
+ $b_value = $b['name'] . $b['prefix'];
+ case 'firstname':
+ $a_value .= $a['firstname'] . $a['middlename'] . $a['surname'];
+ $b_value .= $b['firstname'] . $b['middlename'] . $b['surname'];
+ break;
+
+ case 'surname':
+ $a_value = $a['surname'] . $a['firstname'] . $a['middlename'];
+ $b_value = $b['surname'] . $b['firstname'] . $b['middlename'];
+ break;
+
+ default:
+ $a_value = $a[$this->sort_col];
+ $b_value = $b[$this->sort_col];
+ break;
}
- if (!$b_value && $this->sort_col == 'name') {
- $b_value = join(' ', array_filter(array($b['firstname'], $b['middlename'], $b['surname'])));
- }
- if (!$b_value) {
- $b_value = is_array($b['email']) ? $b['email'][0] : $b['email'];
- }
+ $a_value .= is_array($a['email']) ? $a['email'][0] : $a['email'];
+ $b_value .= is_array($b['email']) ? $b['email'][0] : $b['email'];
// return strcasecmp($a_value, $b_value);
// make sorting unicode-safe and locale-dependent