From fe32e5d89edf0c9c1db621ac02b0cd6b02dda89e Mon Sep 17 00:00:00 2001 From: skeeter Date: Wed, 29 Aug 2001 19:17:52 +0000 Subject: [PATCH] Moved ical_test.php => class.uiicalendar.inc.php. --- calendar/ical_test.php | 185 ------------------------- calendar/inc/class.uiicalendar.inc.php | 165 ++++++++++++++++++++++ 2 files changed, 165 insertions(+), 185 deletions(-) delete mode 100755 calendar/ical_test.php create mode 100755 calendar/inc/class.uiicalendar.inc.php diff --git a/calendar/ical_test.php b/calendar/ical_test.php deleted file mode 100755 index 71de55cb4c..0000000000 --- a/calendar/ical_test.php +++ /dev/null @@ -1,185 +0,0 @@ - * - * http://www.radix.net/~cknudsen * - * Modified 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 * - * Free Software Foundation; either version 2 of the License, or (at your * - * option) any later version. * - \**************************************************************************/ - - /* $Id$ */ - $phpgw_flags = Array( - 'currentapp' => 'calendar', - 'noappheader' => True, - 'noappfooter' => True - ); - $phpgw_info['flags'] = $phpgw_flags; - include('../header.inc.php'); - -echo "Start Time : ".$phpgw->common->show_date()."
\n"; - @set_time_limit(0); - - $icsfile=PHPGW_APP_INC.'/events.ics'; - $fp=fopen($icsfile,'rt'); - $contents = explode("\n",fread($fp, filesize($icsfile))); - fclose($fp); - -// $vcal = CreateObject('calendar.vCalendar'); - -// $vcalendar = $vcal->read($contents); - -// echo "function_exists = ".function_exists("\$vcalendar->read()")."
\n"; - - $vcalendar = ExecMethod('calendar.vCalendar.read',$contents); - - echo "Product ID = ".$vcalendar['prodid']['value']."
\n"; - echo "Method = ".$vcalendar['method']['value']."
\n"; - echo "Version = ".$vcalendar['version']['value']."
\n"; - - for($i=0;$i\nEVENT
\n"; - if($vcalendar['event'][$i]['uid']) - { - echo 'UID = '.$vcalendar['event'][$i]['uid']['value']."
\n"; - } - if($vcalendar['event'][$i]['calscale']) - { - echo "Calscale = ".$vcalendar['event'][$i]['calscale']."
\n"; - } - if($vcalendar['event'][$i]['description']['value']) - { - echo "Description (Value) = ".$vcalendar['event'][$i]['description']['value']."
\n"; - } - if($vcalendar['event'][$i]['description']['altrep']) - { - echo "Description (Alt Rep) = ".$vcalendar['event'][$i]['description']['altrep']."
\n"; - } - if($vcalendar['event'][$i]['description']['x_type']) - { - for($j=0;$j\n"; - } - } - if($vcalendar['event'][$i]['summary']['value']) - { - echo "Summary = ".$vcalendar['event'][$i]['summary']['value']."
\n"; - } - if(!empty($vcalendar['event'][$i]['comment'])) - { - for($j=0;$j\n"; - } - } - if($vcalendar['event'][$i]['location']['value']) - { - echo "Location = ".$vcalendar['event'][$i]['location']['value']."
\n"; - } - echo "Sequence = ".$vcalendar['event'][$i]['sequence']."
\n"; -// echo _debug_array($vcalendar['event'][$i]['dtstart'])."
\n"; - echo "Date Start : ".$phpgw->common->show_date(mktime($vcalendar['event'][$i]['dtstart']['hour'],$vcalendar['event'][$i]['dtstart']['min'],$vcalendar['event'][$i]['dtstart']['sec'],$vcalendar['event'][$i]['dtstart']['month'],$vcalendar['event'][$i]['dtstart']['mday'],$vcalendar['event'][$i]['dtstart']['year']) - $phpgw->calendar->datatime->tz_offset)."
\n"; - if($vcalendar['event'][$i]['dtstart']['tzid']) - { - echo "Date Start TZID : ".$vcalendar['event'][$i]['dtstart']['tzid']."
\n"; - } - if($vcalendar['event'][$i]['rrule']) - { - for($j=0;$j\n"; - } - if($vcalendar['event'][$i]['rrule'][$j]['byday']) - { - echo "Recurrence : Byday = ".$vcalendar['event'][$i]['rrule'][$j]['byday']."
\n"; - } - if($vcalendar['event'][$i]['rrule'][$j]['until']) - { - echo "Recurrence : Until = ".date('Ymd',mktime($vcalendar['event'][$i]['rrule'][$j]['until']['hour'],$vcalendar['event'][$i]['rrule'][$j]['until']['min'],$vcalendar['event'][$i]['rrule'][$j]['until']['sec'],$vcalendar['event'][$i]['rrule'][$j]['until']['month'],$vcalendar['event'][$i]['rrule'][$j]['until']['mday'],$vcalendar['event'][$i]['rrule'][$j]['until']['year']))."
\n"; - } - } - } - echo "Class = ".$vCalendar->switch_class($vcalendar['event'][$i]['class'])."
\n"; - if($vcalendar['event'][$i]['organizer']) - { - echo "Organizer = ".$vcalendar['event'][$i]['organizer']['mailto']['user'].'@'.$vcalendar['event'][$i]['organizer']['mailto']['host']."
\n"; - if($vcalendar['event'][$i]['organizer']['dir']) - { - echo "Organizer Dir = ".$vcalendar['event'][$i]['organizer']['dir']."
\n"; - } - } - for($j=0;$j\nAttendee[$j] CN = ".$vcalendar['event'][$i]['attendee'][$j]['cn']."
\n"; - if($vcalendar['event'][$i]['attendee'][$j]['dir']) - { - echo "Attendee[$j] Dir = ".$vcalendar['event'][$i]['attendee'][$j]['dir']."
\n"; - } - echo "Attendee[$j] Address = ".$vcalendar['event'][$i]['attendee'][$j]['mailto']['user'].'@'.$vcalendar['event'][$i]['attendee'][$j]['mailto']['host']."
\n"; - echo "Attendee[$j] Role = ".$vCalendar->switch_role($vcalendar['event'][$i]['attendee'][$j]['role'])."
\n"; - echo "Attendee[$j] RSVP = ".$vCalendar->switch_rsvp($vcalendar['event'][$i]['attendee'][$j]['rsvp'])."
\n"; -// echo "Attendee[$j] RSVP = ".$vcalendar['event'][$i]['attendee'][$j]['rsvp']."
\n"; - if($vcalendar['event'][$i]['attendee'][$j]['x_type']) - { - for($k=0;$k\n"; - } - } - if($vcalendar['event'][$i]['attendee'][$j]['delegated_from']['user'] && $vcalendar['event'][$i]['attendee'][$j]['delegated_from']['host']) - { - echo "Attendee[$j] DELEGATED_FROM = ".$vcalendar['event'][$i]['attendee'][$j]['delegated_from']['user'].'@'.$vcalendar['event'][$i]['attendee'][$j]['delegated_from']['host']."
\n"; - } - } - if($vcalendar['event'][$i]['alarm']) - { - for($j=0;$j\n"; - - } - } - } - -/* - for($i=0;$itodo);$i++) - { - echo "
\nTODO
\n"; - if($vcalendar->todo[$i]->summary->value) - { - echo "Summary = ".$vcalendar->todo[$i]->summary->value."
\n"; - } - if($vcalendar->todo[$i]->description->value) - { - echo "Description (Value) = ".$vcalendar->todo[$i]->description->value."
\n"; - } - if($vcalendar->todo[$i]->description->altrep) - { - echo "Description (Alt Rep) = ".$vcalendar->todo[$i]->description->altrep."
\n"; - } - if($vcalendar->event[$i]->location->value) - { - echo "Location = ".$vcalendar->todo[$i]->location->value."
\n"; - } - echo "Sequence = ".$vcalendar->todo[$i]->sequence."
\n"; - echo "Date Start : ".$phpgw->common->show_date(mktime($vcalendar->todo[$i]->dtstart->value->hour,$vcalendar->todo[$i]->dtstart->value->min,$vcalendar->todo[$i]->dtstart->value->sec,$vcalendar->todo[$i]->dtstart->value->month,$vcalendar->todo[$i]->dtstart->value->mday,$vcalendar->todo[$i]->dtstart->value->year) - $phpgw->calendar->datatime->tz_offset)."
\n"; - echo "Class = ".$vcalendar->todo[$i]->class->value."
\n"; - } - -*/ - include(PHPGW_APP_INC.'/../setup/setup.inc.php'); - - $vCalendar->set_var($vcalendar['prodid'],'value','-//phpGroupWare//phpGroupWare '.$setup_info['calendar']['version'].' MIMEDIR//'.strtoupper($phpgw_info['user']['preferences']['common']['lang'])); - echo "


