X2Engine / X2CRM

X2CRM Open Source CRM - PHP
http://www.x2crm.com
342 stars 168 forks source link

Incorrect ical format #181

Open dczaretsky opened 3 years ago

dczaretsky commented 3 years ago

When exporting a calendar from x2crm, the ical format produced is incorrect. Here are 3 issues I've come across:

  1. Calendar Actions are single day events -- they should not span multiple days. However they seem to use the completeDate field as the end date, which is not updated appropriately. Recommendation is for Actions to use the dueDate field for the end date.

  2. All Day Events are not respected in the ical file because the formatting is incorrect. Recommendation is that all day events should only have the 'Ymd' format, and not include the time ('His'). Additionally, multi-all-day events require the end date to be one day later.

  3. Calendar Actions include mandatory Subject fields that are not reported in the ical. Recommendation is to place the subject in the SUBJECT field and move the description to the DESCRIPTION field.

Here are my recommended code modifcations for render() in /components/Ical.php:

 $start = new DateTime();
 $end = new DateTime();
 $tzOb = new DateTimeZone($tz);
 $start->setTimestamp($action->dueDate);
 $end->setTimestamp((isset($action->type) && $action->type == 'event') ? $action->completeDate : $action->dueDate);
 $start->setTimezone($tzOb);
 $end->setTimezone($tzOb);
 $allDay = isset($action->allDay) && $action->allDay == 1 ? true : false;
 echo "DTSTART;TZID=$tz:".$start->format($allDay?'Ymd':'Ymd\THis')."\r\n";
 echo "DTEND;TZID=$tz:".$end->add(new DateInterval($allDay?'P1D':'P0D'))->format($allDay?'Ymd':'Ymd\THis')."\r\n";
 echo "SUMMARY:".self::escapeText(!empty($action->subject) ? $action->subject : $action->actionText->text)."\r\n";
 echo "DESCRIPTION:".self::escapeText(!empty($action->subject) ? $action->actionText->text : '')."\r\n";
 echo "END:VEVENT\r\n";
Abrynn commented 3 years ago

Apologies for an offtopic silly question…

Is there still a free version of X2CRM?