Calendar: History tab showed start / end times in server time, not user time

This commit is contained in:
nathan 2023-06-06 14:41:01 -06:00
parent 2d7e267c4b
commit efd073c4c2
2 changed files with 32 additions and 0 deletions

View File

@ -3108,6 +3108,37 @@ class calendar_uiforms extends calendar_ui
// custom fields are now "understood" directly by historylog widget
}
/**
* Modify history to make timestamps in user time
*
* @param array $data values for keys "data" (data) and "args":
* values for keys "value", "rows" (reference) and "total" (reference)
*/
public function modify_history(array $data)
{
$history = [];
$sel_options = [];
$this->setup_history($history, $sel_options);
foreach($data['rows'] as $index => &$row)
{
if($row['appname'] !== 'calendar')
{
return;
}
if(str_contains($history['history']['status-widgets'][$row['status']], 'date'))
{
foreach(['old_value', 'new_value'] as $field)
{
if(!$row[$field])
{
continue;
}
$row[$field] = Api\DateTime::server2user($row[$field], Api\DateTime::ET2);
}
}
}
}
/**
* moves an event to another date/time
*

View File

@ -47,6 +47,7 @@ $setup_info['calendar']['hooks']['categories'] = 'calendar_hooks::categories';
$setup_info['calendar']['hooks']['mail_import'] = 'calendar_hooks::mail_import';
$setup_info['calendar']['hooks']['notifications_actions'] = 'calendar_hooks::notifications_actions';
$setup_info['calendar']['hooks']['etemplate2_register_widgets'] = 'calendar_hooks::widgets';
$setup_info['calendar']['hooks']['etemplate2_history_get_rows'] = 'calendar.calendar_uiforms.modify_history';
/* Dependencies for this app to work */
$setup_info['calendar']['depends'][] = array(