From 7940612da58128bdd9c23136fc8d57e130e22b53 Mon Sep 17 00:00:00 2001 From: "Aleksander Machniak (Kolab Systems)" Date: Wed, 27 Jul 2011 19:13:38 +0200 Subject: [PATCH 1/7] Fixed issue with folders which names are resolved to numeric identifiers --- plugins/kolab_addressbook/kolab_addressbook.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php index 70a7f3e0..3f88a38e 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -135,10 +135,17 @@ class kolab_addressbook extends rcube_plugin // Add personal address sources to the list if ($abook_prio == self::PERSONAL_FIRST) { - $p['sources'] = array_merge($sources, $p['sources']); + // $p['sources'] = array_merge($sources, $p['sources']); + // Don't use array_merge(), because if you have folders name + // that resolve to numeric identifier it will break output array keys + foreach ($p['sources'] as $idx => $value) + $sources[$idx] = $value; + $p['sources'] = $sources; } else { - $p['sources'] = array_merge($p['sources'], $sources); + // $p['sources'] = array_merge($p['sources'], $sources); + foreach ($sources as $idx => $value) + $p['sources'][$idx] = $value; } return $p; From 6d8a2f51c5bdedcc3237bdafb35255581ebe0e95 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 28 Jul 2011 10:17:42 +0200 Subject: [PATCH 2/7] Fix calendar selection for new events in case default calendar is not writeable (#225) --- plugins/calendar/calendar_ui.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index 99596346..f29ea27d 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -1538,12 +1538,17 @@ function rcube_calendar_ui(settings) .data('id', id); } - if (!cal.readonly && !this.selected_calendar && (!settings.default_calendar || settings.default_calendar == id)) { + if (!cal.readonly && !this.selected_calendar) { this.selected_calendar = id; rcmail.enable_command('addevent', true); } } - + + // select default calendar + if (settings.default_calendar && this.calendars[settings.default_calendar] && !this.calendars[settings.default_calendar].readonly) + this.selected_calendar = settings.default_calendar; + + // initalize the fullCalendar plugin var fc = $('#calendar').fullCalendar({ header: { From 3cd7d520400dc06a1a35d7efcbcd10b709cbe5f0 Mon Sep 17 00:00:00 2001 From: "Aleksander Machniak (Kolab Systems)" Date: Thu, 28 Jul 2011 11:41:44 +0200 Subject: [PATCH 3/7] Improved performance by sorting contacts only for listing --- .../lib/rcube_kolab_contacts.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index 70397ac2..da087df8 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -279,9 +279,19 @@ class rcube_kolab_contacts extends rcube_addressbook else $ids = is_array($this->filter['ids']) ? $this->filter['ids'] : array_keys($this->contacts); + // sort data arrays according to desired list sorting + if ($count = count($ids)) { + uasort($this->contacts, array($this, '_sort_contacts_comp')); + // get sorted IDs + if ($count != count($this->contacts)) + $ids = array_intersect(array_keys($this->contacts), $ids); + else + $ids = array_keys($this->contacts); + } + // fill contact data into the current result set $start_row = $subset < 0 ? $this->result->first + $this->page_size + $subset : $this->result->first; - $last_row = min($subset != 0 ? $start_row + abs($subset) : $this->result->first + $this->page_size, count($ids)); + $last_row = min($subset != 0 ? $start_row + abs($subset) : $this->result->first + $this->page_size, $count); for ($i = $start_row; $i < $last_row; $i++) { if ($id = $ids[$i]) @@ -964,9 +974,6 @@ class rcube_kolab_contacts extends rcube_addressbook $this->contacts[$id] = $contact; $this->id2uid[$id] = $record['uid']; } - - // sort data arrays according to desired list sorting - uasort($this->contacts, array($this, '_sort_contacts_comp')); } } From d569b020f41b7bc0b179e21830c14f9390af2f7f Mon Sep 17 00:00:00 2001 From: Thomas Broderli Date: Thu, 28 Jul 2011 11:43:35 +0200 Subject: [PATCH 4/7] Fix free-busy slot comparison --- plugins/calendar/calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index f396c23c..757bcf9c 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1282,7 +1282,7 @@ class calendar extends rcube_plugin $status = self::FREEBUSY_FREE; foreach ($fblist as $slot) { list($from, $to, $type) = $slot; - if ($from <= $t_end && $to > $t) { + if ($from < $t_end && $to > $t) { $status = isset($type) ? $type : self::FREEBUSY_BUSY; break; } From 03f9741a616a4413e46e18ec6e48f2a5ae3936b7 Mon Sep 17 00:00:00 2001 From: "Aleksander Machniak (Kolab Systems)" Date: Thu, 28 Jul 2011 12:00:11 +0200 Subject: [PATCH 5/7] Fix contacts sorting when there's no name field --- .../lib/rcube_kolab_contacts.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index da087df8..d62a7f3b 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -982,7 +982,25 @@ class rcube_kolab_contacts extends rcube_addressbook */ private function _sort_contacts_comp($a, $b) { - return strcasecmp($a['name'], $b['name']); + $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']; + } + } + 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']; + } + } + + return strcasecmp($a_name, $b_name); } /** From 75392cc4926b8a5cf8593b84662cf2c5e15be679 Mon Sep 17 00:00:00 2001 From: "Aleksander Machniak (Kolab Systems)" Date: Thu, 28 Jul 2011 12:39:05 +0200 Subject: [PATCH 6/7] Make contacts sorting unicode-safe and locale-dependent --- .../kolab_addressbook/lib/rcube_kolab_contacts.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index d62a7f3b..0d3b01a4 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -281,7 +281,9 @@ class rcube_kolab_contacts extends rcube_addressbook // sort data arrays according to desired list sorting if ($count = count($ids)) { +$aa = rcube_timer(); uasort($this->contacts, array($this, '_sort_contacts_comp')); +rcube_print_time($aa); // get sorted IDs if ($count != count($this->contacts)) $ids = array_intersect(array_keys($this->contacts), $ids); @@ -1000,7 +1002,14 @@ class rcube_kolab_contacts extends rcube_addressbook } } - return strcasecmp($a_name, $b_name); + // return strcasecmp($a_name, $b_name); + // make sorting unicode-safe and locale-dependent + if ($a_name == $b_name) + return 0; + + $arr = array($a_name, $b_name); + sort($arr, SORT_LOCALE_STRING); + return $a_name == $arr[0] ? -1 : 1; } /** From b1ab27cbe09b4ae6985674d4e8c5f82db1a84e10 Mon Sep 17 00:00:00 2001 From: "Aleksander Machniak (Kolab Systems)" Date: Thu, 28 Jul 2011 12:40:02 +0200 Subject: [PATCH 7/7] Removed timers --- plugins/kolab_addressbook/lib/rcube_kolab_contacts.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index 0d3b01a4..1a16d762 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -281,9 +281,7 @@ class rcube_kolab_contacts extends rcube_addressbook // sort data arrays according to desired list sorting if ($count = count($ids)) { -$aa = rcube_timer(); uasort($this->contacts, array($this, '_sort_contacts_comp')); -rcube_print_time($aa); // get sorted IDs if ($count != count($this->contacts)) $ids = array_intersect(array_keys($this->contacts), $ids);