Make sure placeholders are present & empty if there is no previous appt for contact

This commit is contained in:
Nathan Gray 2011-04-06 21:39:17 +00:00
parent eb337b7dec
commit a8b3fd0cba

View File

@ -79,7 +79,7 @@ class addressbook_merge extends bo_merge
{ {
$events = array(); $events = array();
} }
if ($last_event_too=true) if ($last_event_too==true)
{ {
$last = $calendar->search(array( $last = $calendar->search(array(
'end' => $calendar->now_su, 'end' => $calendar->now_su,
@ -88,7 +88,7 @@ class addressbook_merge extends bo_merge
'num_rows' => 1, 'num_rows' => 1,
'order' => 'cal_start DESC', '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(); $replacements = array();
foreach($events as $n => $event) 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', 'time' => $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i',
) as $name => $format) ) as $name => $format)
{ {
$value = date($format,$event[$what]); $value = $event[$what] ? date($format,$event[$what]) : '';
if ($format == 'l') $value = lang($value); if ($format == 'l') $value = lang($value);
$replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value;
} }
@ -116,6 +116,14 @@ class addressbook_merge extends bo_merge
++$n; ++$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; return $replacements;
} }