diff --git a/calendar/ical_test.php b/calendar/ical_test.php index 224a4c6e45..ea5bfa7e0f 100755 --- a/calendar/ical_test.php +++ b/calendar/ical_test.php @@ -28,13 +28,19 @@ echo "Product ID = ".$vcalendar->prodid."
\n"; echo "Method = ".$vcalendar->method."
\n"; echo "Version = ".$vcalendar->version."
\n"; - echo "Sequence = ".$vcalendar->event[0]->sequence."
\n"; - $datet = CreateObject('phpgwapi.datetime'); - $datetime = mktime($vcalendar->event[0]->dtstart->hour,$vcalendar->event[0]->dtstart->min,$vcalendar->event[0]->dtstart->sec,$vcalendar->event[0]->dtstart->month,$vcalendar->event[0]->dtstart->mday,$vcalendar->event[0]->dtstart->year); - echo "Date Start : ".$phpgw->common->show_date($datetime)."
\n"; + echo "Summary = ".$vcalendar->event[0]->summary."
\n"; + echo "Location = ".$vcalendar->event[0]->location."
\n"; + echo "Sequence = ".$vcalendar->event[0]->sequence."
\n"; + echo "Date Start : ".$phpgw->common->show_date(mktime($vcalendar->event[0]->dtstart->hour,$vcalendar->event[0]->dtstart->min,$vcalendar->event[0]->dtstart->sec,$vcalendar->event[0]->dtstart->month,$vcalendar->event[0]->dtstart->mday,$vcalendar->event[0]->dtstart->year))."
\n"; echo "Organizer = ".$vcalendar->event[0]->organizer->mailto->user.'@'.$vcalendar->event[0]->organizer->mailto->host."
\n"; - echo "Attendee[0] = ".$vcalendar->event[0]->attendee[0]->mailto->user.'@'.$vcalendar->event[0]->attendee[0]->mailto->host."
\n"; - echo "Attendee[1] = ".$vcalendar->event[0]->attendee[1]->mailto->user.'@'.$vcalendar->event[0]->attendee[1]->mailto->host."
\n"; + for($i=0;$i<3;$i++) + { + echo "Attendee[$i] CN = ".$vcalendar->event[0]->attendee[$i]->cn."
\n"; + echo "Attendee[$i] Address= ".$vcalendar->event[0]->attendee[$i]->mailto->user.'@'.$vcalendar->event[0]->attendee[$i]->mailto->host."
\n"; + echo "Attendee[$i] Role = ".$vcal->switch_role($vcalendar->event[0]->attendee[$i]->role)."
\n"; +// echo "Attendee[$i] RSVP = ".$vcal->switch_rsvp($vcalendar->event[0]->attendee[$i]->rsvp)."
\n"; + echo "Attendee[$i] RSVP = ".$vcalendar->event[0]->attendee[$i]->rsvp."
\n"; + } echo "Class = ".$vcalendar->event[0]->class."
\n"; $phpgw->common->phpgw_footer(); ?> diff --git a/calendar/inc/class.vCalendar.inc.php b/calendar/inc/class.vCalendar.inc.php index ca2b777210..37816a7c32 100755 --- a/calendar/inc/class.vCalendar.inc.php +++ b/calendar/inc/class.vCalendar.inc.php @@ -1,8 +1,8 @@ * + * Written by Mark Peters * * -------------------------------------------- * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the * @@ -12,6 +12,9 @@ /* $Id$ */ +define('VEVENT',1); +define('VTODO',2); + define('NONE',0); define('CHAIR',1); define('REQ_PARTICIPANT',2); @@ -24,9 +27,22 @@ define('RESOURCE',4); define('ROOM',8); define('UNKNOWN',16); +define('NEEDS_ACTION',0); +define('ACCEPTED',1); +define('DECLINED',2); +define('TENTATIVE',3); +define('DELEGATED',4); +define('COMPLETED',5); +define('IN_PROCESS',6); + define('PRIVATE',0); define('PUBLIC',1); -define('CONFIDENTIAL',0); +define('CONFIDENTIAL',3); + +define('TRANSPARENT',0); +define('OPAQUE',1); + +define('OTHER',99); class mailto { @@ -39,13 +55,13 @@ class attendee var $cn = 'Unknown'; var $cutype = INDIVIDUAL; var $role = REQ_PARTICIPANT; - var $rsvp = False; + var $rsvp = 0; var $mailto; var $sent_by; var $delegated_from; var $delegated_to; var $member; - var $partstat; + var $partstat = NEEDS_ACTION; } class organizer @@ -55,7 +71,7 @@ class organizer var $delegated_from; var $delegated_to; var $member; - var $partstat; + var $partstat = NEEDS_ACTION; var $mailto; var $sent_by; } @@ -90,7 +106,7 @@ class vCalendar_event var $dtstart; var $dtend; var $location; - var $transp; + var $transp = OPAQUE; var $sequence; var $uid; var $dtstamp; @@ -124,9 +140,18 @@ class vCalendar $dtime->year = intval(substr($value,0,4)); $dtime->month = intval(substr($value,4,2)); $dtime->mday = intval(substr($value,6,2)); - $dtime->hour = intval(substr($value,9,2)); - $dtime->min = intval(substr($value,11,2)); - $dtime->sec = intval(substr($value,13,2)); + if(substr($value,8,1) == 'T') + { + $dtime->hour = intval(substr($value,9,2)); + $dtime->min = intval(substr($value,11,2)); + $dtime->sec = intval(substr($value,13,2)); + } + else + { + $dtime->hour = 0; + $dtime->min = 0; + $dtime->sec = 0; + } return $dtime; } @@ -150,7 +175,7 @@ class vCalendar { // if($value != False) // { - $type = strtolower($type); + $type = strtolower(str_replace('-','_',$type)); $event->$type = $value; // } } @@ -175,11 +200,7 @@ class vCalendar function strip_quotes($str) { - if(strpos(' '.$str.' ','"')) - { - $str = substr($str,1,strlen($str)-2); - } - return $str; + return str_replace('"','',$str); } function strip_param($str) @@ -195,34 +216,203 @@ class vCalendar } } + function switch_role($var) + { + if(gettype($var) == 'string') + { + switch($var) + { + case 'NONE': + return NONE; + break; + case 'CHAIR': + return CHAIR; + break; + case 'REQ-PARTICIPANT': + return REQ_PARTICIPANT; + break; + case 'OPT-PARTICIPANT': + return OPT_PARTICIPANT; + break; + case 'NON-PARTICIPANT': + return NON_PARTICIPANT; + break; + } + } + elseif(gettype($var) == 'integer') + { + switch($var) + { + case NONE: + return 'NONE'; + break; + case CHAIR: + return 'CHAIR'; + break; + case REQ_PARTICIPANT: + return 'REQ-PARTICIPANT'; + break; + case OPT_PARTICIPANT: + return 'OPT-PARTICIPANT'; + break; + case NON_PARTICIPANT: + return 'NON-PARTICIPANT'; + break; + } + } + else + { + return $var; + } + } + + function switch_partstat($var) + { + if(gettype($var) == 'string') + { + switch($var) + { + case 'NEEDS-ACTION': + return NEEDS_ACTION; + break; + case 'ACCEPTED': + return ACCEPTED; + break; + case 'DECLINED': + return DECLINED; + break; + case 'TENTATIVE': + return TENTATIVE; + break; + case 'DELEGATED': + return DELEGATED; + break; + case 'COMPLETED': + return COMPLETED; + break; + case 'IN-PROCESS': + return IN_PROCESS; + break; + default: + return OTHER; + break; + } + } + elseif(gettype($var) == 'integer') + { + switch($var) + { + case NEEDS_ACTION: + return 'NEEDS-ACTION'; + break; + case ACCEPTED: + return 'ACCEPTED'; + break; + case DECLINED: + return 'DECLINED'; + break; + case TENTATIVE: + return 'TENTATIVE'; + break; + case DELEGATED: + return 'DELEGATED'; + break; + case COMPLETED: + return 'COMPLETED'; + break; + case IN_PROCESS: + return 'IN-PROCESS'; + break; + default: + return 'X-OTHER'; + break; + } + } + else + { + return $var; + } + } + + function switch_rsvp($var) + { + if(gettype($var) == 'string') + { + if($var == 'TRUE') + { + return 1; + } + else + { + return 0; + } + } + elseif(gettype($var) == 'boolean') + { + if($var == 1) + { + return 'TRUE'; + } + else + { + return 'FALSE'; + } + } + else + { + return $var; + } + } + function parse_attendee(&$event,$value) { $param = explode(':',$value); for($j=0;$jset_var($event,$type[0],$this->strip_quotes($type[1])); - } - else - { - if(strpos($param[$j],'@')) + if(strpos($param_sub[$k],'=')) { - $this->set_var($event,'mailto',$this->split_address($param[$j])); + $type = explode('=',$param_sub[$k]); + $type[0] = strtolower($type[0]); + $type[1] = $this->strip_quotes($type[1]); + switch($type[0]) + { + case 'role': + $val = $this->switch_role($type[1]); + break; + case 'partstat': + $val = $this->switch_partstat($type[1]); + break; + case 'rsvp': + $val = $this->switch_rsvp($type[1]); + break; + default: + $val = $type[1]; + break; + } + $this->set_var($event,$type[0],$val); } else { - switch(strtolower($param[$j])) + if(strpos($param_sub[$k],'@')) { - case 'mailto': - $email_addy = $param[$j + 1]; - $this->set_var($event,$param[$j++],$this->split_address($email_addy)); - break; - default: - $var = $this->strip_param($this->strip_quotes($param[$j + 1])); - $this->set_var($event,$param[$j++],$var); - break; + $this->set_var($event,'mailto',$this->split_address($param_sub[$k])); + } + else + { + switch(strtolower($param_sub[$k])) + { + case 'mailto': + $email_addy = $param_sub[$k + 1]; + $this->set_var($event,$param_sub[$k++],$this->split_address($email_addy)); + break; + default: + $var = $this->strip_param($this->strip_quotes($param_sub[$k + 1])); + $this->set_var($event,$param_sub[$k++],$var); + break; + } } } } @@ -352,21 +542,33 @@ class vCalendar case 'dtstamp': $this->set_var($event,$majortype,$this->splitdate($value)); break; -// case 'class': -// switch(strtolower($value)) -// { -// case 'private': -// $var = PRIVATE; -// break; -// case 'public': -// $var = PUBLIC; -// break; -// case 'confidential': -// $var = CONFIDENTIAL; -// break; -// } -// $this->set_var($event,$majortype,$var); -// break; + case 'class': + switch(strtolower($value)) + { + case 'private': + $class = PRIVATE; + break; + case 'public': + $class = PUBLIC; + break; + case 'confidential': + $class = CONFIDENTIAL; + break; + } + $this->set_var($event,$majortype,$class); + break; + case 'transp': + switch(strtolower($value)) + { + case 'transparent': + $transp = TRANSPARENT; + break; + case 'opaque': + $transp = OPAQUE; + break; + } + $this->set_var($event,$majortype,$transp); + break; case 'rrule': $event->$majortype = new $majortype; $this->parse_recurrence($event->$majortype,$value); diff --git a/calendar/inc/vcal1.ics b/calendar/inc/vcal1.ics new file mode 100755 index 0000000000..84e318ddc3 --- /dev/null +++ b/calendar/inc/vcal1.ics @@ -0,0 +1,23 @@ +BEGIN:VCALENDAR +PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN +VERSION:2.0 +METHOD:REQUEST +BEGIN:VEVENT +ATTENDEE;CN="Doe John (Marketing)";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:John.Doe@somewhere.com +ATTENDEE;CN="Jones Bill (IT)";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:Bill.Jones@somewhere.com +ATTENDEE;CN="Smith Mary (PR)";ROLE=NON-PARTICIPANT;RSVP=FALSE:MAILTO:Mary.Smith@elsewhere.com +ORGANIZER:MAILTO:John.Doe@somewhere.com +DTSTART:20010302T150000Z +DTEND:20010302T153000Z +LOCATION:Conference Room #2 +TRANSP:OPAQUE +SEQUENCE:0 +UID:023007208203E60074C5B7107A82E00803730C0D40A12C0042A2C001009384EA000F00B100 + 184029BDFF7C7650ED5118DF7028059A01231 +DTSTAMP:20010301T172312Z +DESCRIPTION:\n +SUMMARY:Web Site Redesign +PRIORITY:5 +CLASS:PUBLIC +END:VEVENT +END:VCALENDAR