\n"; - echo nl2br(execmethod('calendar.vCalendar.build_vcal',$vcalendar)); -echo "End Time : ".$phpgw->common->show_date()."
\n"; - $phpgw->common->phpgw_footer(); -?> diff --git a/calendar/inc/class.uiicalendar.inc.php b/calendar/inc/class.uiicalendar.inc.php new file mode 100755 index 0000000000..f41294f093 --- /dev/null +++ b/calendar/inc/class.uiicalendar.inc.php @@ -0,0 +1,165 @@ + * + * http://www.radix.net/~cknudsen * + * Modified 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 * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \**************************************************************************/ + + /* $Id$ */ + + class uiicalendar + { + var $bo; + var $datetime; + + var $public_functions = array( + 'test' => True + ); + + + + function uiicalendar() + { + $this->bo = CreateObject('calendar.boicalendar'); + $this->datetime = CreateObject('phpgwapi.datetime'); + } + + + function print_test($val,$title,$x_pre='') + { +// echo 'VAL = '._debug_array($val)."
\n"; + if(is_array($val)) + { + @reset($val); + while(list($key,$value) = each($val)) + { + if(is_array($key)) + { + $this->print_test($key,$title,$x_pre); + } + elseif(is_array($value)) + { + $this->print_test($value,$title,$x_pre); + } + else + { + if($x_pre && $key == 'name') + { + $x_key = $x_pre.$value; + list($key,$value) = each($val); + $key=$x_key; + } + if($this->bo->parameter[$key]['type'] == 'function') + { + $function = $this->bo->parameter[$key]['function']; + $v_value = $this->bo->$function($value); + } + else + { + $v_value = $value; + } + echo $title.' ('.$key.') = '.$v_value."
\n"; + } + } + } + elseif($val != '') + { + echo $title.' = '.$val."
\n"; + } + } + + function test() + { + $print_events = False; + + unset($GLOBALS['phpgw_info']['flags']['noheader']); + unset($GLOBALS['phpgw_info']['flags']['nonavbar']); + $GLOBALS['phpgw']->common->phpgw_header(); + + echo "Start Time : ".$GLOBALS['phpgw']->common->show_date()."
\n"; + @set_time_limit(0); + + $icsfile=PHPGW_APP_INC.'/events.ics'; + $fp=fopen($icsfile,'rt'); + $contents = explode("\n",fread($fp, filesize($icsfile))); + fclose($fp); + + $vcalendar = $this->bo->parse($contents); + + if($print_events) + { + $this->print_test($vcalendar['prodid'],'Product ID'); + $this->print_test($vcalendar['method'],'Method'); + $this->print_test($vcalendar['version'],'Version'); + + for($i=0;$i\nEVENT
\n"; +// echo 'TEST Debug : '._debug_array($event)."
\n"; + $this->print_test($event['uid'],'UID','X-'); + $this->print_test($event['valscale'],'Calscale','X-'); + $this->print_test($event['description'],'Description','X-'); + $this->print_test($event['summary'],'Summary','X-'); + $this->print_test($event['comment'],'Comment','X-'); + $this->print_test($event['location'],'Location','X-'); + $this->print_test($event['sequence'],'Sequence','X-'); + $this->print_test($event['priority'],'Priority','X-'); + $this->print_test($event['dtstart'],'Date Start','X-'); + $this->print_test($event['dtstamp'],'Date Stamp','X-'); + $this->print_test($event['rrule'],'Recurrence','X-'); + + echo "Class = ".$this->bo->switch_class($event['class'])."
\n"; + + $this->print_test($event['organizer'],'Organizer','X-'); + $this->print_test($event['attendee'],'Attendee','X-'); + $this->print_test($event['x_type'],'X-Type','X-'); + $this->print_test($event['alarm'],'Alarm','X-'); + } + } + +/* + for($i=0;$itodo);$i++) + { + echo "
\nTODO
\n"; + if($vcalendar['todo'][$i]['summary']['value']) + { + echo "Summary = ".$vcalendar['todo'][$i]['summary']['value']."
\n"; + } + if($vcalendar['todo'][$i]['description']['value']) + { + echo "Description (Value) = ".$vcalendar['todo'][$i]['description']['value']."
\n"; + } + if($vcalendar['todo'][$i]['description']['altrep']) + { + echo "Description (Alt Rep) = ".$vcalendar['todo'][$i]['description']['altrep']."
\n"; + } + if($vcalendar['todo'][$i]['location']['value']) + { + echo "Location = ".$vcalendar['todo'][$i]['location']['value']."
\n"; + } + echo "Sequence = ".$vcalendar['todo'][$i]['sequence']."
\n"; + echo "Date Start : ".$GLOBALS['phpgw']->common->show_date(mktime($vcalendar['todo'][$i]['dtstart']['hour'],$vcalendar['todo'][$i]['dtstart']['min'],$vcalendar['todo'][$i]['dtstart']['sec'],$vcalendar['todo'][$i]['dtstart']['month'],$vcalendar['todo'][$i]['dtstart']['mday'],$vcalendar['todo'][$i]['dtstart']['year']) - $this->datatime->tz_offset)."
\n"; + echo "Class = ".$vcalendar['todo'][$i]['class']['value']."
\n"; + } + +*/ + include(PHPGW_APP_INC.'/../setup/setup.inc.php'); + + $this->bo->set_var($vcalendar['prodid'],'value','-//phpGroupWare//phpGroupWare '.$setup_info['calendar']['version'].' MIMEDIR//'.strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])); + $this->bo->set_var($vcalendar['version'],'value','2.0'); + $this->bo->set_var($vcalendar['method'],'value',strtoupper('publish')); + echo "


\n"; + echo nl2br($this->bo->build_ical($vcalendar)); + echo "End Time : ".$GLOBALS['phpgw']->common->show_date()."
\n"; + } + } +?>