Calendar: better fix for spurious history log entries

This commit is contained in:
nathangray 2020-06-24 15:07:52 -06:00
parent 4d67f98eeb
commit b2c73ed905

View File

@ -1380,7 +1380,7 @@ class calendar_boupdate extends calendar_bo
foreach($timestamps as $ts) foreach($timestamps as $ts)
{ {
// we convert here from user-time to timestamps in server-time! // we convert here from user-time to timestamps in server-time!
if (isset($event[$ts])) $save_event[$ts] = $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
} }
// convert tzid name to integer tz_id, of set user default // convert tzid name to integer tz_id, of set user default
if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@ -1494,6 +1494,13 @@ class calendar_boupdate extends calendar_bo
// Update history // Update history
$tracking = new calendar_tracking($this); $tracking = new calendar_tracking($this);
if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
// we run all dates through date2ts, to adjust to server-time and the possible date-formats
// This is done here to avoid damaging the actual event when saving, but the old event is in server-time
foreach($timestamps as $ts)
{
// we convert here from user-time to timestamps in server-time!
if (isset($save_event[$ts])) $save_event[$ts] = $save_event[$ts] ? $this->date2ts($save_event[$ts],true) : 0;
}
$tracking->track($save_event, $old_event); $tracking->track($save_event, $old_event);
return $cal_id; return $cal_id;