RSS

LuxCal Forum

The place for questions, suggestions and news about the LuxCal Event Calendar

User:   Password:   Remember Me?   
LuxCal Forum / LuxCal / Comments and Suggestions / Google calendar ICS import
Posted:  23 Feb 2012 16:03   Last Edited By: pantricio
Hello:

As I mentioned in my previous post, I've been playing around with LuxCal for a while and I think I've found another small issue.

When I try to import a Google Calendar (which was previously exported as an ICS file from the Google Calendar website) to LuxCal, the events that have some alarms (VALARM calendar components according to RFC-5545) are not processed properly.

It seems that Google Calendar export the events with the following structure:
BEGIN:VEVENT
...
DESCRIPTION:Whatever event description
...
SUMMARY:Whatever event summary
...
BEGIN:VALARM
...
DESCRIPTION:This is an event reminder
SUMMARY:Alarm notification
...
END:VALARM
END:VEVENT


When LuxCal import that content, the script pages/importICS.php takes the last VALARM DESCRIPTION and SUMMARY elements as the parent's VELEMENT DESCRIPTION and SUMMARY. I mean, in the previous example the event would get

DESCRIPTION:This is an event reminder
SUMMARY:Alarm notification


instead of

DESCRIPTION:Whatever event description
SUMMARY:Whatever event summary


As my PHP knowledge is really low I've coded a poor's man solution. The idea is to use a variable (I've called it $alarmMode) to store 1 if the processed line is between the BEGIN:VALARM and END:VALARM (or 0 if it is not), and if so just ignore it. This way the ICS gets cleaned when it's imported.

In /pages/importICS.php I've changed lines 62-69 from

Code:


    //Iterate icsLines for one event
    while (list($k, $v) = explode(':', str_replace(';','~',$icsLines[$curLine++]), 2)) { //1st colon only
        $key = explode(';',$k);
        $value = explode(';',$v);
        foreach ($key as &$val) { $val = trim($val); }
        foreach ($value as &$val) { $val = trim($val); }
        unset($val); //break reference
        if ($key[0] == "END" and $value[0] == "VEVENT") { break; }//event end
to

Code:


    $alarmMode = 0;
    //Iterate icsLines for one event
    while (list($k, $v) = explode(':', str_replace(';','~',$icsLines[$curLine++]), 2)) { //1st colon only
        $key = explode(';',$k);
        $value = explode(';',$v);
        foreach ($key as &$val) { $val = trim($val); }
        foreach ($value as &$val) { $val = trim($val); }
        unset($val); //break reference
        if ($key[0] == "END" and $value[0] == "VEVENT") { break; }//event end
        if ($key[0] == "BEGIN" and $value[0] == "VALARM") { $alarmMode = 1; break; }//alarm begin
        if ($key[0] == "END" and $value[0] == "VALARM") { $alarmMode = 0; break; }//alarm end
        if ($alarmMode == 1) { break; } //alarmMode == 1
However, it would be great if the TRIGGER element present in the VALARM component could be used for setting the NOTIFY field of the event (how many days in advance should I get the reminder), but as I said my PHP is not that good... so that's another story.

I hope this helps, and thanks again for developing LuxCal.

Best regards.
Posted:  10 Mar 2012 00:13   Last Edited By: Roel B.
Hello Pantricio,

Thanks for this input!
To solve the alarm issue (VALARM) in .ics files, I will include your code in the next LuxCal version.
This code change will skip the VALARM component (BEGIN:VALARM - END:VALARM) altogether.

To parse the TRIGGER property inside the VALARM component is not impossible, but would require a major change of the importICS.php script. The VALARM component is the only component that must appear inside a VEVENT component (nested components). So processing one VEVENT component would output two LuxCal events, i.e. the normal event (VEVENT) and an event to send an email notification (VALARM component, TRIGGER property with action ACTION:EMAIL) to the specified email address (ATTENDEE).
I will have think about this one for a while . . .

Roel