From a8b3fd0cba3239cbc99812d5002c0f81c0d7b768 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 6 Apr 2011 21:39:17 +0000 Subject: [PATCH] Make sure placeholders are present & empty if there is no previous appt for contact --- addressbook/inc/class.addressbook_merge.inc.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php index 920f49eb64..6955d92bdb 100644 --- a/addressbook/inc/class.addressbook_merge.inc.php +++ b/addressbook/inc/class.addressbook_merge.inc.php @@ -79,7 +79,7 @@ class addressbook_merge extends bo_merge { $events = array(); } - if ($last_event_too=true) + if ($last_event_too==true) { $last = $calendar->search(array( 'end' => $calendar->now_su, @@ -88,7 +88,7 @@ class addressbook_merge extends bo_merge 'num_rows' => 1, 'order' => 'cal_start DESC', )); - if ($last) $events['-1'] = array_shift($last); // returned events are indexed by cal_id! + $events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id! } $replacements = array(); foreach($events as $n => $event) @@ -106,7 +106,7 @@ class addressbook_merge extends bo_merge 'time' => $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i', ) as $name => $format) { - $value = date($format,$event[$what]); + $value = $event[$what] ? date($format,$event[$what]) : ''; if ($format == 'l') $value = lang($value); $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; } @@ -116,6 +116,14 @@ class addressbook_merge extends bo_merge ++$n; } + + // Need to set some keys if there is no previous event + if($last_event_too && count($events['-1']) == 0) { + $replacements['$$calendar/-1/start$$'] = ''; + $replacements['$$calendar/-1/end$$'] = ''; + $replacements['$$calendar/-1/owner$$'] = ''; + $replacements['$$calendar/-1/updated$$'] = ''; + } return $replacements; }