diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php index 7e447029ca..f7c45862c1 100644 --- a/addressbook/inc/class.addressbook_merge.inc.php +++ b/addressbook/inc/class.addressbook_merge.inc.php @@ -155,16 +155,24 @@ class addressbook_merge // extends bo_merge 'num_rows' => 20, 'order' => 'cal_start', )); - array_unshift($events,false); unset($events[0]); // renumber the array to start with key 1, instead of 0 - if ($last_event_too) + if ($events) { - list($events['-1']) = $calendar->search(array( + array_unshift($events,false); unset($events[0]); // renumber the array to start with key 1, instead of 0 + } + else + { + $events = array(); + } + if ($last_event_too=true) + { + $last = $calendar->search(array( 'end' => $calendar->now_su, 'users' => 'c'.$id, 'offset' => 0, 'num_rows' => 1, 'order' => 'cal_start DESC', )); + if ($last) $events['-1'] = array_shift($last); // returned events are indexed by cal_id! } $replacements = array(); foreach($events as $n => $event) @@ -311,7 +319,7 @@ class addressbook_merge // extends bo_merge echo '$$'.$name.'$$'.$label."\n"; } $GLOBALS['egw']->translation->add_app('calendar'); - echo '

'.lang('Calendar fields:')." # = 1, 2, ..., 20

"; + echo '

'.lang('Calendar fields:')." # = 1, 2, ..., 20, -1

"; foreach(array( 'title' => lang('Title'), 'description' => lang('Description'),