summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2012-02-08 14:09:55 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2012-02-08 14:09:55 (GMT)
commitb5a44da343057cdf461c69c35e53d095af54d15c (patch)
treeafd5be69218f06f5f1f0d995017e2adbbd334e99
parentdc3a82198b568750e21ca67c2eaae719131d80f5 (diff)
downloadroundcubemail-plugins-kolab-b5a44da343057cdf461c69c35e53d095af54d15c.tar.gz
Respect new configurable sort order for contacts
-rw-r--r--plugins/kolab_addressbook/lib/rcube_kolab_contacts.php37
1 files changed, 18 insertions, 19 deletions
diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
index 2ffc740..531eec7 100644
--- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
@@ -1017,32 +1017,31 @@ class rcube_kolab_contacts extends rcube_addressbook
*/
private function _sort_contacts_comp($a, $b)
{
- $a_name = $a['name'];
- $b_name = $b['name'];
-
- if (!$a_name) {
- $a_name = join(' ', array_filter(array($a['prefix'], $a['firstname'],
- $a['middlename'], $a['surname'], $a['suffix'])));
- if (!$a_name) {
- $a_name = is_array($a['email']) ? $a['email'][0] : $a['email'];
- }
+ $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 (!$b_name) {
- $b_name = join(' ', array_filter(array($b['prefix'], $b['firstname'],
- $b['middlename'], $b['surname'], $b['suffix'])));
- if (!$b_name) {
- $b_name = is_array($b['email']) ? $b['email'][0] : $b['email'];
- }
+ if (!$a_value) {
+ $a_value = is_array($a['email']) ? $a['email'][0] : $a['email'];
+ }
+
+ 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'];
}
- // return strcasecmp($a_name, $b_name);
+ // return strcasecmp($a_value, $b_value);
// make sorting unicode-safe and locale-dependent
- if ($a_name == $b_name)
+ if ($a_value == $b_value)
return 0;
- $arr = array($a_name, $b_name);
+ $arr = array($a_value, $b_value);
sort($arr, SORT_LOCALE_STRING);
- return $a_name == $arr[0] ? -1 : 1;
+ return $a_value == $arr[0] ? -1 : 1;
}
/**