Calendar sharing – 2 way

In a previous post we have create calendar snippets in ics format. PHPicalendar is the ultimate solution to stitch these calendar snippets together to a workgroup view.
I am using the built-in RSS feed to be noticed about any forthcoming events that are not sitting in my own calendar.
There is only one drawback: phpicalendar doesn’t offer any possibility to import back any new meeting into Sunbird or Outlook. By using the following patch of events.php it may, however, send you back an .ics file (that can opens Sunbird automatically if configured correctly) by just clicking on any new event.

events.php

 1:
 2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
58:
switch ($event['status']){
    case 'CONFIRMED':
        $event['status'] =    $lang['l_status_confirmed'] ; 
        break;
    case 'CANCELLED':
        $event['status'] =    $lang['l_status_cancelled'] ; 
        break;
    case 'TENTATIVE':
        $event['status'] =    $lang['l_status_tentative'] ; 
        break;
}
--------------------------insert start--------------------------
$ics ='BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN
METHOD:PUBLISH
BEGIN:VEVENT
TRANSP:TRANSPARENT
CATEGORIES:WJST
DTSTART:'. date("Ymd", $event['start_unixtime']) .'T' . date("His", $event['start_unixtime']) . 'Z
LOCATION:' . stripslashes($event['location']) .'
DTEND:'. date("Ymd", $event['end_unixtime']) .'T' . date("His", $event['end_unixtime']) . 'Z
SUMMARY:' . $event['event_text'] . '
UID:462CB5E2-7A1D-11DB-A244-000393AE2CEE-'. rand(1000000000000,9999999999999) . '
SEQUENCE:3
DTSTAMP:20070808T000000Z
END:VEVENT
END:VCALENDAR';
$fp=fopen("tmp.ics","w");
fputs($fp,$ics);
fclose($fp);
--------------------------insert end --------------------------
$page = new Page(BASE.'templates/'.$template.'/event.tpl');

$page->replace_tags(array(
    'charset'        => $charset,
    'cal'             => $event['calname'],
--------------------------patch ------------------------------
    'event_text'         => '<a href=tmp.ics>'. $event['event_text'] .'</a>',
----------------------------------patch ----------------------
    'event_times'         => $event_times,
    'description'         => $event['description'],
    'organizer'         => $organizer,
    'attendee'         => $attendee,
    'status'         => $event['status'],
    'location'         => stripslashes($event['location'])    ,
    'cal_title_full'    => $event['calname'].' '.$lang['l_calendar'],
    'template'        => $template,
    'l_organizer'        => $lang['l_organizer'],
    'l_attendee'        => $lang['l_attendee'],
    'l_status'        => $lang['l_status'],
    'l_location'        => $lang['l_location'] 
    ));

$page->output();

?>

If your calendar ics are really up to date, you may want to change $actual_calname in ical_parser.php to
$actual_calname = getCalendarName($filename) . ‘ (-‘ . round((time() – filemtime($filename) )/100000) . ‘ days old)’;