Infolog: When creating an event from an infolog, don't send an invalid category ID. Fixes validation error when saving the event.

This commit is contained in:
nathan 2023-04-03 09:35:22 -06:00
parent 558d6a5d0c
commit c0f29e406f

View File

@ -680,10 +680,22 @@ class infolog_ui
'end' => $infolog['info_enddate'] ? $infolog['info_enddate'] : $infolog['info_datecompleted'] 'end' => $infolog['info_enddate'] ? $infolog['info_enddate'] : $infolog['info_datecompleted']
)); ));
unset($event['entry_id']); unset($event['entry_id']);
if (!$event['end']) $event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60; if(!$event['end'])
{
$event['end'] = $event['start'] + (int)$GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60;
}
// Match Api\Categories by name // Match Api\Categories by name
if($infolog['info_cat'])
{
$event['category'] = $GLOBALS['egw']->categories->name2id(Api\Categories::id2name($infolog['info_cat'])); $event['category'] = $GLOBALS['egw']->categories->name2id(Api\Categories::id2name($infolog['info_cat']));
}
if(!$event['category'] || $event['category'] === '0')
{
// No matching category found, don't send an invalid category
unset($event['category']);
}
// make current user the owner of the new event, not the selected calendar, if current user has rights for it // make current user the owner of the new event, not the selected calendar, if current user has rights for it
$event['owner'] = $user = $GLOBALS['egw_info']['user']['account_id']; $event['owner'] = $user = $GLOBALS['egw_info']['user']['account_id'];