Google Calendar & PHP iCalendar
PHP icalendar Google Calendar and PHP icalendar MRBS Room booking Calendar

PHPiCalendar and Google Calendar

For directions on setting up PHP icalendar on SFU's Fraser, go to http://www.sfu.ca/biology2/facilities/computer/calendar/phpicalendar.html

1) In your Google Calendar account, go to the Calendar settings and click on the iCal link and Copy the address (e.g http://www.google.com/calendar/ical/jtod46ihqgr5nml8qrleq30@group.calendar.google.com/public/basic.ics)

2) Open config.inc.php and find $list_webcals[] = ''; and paste in the calendar link- e.g.
$list_webcals[] = 'http://www.google.com/calendar/ical/jtod4o6ihqg5nml8qrleq30@group.calendar.google.com/public/basic.ics';

Also in config.inc.php turn the caching off, e.g.
$save_parsed_cals = 'no'; [only changing cache for webcals to '0' causes problems when you try to 'jump to' or pick a single calendar under the 'Pick multiple:']

3) Test to see that the Calendar works- note repeating events only show the beginning time. To fix this go to ical_parser.php in the functions folder and replace the "case 'DURATION': block with this code (from http://phpicalendar.net/forums/):

case 'DURATION':
if (($first_duration == TRUE) && (!stristr($field, '=DURATION'))) {
ereg ('^P([0-9]{1,2}[W])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,}[S])?', $data, $duration);

$weeks = str_replace('W', '', $duration[1]);
$days = str_replace('D', '', $duration[2]);
$hours = str_replace('H', '', $duration[4]);
$minutes = str_replace('M', '', $duration[5]);
$seconds = str_replace('S', '', $duration[6]);

// Convert seconds to hours, minutes, and seconds
if ($seconds > 60) {
$rem_seconds = $seconds % 60;
$minutes = $minutes + (($seconds - $rem_seconds) / 60);
$seconds = $rem_seconds;
}
if ($minutes > 60) {
$rem_minutes = $minutes % 60;
$hours = $hours + (($minutes - $rem_minutes) / 60);
$minutes = $rem_minutes;
}

$the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
$first_duration = FALSE;
}
break;