2001-03-17 20:39:56 +01:00
< ? php
/************************************************************************** \
2004-01-27 01:31:58 +01:00
* eGroupWare - iCalendar Parser *
* http :// www . egroupware . org *
2001-06-10 19:05:51 +02:00
* Written by Mark Peters < skeeter @ phpgroupware . org > *
2001-03-17 20:39:56 +01:00
* -------------------------------------------- *
* 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$ */
2004-01-04 01:47:37 +01:00
define ( 'FOLD_LENGTH' , 75 );
define ( 'VEVENT' , 1 );
define ( 'VTODO' , 2 );
define ( 'NONE' , 0 );
define ( 'CHAIR' , 1 );
define ( 'REQ_PARTICIPANT' , 2 );
define ( 'OPT_PARTICIPANT' , 3 );
define ( 'NON_PARTICIPANT' , 4 );
define ( 'INDIVIDUAL' , 1 );
define ( 'GROUP' , 2 );
define ( 'RESOURCE' , 4 );
define ( 'ROOM' , 8 );
define ( 'UNKNOWN' , 16 );
2004-10-15 19:28:34 +02:00
/* event status */
2004-01-04 01:47:37 +01:00
define ( 'NEEDS_ACTION' , 0 );
define ( 'ACCEPTED' , 1 );
define ( 'DECLINED' , 2 );
define ( 'TENTATIVE' , 3 );
define ( 'DELEGATED' , 4 );
define ( 'COMPLETED' , 5 );
define ( 'IN_PROCESS' , 6 );
2001-06-10 19:05:51 +02:00
2004-10-15 19:28:34 +02:00
/* class */
2005-04-06 06:55:49 +02:00
define ( 'PRIVATECAL' , 0 );
define ( 'PUBLICCAL' , 1 );
2004-01-04 01:47:37 +01:00
define ( 'CONFIDENTIAL' , 3 );
2001-06-10 19:05:51 +02:00
2004-10-15 19:28:34 +02:00
/* transparency */
2004-01-04 01:47:37 +01:00
define ( 'TRANSPARENT' , 0 );
define ( 'OPAQUE' , 1 );
2001-06-10 19:05:51 +02:00
2004-10-15 19:28:34 +02:00
/* frequency */
2004-01-04 01:47:37 +01:00
define ( 'SECONDLY' , 1 );
define ( 'MINUTELY' , 2 );
define ( 'HOURLY' , 3 );
define ( 'DAILY' , 4 );
define ( 'WEEKLY' , 5 );
define ( 'MONTHLY' , 6 );
define ( 'YEARLY' , 7 );
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
define ( 'FREE' , 0 );
define ( 'BUSY' , 1 );
define ( 'BUSY_UNAVAILABLE' , 2 );
define ( 'BUSY_TENTATIVE' , 3 );
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
define ( 'THISANDPRIOR' , 0 );
define ( 'THISANDFUTURE' , 1 );
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
define ( 'START' , 0 );
define ( 'END' , 1 );
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
define ( '_8BIT' , 0 );
define ( '_BASE64' , 1 );
2001-07-02 05:31:13 +02:00
2004-01-04 01:47:37 +01:00
define ( 'OTHER' , 99 );
2001-09-07 18:37:11 +02:00
2004-01-04 01:47:37 +01:00
class boicalendar
{
2001-09-07 18:37:11 +02:00
var $public_functions = array (
2004-01-04 01:47:37 +01:00
'import' => True ,
2004-03-14 02:10:37 +01:00
'export' => True ,
'freebusy' => True ,
2001-09-07 18:37:11 +02:00
);
2004-01-04 01:47:37 +01:00
var $ical ;
var $line = 0 ;
var $event = Array ();
var $todo = Array ();
var $journal = Array ();
var $freebusy = Array ();
var $timezone = Array ();
var $property = Array ();
var $parameter = Array ();
var $debug_str = False ;
var $api = True ;
var $chunk_split = True ;
/*
* Base Functions
*/
function boicalendar ()
{
$this -> property = Array (
2004-10-15 19:28:34 +02:00
'action' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'attach' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'uri' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'attendee' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'cal-address' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
'vfreebusy' => Array (
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'categories' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'class' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'comment' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'daylight' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'standard' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'completed' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'contact' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'created' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
'vjournal' => Array (
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'description' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'dtend' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'dtstamp' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'dtstart' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'daylight' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'standard' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'due' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'duration' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'duration' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'exdate' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'exrule' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'recur' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'freebusy' => Array (
2005-03-31 15:19:16 +02:00
'type' => 'text' ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'geo' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'float' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'last_modified' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtimezone' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'location' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'method' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'ical' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'organizer' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'cal-address' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'percent_complete' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'integer' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'priority' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'integer' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'prodid' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
'ical' => Array (
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'rdate' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'daylight' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'standard' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'recurrence_id' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'date-time' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
'vtodo' => Array (
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'related_to' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'request_status' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'resources' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'rrule' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'recur' ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'daylight' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
2004-10-15 19:28:34 +02:00
'multiples' => False
2004-01-04 01:47:37 +01:00
),
2004-10-15 19:28:34 +02:00
'standard' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
2004-10-15 19:28:34 +02:00
'multiples' => False
2004-01-04 01:47:37 +01:00
),
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
2004-10-15 19:28:34 +02:00
'multiples' => False
2004-01-04 01:47:37 +01:00
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
2004-10-15 19:28:34 +02:00
'multiples' => False
2004-01-04 01:47:37 +01:00
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
2004-10-15 19:28:34 +02:00
'multiples' => False
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'sequence' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'integer' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'status' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'summary' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'transp' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'trigger' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'valarm' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'tzid' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vtimezone' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'tzname' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'daylight' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
),
2004-10-15 19:28:34 +02:00
'standard' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => True
)
),
2004-10-15 19:28:34 +02:00
'tzoffsetfrom' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'utc-offset' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'daylight' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'standard' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'tzoffsetto' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'utc-offset' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'daylight' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'standard' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'tzurl' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'uri' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vtimezone' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'uid' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vtodo' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'url' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'vevent' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vfreebusy' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
),
2004-10-15 19:28:34 +02:00
'vjournal' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'optional' ,
'multiples' => False
),
'vtodo' => Array (
'state' => 'required' ,
'multiples' => False
)
),
2004-10-15 19:28:34 +02:00
'version' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'ical' => Array (
2004-01-04 01:47:37 +01:00
'state' => 'required' ,
'multiples' => False
)
2001-07-09 13:35:13 +02:00
)
2004-01-04 01:47:37 +01:00
);
$this -> parameter = Array (
2004-10-15 19:28:34 +02:00
'altrep' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'uri' ,
'quoted' => True ,
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'comment' => True ,
2004-01-04 01:47:37 +01:00
'description' => True ,
2004-10-15 19:28:34 +02:00
'location' => True ,
'prodid' => True ,
'resources' => True ,
'summary' => True ,
'contact' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'byday' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'byhour' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'byminute' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'bymonth' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'bymonthday' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'bysecond' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'bysetpos' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'byweekno' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'byyearday' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'class' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_class' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'class' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'cn' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => True ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True ,
'organizer' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'count' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'integer' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'cu' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_cu' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'delegated_from' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_mailto' ,
2004-10-15 19:28:34 +02:00
'quoted' => True ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'delegated_to' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_mailto' ,
2004-10-15 19:28:34 +02:00
'quoted' => True ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'dir' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'dir' ,
2004-10-15 19:28:34 +02:00
'quoted' => True ,
2004-01-04 01:47:37 +01:00
'to_text' => True ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True ,
'organizer' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'dtend' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_date' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'dtend' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'dtstamp' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_date' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'dtstamp' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'dtstart' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_date' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'dtstart' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'encoding' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_encoding' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attach' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'fmttype' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attach' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'fbtype' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_fbtype' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attach' => True
2004-01-04 01:47:37 +01:00
)
),
2005-03-31 15:19:16 +02:00
'freebusy' => Array (
'type' => 'text' ,
'quoted' => False ,
'to_text' => False ,
'properties' => Array (
'freebusy' => True
)
),
2004-10-15 19:28:34 +02:00
'freq' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_freq' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'rrule' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'interval' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'integer' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'rrule' => True
)
),
2004-10-15 19:28:34 +02:00
'language' => Array (
'type' => 'text' ,
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'categories' => True ,
2004-10-15 19:28:34 +02:00
'comment' => True ,
2004-01-04 01:47:37 +01:00
'description' => True ,
2004-10-15 19:28:34 +02:00
'location' => True ,
'resources' => True ,
'summary' => True ,
'tzname' => True ,
'attendee' => True ,
'contact' => True ,
'organizer' => True ,
'x-type' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'last_modified' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_date' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'last_modified' => True
)
),
2004-10-15 19:28:34 +02:00
'mailto' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_mailto' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True ,
'organizer' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'member' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_mailto' ,
2004-10-15 19:28:34 +02:00
'quoted' => True ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'partstat' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_partstat' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True ,
'organizer' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'range' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_range' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'recurrence_id' => True
)
),
2004-10-15 19:28:34 +02:00
'related' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_related' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'related_to' => True
)
),
2004-10-15 19:28:34 +02:00
'role' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_role' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True ,
'organizer' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'rsvp' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_rsvp' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'sent_by' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
2004-08-18 22:40:44 +02:00
'function' => 'switch_mailto' ,
2004-10-15 19:28:34 +02:00
'quoted' => True ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'attendee' => True ,
'organizer' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'tzid' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'text' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
'dtend' => True ,
'due' => True ,
2004-01-04 01:47:37 +01:00
'dtstart' => True ,
2004-10-15 19:28:34 +02:00
'exdate' => True ,
2004-01-04 01:47:37 +01:00
'rdate' => True ,
'recurrence_id' => True
)
),
2004-10-15 19:28:34 +02:00
'until' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'function' ,
'function' => 'switch_date' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'rrule' => True
)
),
2004-10-15 19:28:34 +02:00
'value' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'value' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'calscale' => True ,
2004-10-15 19:28:34 +02:00
'prodid' => True ,
'method' => True ,
2004-01-04 01:47:37 +01:00
'version' => True ,
2004-10-15 19:28:34 +02:00
'attach' => True ,
2004-01-04 01:47:37 +01:00
'categories' => True ,
'class' => True ,
'comment' => True ,
'description' => True ,
'geo' => True ,
'location' => True ,
'percent' => True ,
'priority' => True ,
'resources' => True ,
2004-10-15 19:28:34 +02:00
'status' => True ,
2004-01-04 01:47:37 +01:00
'summary' => True ,
'completed' => True ,
'dtend' => True ,
'due' => True ,
'dtstart' => True ,
'duration' => True ,
'freebusy' => True ,
2004-10-15 19:28:34 +02:00
'transp' => True ,
2004-01-04 01:47:37 +01:00
'tzid' => True ,
2004-10-15 19:28:34 +02:00
'tzname' => True ,
2004-01-04 01:47:37 +01:00
'tzoffsetfrom' => True ,
'tzoffsetto' => True ,
'tzurl' => True ,
'attendee' => True ,
'contact' => True ,
'organizer' => True ,
'recurrence_id' => True ,
'url' => True ,
'uid' => True ,
'exdate' => True ,
'exrule' => True ,
2004-10-15 19:28:34 +02:00
'rdate' => True ,
'rrule' => True ,
2004-01-04 01:47:37 +01:00
'action' => True ,
'repeat' => True ,
'trigger' => True ,
'created' => True ,
'dtstamp' => True ,
'last_modified' => True ,
'sequence' => True ,
2004-10-15 19:28:34 +02:00
'x_type' => True ,
'request_status' => True
2004-01-04 01:47:37 +01:00
)
),
2004-10-15 19:28:34 +02:00
'wkst' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'string' ,
'quoted' => False ,
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'rrule' => True
)
),
2004-10-15 19:28:34 +02:00
'x_type' => Array (
2004-01-04 01:47:37 +01:00
'type' => 'x_type' ,
2004-10-15 19:28:34 +02:00
'quoted' => False ,
2004-01-04 01:47:37 +01:00
'to_text' => False ,
2004-10-15 19:28:34 +02:00
'properties' => Array (
2004-01-04 01:47:37 +01:00
'calscale' => True ,
2004-10-15 19:28:34 +02:00
'method' => True ,
'prodid' => True ,
2004-01-04 01:47:37 +01:00
'version' => True ,
2004-10-15 19:28:34 +02:00
'attach' => True ,
2004-01-04 01:47:37 +01:00
'categories' => True ,
'class' => True ,
'comment' => True ,
'description' => True ,
'geo' => True ,
'location' => True ,
'percent' => True ,
'priority' => True ,
'resources' => True ,
2004-10-15 19:28:34 +02:00
'status' => True ,
2004-01-04 01:47:37 +01:00
'summary' => True ,
'completed' => True ,
'dtend' => True ,
'due' => True ,
'dtstart' => True ,
'duration' => True ,
'freebusy' => True ,
2004-10-15 19:28:34 +02:00
'transp' => True ,
2004-01-04 01:47:37 +01:00
'tzid' => True ,
2004-10-15 19:28:34 +02:00
'tzname' => True ,
2004-01-04 01:47:37 +01:00
'tzoffsetfrom' => True ,
'tzoffsetto' => True ,
'tzurl' => True ,
'attendee' => True ,
'contact' => True ,
'organizer' => True ,
'recurrence_id' => True ,
'url' => True ,
'uid' => True ,
'exdate' => True ,
'exrule' => True ,
2004-10-15 19:28:34 +02:00
'rdate' => True ,
'rrule' => True ,
2004-01-04 01:47:37 +01:00
'action' => True ,
'repeat' => True ,
'trigger' => True ,
'created' => True ,
'dtstamp' => True ,
'last_modified' => True ,
'sequence' => True ,
2004-10-15 19:28:34 +02:00
'x_type' => True ,
'request_status' => True
2004-01-04 01:47:37 +01:00
)
2001-07-09 13:35:13 +02:00
)
2004-01-04 01:47:37 +01:00
);
if ( ! is_object ( $GLOBALS [ 'phpgw' ] -> datetime ))
{
$GLOBALS [ 'phpgw' ] -> datetime = createobject ( 'phpgwapi.datetime' );
}
2002-06-25 01:24:24 +02:00
}
2001-06-07 05:18:35 +02:00
2004-01-04 01:47:37 +01:00
function set_var ( & $event , $type , $value )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$type = strtolower ( str_replace ( '-' , '_' , $type ));
$event [ $type ] = $value ;
if ( is_string ( $value ))
{
$this -> debug ( " Setting " . $type . " = " . $value );
}
else
{
$this -> debug ( " Setting " . $type . " = " . _debug_array ( $value , False ));
}
2001-08-27 13:23:44 +02:00
}
2001-06-07 05:18:35 +02:00
2004-01-04 01:47:37 +01:00
function read_line_unfold ( $ical_text )
2001-06-07 05:18:35 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $this -> line < count ( $ical_text ))
2001-06-07 05:18:35 +02:00
{
2004-01-04 01:47:37 +01:00
$str = str_replace ( " \r \n " , '' , $ical_text [ $this -> line ]);
2001-08-04 03:34:49 +02:00
$this -> line = $this -> line + 1 ;
2004-01-04 01:47:37 +01:00
while ( ereg ( " ^[[:space:]] " , $ical_text [ $this -> line ]))
{
$str .= substr ( str_replace ( " \r \n " , '' , $ical_text [ $this -> line ]), 1 );
$this -> line = $this -> line + 1 ;
}
$this -> debug ( " LINE : " . $str );
return $str ;
}
else
{
return False ;
2001-06-07 05:18:35 +02:00
}
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
function fold ( $str )
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
return $this -> chunk_split == True ? chunk_split ( $str , FOLD_LENGTH , " \r \n " ) : $str . " \r \n " ;
2001-06-07 05:18:35 +02:00
}
2001-06-25 00:13:17 +02:00
2004-01-04 01:47:37 +01:00
function strip_quotes ( $str )
{
return str_replace ( '"' , '' , $str );
}
2001-05-06 02:11:12 +02:00
2004-01-04 01:47:37 +01:00
function from_text ( $str )
{
$str = str_replace ( " \\ , " , " , " , $str );
$str = str_replace ( " \\ ; " , " ; " , $str );
$str = str_replace ( " \\ N " , " \n " , $str );
$str = str_replace ( " \\ n " , " \n " , $str );
$str = str_replace ( " \\ \\ " , " \\ " , $str );
return " $str " ;
}
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
function to_text ( $str )
{
$str = str_replace ( " \\ " , " \\ \\ " , $str );
$str = str_replace ( " , " , " \\ , " , $str );
$str = str_replace ( " ; " , " \\ ; " , $str );
$str = str_replace ( " \n " , " \\ n " , $str );
return " $str " ;
}
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
function from_dir ( $str )
{
return str_replace ( '=3D' , '=' , str_replace ( '%20' , ' ' , $str ));
}
2001-08-27 13:23:44 +02:00
2004-01-04 01:47:37 +01:00
function to_dir ( $str )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
return str_replace ( '=' , '=3D' , str_replace ( ' ' , '%20' , $str ));
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
2005-03-31 15:19:16 +02:00
/**
* Searches all parameters allowed for a certain property
*
* @ param string $property , every key from the $this -> property
* @ return array with allowed parameters ( keys from $this -> parameters which list $property under 'properties'
*/
2004-01-04 01:47:37 +01:00
function find_parameters ( $property )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
static $cached_returns ;
if ( isset ( $cached_returns [ $property ]))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
reset ( $cached_returns [ $property ]);
return $cached_returns [ $property ];
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
reset ( $this -> parameter );
while ( list ( $key , $param_array ) = each ( $this -> parameter ))
{
if ( $param_array [ 'properties' ][ $property ])
{
$param [] = $key ;
$this -> debug ( 'Property : ' . $property . ' = Parameter : ' . $key );
}
}
reset ( $param );
$cached_returns [ $property ] = $param ;
return $param ;
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
function find_properties ( $ical_type )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
static $cached_returns ;
if ( isset ( $cached_returns [ $ical_type ]))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
reset ( $cached_returns [ $ical_type ]);
return $cached_returns [ $ical_type ];
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
reset ( $this -> property );
while ( list ( $key , $param_array ) = each ( $this -> property ))
{
if ( $param_array [ $ical_type ])
{
$prop [] = $key ;
}
}
reset ( $prop );
$cached_returns [ $ical_type ] = $prop ;
return $prop ;
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
function new_ical ()
{
return Array ();
}
2001-07-05 19:04:52 +02:00
2004-01-04 01:47:37 +01:00
/*
* Parse Functions
*/
2001-07-05 19:04:52 +02:00
2004-01-04 01:47:37 +01:00
function parse_geo ( & $event , $value )
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
if ( count ( $return_value ) == 2 )
{
$event [ 'lat' ] = $return_value [ 0 ];
$event [ 'lon' ] = $return_value [ 1 ];
}
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
function parse_xtype ( & $event , $majortype , $value )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$temp_x_type [ 'name' ] = strtoupper ( substr ( $majortype , 2 ));
$temp_x_type [ 'value' ] = $value ;
$event [ 'x_type' ][] = $temp_x_type ;
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
function parse_parameters ( & $event , $majortype , $value )
2001-07-02 05:31:13 +02:00
{
2005-03-31 15:19:16 +02:00
if ( ! ereg ( '[\=\;]' , $value ) || $majortype == 'url' )
2001-07-02 05:31:13 +02:00
{
2001-08-27 13:23:44 +02:00
$return_value [] = Array (
'param' => $majortype ,
2004-01-04 01:47:37 +01:00
'value' => $value
2001-08-27 13:23:44 +02:00
);
2004-01-04 01:47:37 +01:00
$value = '' ;
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( ereg ( '(.*(\:\\\\)?.*):(.*)' , $value , $temp ))
2001-08-27 13:23:44 +02:00
{
2002-04-06 17:13:51 +02:00
$this -> debug ( 'Value : ' . _debug_array ( $temp , False ));
2004-01-04 01:47:37 +01:00
$this -> debug ( 'Param ' . $majortype . ' Value : ' . $temp [ 3 ]);
if ( $temp [ 3 ])
{
$return_value [] = Array (
'param' => $majortype ,
'value' => $temp [ 3 ]
);
$value = str_replace ( ':MAILTO' , '' , $temp [ 1 ]);
}
while ( ereg ( '(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)' , $value , $temp ))
{
$this -> debug ( 'Value : ' . _debug_array ( $temp , False ));
$this -> debug ( 'Param ' . $temp [ 2 ] . ' Value : ' . $temp [ 3 ]);
$return_value [] = Array (
'param' => $temp [ 2 ],
'value' => $temp [ 3 ]
);
$value = chop ( $temp [ 5 ]);
$this -> debug ( 'Value would be = ' . $value );
}
2001-08-27 13:23:44 +02:00
}
else
{
2004-01-04 01:47:37 +01:00
while ( ereg ( '(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)' , $value , $temp ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> debug ( 'Value : ' . _debug_array ( $temp , False ));
$this -> debug ( 'Param ' . $temp [ 2 ] . ' Value : ' . $temp [ 3 ]);
$return_value [] = Array (
'param' => $temp [ 2 ],
'value' => $temp [ 3 ]
);
$value = chop ( $temp [ 5 ]);
$this -> debug ( 'Value would be = ' . $value );
2001-07-02 05:31:13 +02:00
}
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
for ( $i = 0 ; $i < count ( $return_value ); $i ++ )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$name = strtolower ( $return_value [ $i ][ 'param' ]);
$value = $this -> strip_quotes ( $return_value [ $i ][ 'value' ]);
if ( substr ( $name , 0 , 2 ) == 'x-' )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$param = 'x_type' ;
$name = str_replace ( '-' , '_' , $return_value [ $i ][ 'param' ]);
}
else
{
$param = str_replace ( '-' , '_' , strtolower ( $name ));
if ( ! isset ( $this -> parameter [ $param ]) || $majortype == 'tzid' )
{
if ( $majortype == 'attendee' || $majortype == 'organizer' )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$param = 'mailto' ;
$name = $param ;
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$param = 'value' ;
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
}
2001-08-27 13:23:44 +02:00
}
2005-03-31 15:19:16 +02:00
// hack to write freebusy as value (freebusy:<value>) and not as param (freebusy:freebusy=<value>)
if ( $name == 'freebusy' ) $name = 'value' ;
2004-01-04 01:47:37 +01:00
$this -> debug ( 'name : ' . $name . ' : Param = ' . $param );
if ( @ $this -> parameter [ $param ][ 'properties' ][ $majortype ])
{
2005-03-31 15:19:16 +02:00
2004-01-04 01:47:37 +01:00
switch ( @ $this -> parameter [ $param ][ 'type' ])
{
case 'dir' :
$this -> set_var ( $event , $name , $this -> from_dir ( $value ));
break ;
case 'text' :
$this -> set_var ( $event , $name , $value );
break ;
case 'x_type' :
$this -> parse_xtype ( $event , $name , $value );
break ;
case 'function' :
$function = $this -> parameter [ $param ][ 'function' ];
$this -> set_var ( $event , $name , $this -> $function ( $value ));
break ;
case 'uri' :
if ( @ $this -> parameter [ $param ][ 'to_text' ])
{
$value = $this -> to_text ( $value );
}
$this -> set_var ( $event , $name , $value );
break ;
case 'integer' :
$this -> set_var ( $event , $name ,( int ) $value );
break ;
case 'value' :
if ( @ $this -> property [ $majortype ][ 'type' ] == 'date-time' )
{
$this -> set_var ( $event , $param , $this -> switch_date ( $name ));
}
2005-03-31 15:19:16 +02:00
elseif ( $majortype == 'url' )
{
$this -> set_var ( $event , $param , $value );
}
2004-01-04 01:47:37 +01:00
elseif ( $value <> " \\ n " && $value )
{
$this -> set_var ( $event [ $majortype ], $param , $value );
}
$this -> debug ( 'Event : ' . _debug_array ( $event , False ));
break ;
}
}
}
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
function parse_value ( & $event , $majortype , $value , $mode )
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
$var = Array ();
$this -> debug ( 'Mode : ' . $mode . ' Majortype : ' . $majortype );
$this -> parse_parameters ( $var , $majortype , $value );
if ( $this -> property [ $majortype ][ $mode ][ 'multiples' ])
{
$this -> debug ( _debug_array ( $var , False ));
$event [ $majortype ][] = $var ;
}
else
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> debug ( 'Majortype : ' . $majortype );
$this -> debug ( 'Property : ' . $this -> property [ $majortype ][ 'type' ]);
if ( $this -> property [ $majortype ][ 'type' ] == 'date-time' )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> debug ( 'Got a DATE-TIME type!' );
$t_var = $var [ $majortype ];
unset ( $var [ $majortype ]);
2004-10-15 19:30:49 +02:00
@ reset ( $t_var );
while ( list ( $key , $val ) = @ each ( $t_var ))
2004-01-04 01:47:37 +01:00
{
$var [ $key ] = $val ;
}
$this -> debug ( $majortype . ' : ' . _debug_array ( $var , False ));
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
$this -> set_var ( $event , $majortype , $var );
2001-08-27 13:23:44 +02:00
}
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
/*
* Build - Card Functions
*/
2001-08-04 03:34:49 +02:00
2004-01-04 01:47:37 +01:00
function build_xtype ( $x_type , $seperator = '=' )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$quote = '' ;
if ( $seperator == '=' )
{
$quote = '"' ;
}
2001-08-27 13:23:44 +02:00
2004-01-04 01:47:37 +01:00
$return_value = $this -> fold ( 'X-' . $x_type [ 'name' ] . $seperator . $quote . $x_type [ 'value' ] . $quote );
if ( $seperator == '=' )
{
return str_replace ( " \r \n " , '' , $return_value );
}
else
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
return $return_value ;
2001-08-27 13:23:44 +02:00
}
2001-12-02 23:19:48 +01:00
}
2004-01-04 01:47:37 +01:00
function build_parameters ( $event , $property )
2001-12-02 23:19:48 +01:00
{
2004-01-04 01:47:37 +01:00
$str = '' ;
$include_mailto = False ;
$include_datetime = False ;
$param = $this -> find_parameters ( $property );
if ( $property == 'exdate' )
{
while ( list ( $key , $value ) = each ( $event ))
{
$exdates [] = $this -> switch_date ( $value );
}
return ':' . implode ( $exdates , ',' );
}
else
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
while ( list ( $dumb_key , $key ) = each ( $param ))
2001-12-02 23:19:48 +01:00
{
2004-01-04 01:47:37 +01:00
if ( $key == 'value' )
{
continue ;
}
if ( $key == 'mailto' )
{
$include_mailto = True ;
continue ;
}
$param_array = @ $this -> parameter [ $key ];
$type = @ $this -> parameter [ $key ][ 'type' ];
if ( $type == 'date-time' )
{
$include_datetime = True ;
continue ;
}
$quote = ( @ $this -> parameter [ $key ][ 'quoted' ] ? '"' : '' );
if ( isset ( $event [ $key ]) && @ $this -> parameter [ $key ][ 'properties' ][ $property ])
{
$change_text = @ $this -> parameter [ $key ][ 'to_text' ];
$value = $event [ $key ];
if ( $change_text && $type == 'text' )
{
$value = $this -> to_text ( $value );
}
switch ( $type )
{
case 'dir' :
$str .= ';' . str_replace ( '_' , '-' , strtoupper ( $key )) . '=' . $quote . $this -> to_dir ( $value ) . $quote ;
break ;
case 'function' :
$str .= ';' . str_replace ( '_' , '-' , strtoupper ( $key )) . '=' ;
$function = $this -> parameter [ $key ][ 'function' ];
$this -> debug ( $key . ' Function Param : ' . $value );
$str .= $quote . $this -> $function ( $value ) . $quote ;
break ;
case 'text' :
case 'string' :
$str .= ';' . strtoupper ( $key ) . '=' . $quote . $value . $quote ;
break ;
case 'date-time' :
$str .= ( $key == 'until' ? ':' : ';UNTIL=' ) . date ( 'Ymd\THis' , mktime ( $event [ 'hour' ], $event [ 'min' ], $event [ 'sec' ], $event [ 'month' ], $event [ 'mday' ], $event [ 'year' ])) . ( !@ isset ( $event [ 'tzid' ]) ? 'Z' : '' );
break ;
}
unset ( $value );
}
}
if ( ! empty ( $event [ 'x_type' ]))
{
$c_x_type = count ( $event [ 'x_type' ]);
for ( $j = 0 ; $j < $c_x_type ; $j ++ )
{
$str .= ';' . $this -> build_xtype ( $event [ 'x_type' ][ $j ], '=' );
}
}
if ( ! empty ( $event [ 'value' ]))
{
if ( $property == 'trigger' )
{
$seperator = ';' ;
}
else
{
$seperator = ':' ;
}
$str .= $seperator . ( $this -> parameter [ 'value' ][ 'to_text' ] ? $this -> to_text ( $event [ 'value' ]) : $event [ 'value' ]);
2001-12-02 23:19:48 +01:00
}
2004-01-04 01:47:37 +01:00
if ( $include_mailto == True )
2001-12-02 23:19:48 +01:00
{
2004-01-04 01:47:37 +01:00
$key = 'mailto' ;
$function = $this -> parameter [ $key ][ 'function' ];
$ret_value = $this -> $function ( $event [ $key ]);
$str .= ( $ret_value ? ':' . $ret_value : '' );
2001-12-02 23:19:48 +01:00
}
2004-01-04 01:47:37 +01:00
if ( $include_datetime == True || @ $this -> property [ $property ][ 'type' ] == 'date-time' )
2001-12-02 23:19:48 +01:00
{
2004-01-04 01:47:37 +01:00
$str .= ':' . date ( 'Ymd\THis' , mktime ( $event [ 'hour' ], $event [ 'min' ], $event [ 'sec' ], $event [ 'month' ], $event [ 'mday' ], $event [ 'year' ])) . ( !@ isset ( $event [ 'tzid' ]) ? 'Z' : '' );
2001-12-02 23:19:48 +01:00
}
2004-01-04 01:47:37 +01:00
return ( $property == 'rrule' ? ':' . substr ( $str , 1 ) : $str );
}
}
function build_text ( $event , $property )
{
$str = '' ;
$param = $this -> find_parameters ( $property );
while ( list ( $dumb_key , $key ) = each ( $param ))
{
if ( ! empty ( $event [ $key ]) && $key != 'value' )
2001-12-02 23:19:48 +01:00
{
2004-01-04 01:47:37 +01:00
$type = @ $this -> parameter [ $key ][ 'type' ];
$quote = @ $this -> parameter [ $key ][ 'quote' ];
if ( @ $this -> parameter [ $key ][ 'to_text' ] == True )
{
$value = $this -> to_text ( $event [ $key ]);
}
else
2001-12-02 23:19:48 +01:00
{
2004-01-04 01:47:37 +01:00
$value = $event [ $key ];
2001-12-02 23:19:48 +01:00
}
switch ( $type )
{
case 'text' :
2004-01-04 01:47:37 +01:00
$str .= ';' . strtoupper ( $key ) . '=' . $quote . $value . $quote ;
break ;
2001-12-02 23:19:48 +01:00
}
}
2001-07-09 13:35:13 +02:00
}
2001-12-02 23:19:48 +01:00
if ( ! empty ( $event [ 'x_type' ]))
2001-07-09 13:35:13 +02:00
{
2001-12-02 23:19:48 +01:00
$c_x_type = count ( $event [ 'x_type' ]);
for ( $j = 0 ; $j < $c_x_type ; $j ++ )
{
$str .= ';' . $this -> build_xtype ( $event [ 'x_type' ][ $j ], '=' );
}
2001-07-09 13:35:13 +02:00
}
2001-12-02 23:19:48 +01:00
if ( ! empty ( $event [ 'value' ]))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
$str .= ':' . ( $this -> parameter [ 'value' ][ 'to_text' ] ? $this -> to_text ( $event [ 'value' ]) : $event [ 'value' ]);
2001-12-02 23:19:48 +01:00
}
2004-01-04 01:47:37 +01:00
return $str ;
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
function build_card_internals ( $ical_item , $event )
2001-07-05 19:04:52 +02:00
{
2005-03-31 15:19:16 +02:00
foreach ( $this -> find_properties ( $ical_item ) as $value )
2001-07-09 13:35:13 +02:00
{
2005-03-31 15:19:16 +02:00
$varray = $this -> property [ $value ];
2004-01-04 01:47:37 +01:00
$type = $varray [ 'type' ];
$to_text = $varray [ 'to_text' ];
$state = @ $varray [ $ical_item ][ 'state' ];
$multiples = @ $varray [ $ical_item ][ 'multiples' ];
2001-07-09 13:35:13 +02:00
switch ( $type )
{
2004-01-04 01:47:37 +01:00
case 'date-time' :
if ( ! empty ( $event [ $value ]))
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $multiples && $value != 'exdate' )
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
for ( $i = 0 ; $i < count ( $event [ $value ]); $i ++ )
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $this -> build_parameters ( $event [ $value ][ $i ], $value ));
}
}
else
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $this -> build_parameters ( $event [ $value ], $value ));
2001-07-05 19:04:52 +02:00
}
}
2004-01-04 01:47:37 +01:00
elseif ( $value == 'dtstamp' || $value == 'created' )
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . ':' . gmdate ( 'Ymd\THis\Z' ));
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
break ;
case 'uri' :
if ( ! empty ( $event [ $value ]))
2001-07-05 19:04:52 +02:00
{
2001-08-27 13:23:44 +02:00
for ( $i = 0 ; $i < count ( $event [ $value ]); $i ++ )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $this -> build_parameters ( $event [ $value ][ $i ], $to_text ));
2001-07-09 13:35:13 +02:00
}
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
break ;
case 'recur' :
if ( ! empty ( $event [ $value ]))
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $multiples )
2001-08-27 13:23:44 +02:00
{
for ( $i = 0 ; $i < count ( $event [ $value ]); $i ++ )
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $this -> build_parameters ( $event [ $value ][ $i ], $value ));
}
}
else
2001-07-06 05:29:29 +02:00
{
2001-08-27 13:23:44 +02:00
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $this -> build_parameters ( $event [ $value ], $value ));
2001-07-06 05:29:29 +02:00
}
}
2004-01-04 01:47:37 +01:00
break ;
case 'integer' :
if ( ! empty ( $event [ $value ]))
2001-07-06 05:29:29 +02:00
{
2004-01-04 01:47:37 +01:00
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . ':' . $event [ $value ]);
}
elseif ( $value == 'sequence' || $value == 'percent_complete' )
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . ':0' );
}
break ;
case 'function' :
$str .= ';' . str_replace ( '_' , '-' , strtoupper ( $value )) . '=' ;
$function = @ $this -> parameter [ $key ][ 'function' ];
$str .= ( @ $this -> parameter [ $key ][ 'quoted' ] ? '"' : '' ) . $this -> $function ( $event [ $key ]) . ( @ $this -> parameter [ $key ][ 'quoted' ] ? '"' : '' );
break ;
case 'float' :
if ( ! empty ( $event [ $value ]))
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . ':' . $event [ $value ][ 'lat' ] . ';' . $event [ $value ][ 'lon' ]);
}
break ;
case 'text' :
if ( isset ( $event [ $value ]))
{
if ( @ $this -> parameter [ $key ][ 'type' ] != 'function' )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $multiples && count ( $event [ $value ]) > 1 )
{
for ( $i = 0 ; $i < count ( $event [ $value ]); $i ++ )
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $this -> build_parameters ( $event [ $value ][ $i ], $value ));
}
}
else
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $this -> build_parameters ( $event [ $value ], $value ));
2001-08-27 13:23:44 +02:00
}
}
else
{
2004-01-04 01:47:37 +01:00
$function = $this -> parameter [ $value ][ 'function' ];
if ( $multiples )
{
for ( $i = 0 ; $i < count ( $event [ $value ]); $i ++ )
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . ':' . $this -> $function ( $event [ $value ][ $i ]));
}
}
else
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . ':' . $this -> $function ( $event [ $value ]));
}
2001-08-27 13:23:44 +02:00
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
break ;
case 'cal-address' :
if ( is_array ( $event [ $value ][ 0 ]))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
for ( $j = 0 ; $j < count ( $event [ $value ]); $j ++ )
2001-07-06 05:29:29 +02:00
{
2004-01-04 01:47:37 +01:00
$temp_output = $this -> build_parameters ( $event [ $value ][ $j ], $value );
if ( $temp_output )
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $temp_output );
}
2001-07-06 05:29:29 +02:00
}
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$temp_output = $this -> build_parameters ( $event [ $value ], $value );
if ( $temp_output )
{
$str .= $this -> fold ( strtoupper ( str_replace ( '_' , '-' , $value )) . $temp_output );
}
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
break ;
}
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
if ( ! empty ( $event [ 'x_type' ]))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
for ( $i = 0 ; $i < count ( $event [ 'x_type' ]); $i ++ )
{
$str .= $this -> build_xtype ( $event [ 'x_type' ][ $i ], ':' );
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
if ( $ical_item == 'vtimezone' )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $event [ 'tzdata' ])
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
for ( $k = 0 ; $k < count ( $event [ 'tzdata' ]); $k ++ )
{
$str .= 'BEGIN:' . strtoupper ( $event [ 'tzdata' ][ $k ][ 'type' ]) . " \r \n " ;
$str .= $this -> build_card_internals ( strtolower ( $event [ 'tzdata' ][ $k ][ 'type' ]), $event [ 'tzdata' ][ $k ]);
$str .= 'END:' . strtoupper ( $event [ 'tzdata' ][ $k ][ 'type' ]) . " \r \n " ;
}
2001-07-09 13:35:13 +02:00
}
}
2004-01-04 01:47:37 +01:00
elseif ( $event [ 'alarm' ])
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
for ( $k = 0 ; $k < count ( $event [ 'alarm' ]); $k ++ )
{
$str .= 'BEGIN:VALARM' . " \r \n " ;
$str .= $this -> build_card_internals ( 'valarm' , $event [ 'alarm' ][ $k ]);
$str .= 'END:VALARM' . " \r \n " ;
}
}
return $str ;
2001-08-27 13:23:44 +02:00
}
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
/*
* Switching Functions
*/
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
function switch_class ( $var )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case 'PRIVATE' :
2005-04-06 06:55:49 +02:00
return PRIVATECAL ;
2004-01-04 01:47:37 +01:00
break ;
case 'PUBLIC' :
2005-04-06 06:55:49 +02:00
return PUBLICCAL ;
2004-01-04 01:47:37 +01:00
break ;
case 'CONFIDENTIAL' :
return CONFIDENTIAL ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch (( int ) $var )
{
2005-04-06 06:55:49 +02:00
case PRIVATECAL :
2004-01-04 01:47:37 +01:00
return 'PRIVATE' ;
break ;
2005-04-06 06:55:49 +02:00
case PUBLICCAL :
2004-01-04 01:47:37 +01:00
return 'PUBLIC' ;
break ;
case CONFIDENTIAL :
return 'CONFIDENTIAL' ;
break ;
}
}
else
{
return $var ;
2001-07-09 13:35:13 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_cu ( $var )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
if ( gettype ( $var ) == 'string' )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case 'INDIVIDUAL' :
return INDIVIDUAL ;
break ;
case 'GROUP' :
return GROUP ;
break ;
case 'RESOURCE' :
return RESOURCE ;
break ;
case 'ROOM' :
return ROOM ;
break ;
case 'UNKNOWN' :
return UNKNOWN ;
break ;
default :
return OTHER ;
break ;
}
}
elseif ( gettype ( $var ) == 'integer' )
{
switch ( $var )
{
case INDIVIDUAL :
return 'INDIVIDUAL' ;
break ;
case GROUP :
return 'GROUP' ;
break ;
case RESOURCE :
return 'RESOURCE' ;
break ;
case ROOM :
return 'ROOM' ;
break ;
case UNKNOWN :
return 'UNKNOWN' ;
break ;
default :
return 'X-OTHER' ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-07-09 13:35:13 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_date ( $var )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> debug ( 'SWITCH_DATE: gettype = ' . gettype ( $var ));
if ( is_string ( $var ))
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
$dtime = Array ();
if ( strpos ( $var , ':' ))
{
$pos = explode ( ':' , $var );
$var = $pos [ 1 ];
}
$this -> set_var ( $dtime , 'year' ,( int )( substr ( $var , 0 , 4 )));
$this -> set_var ( $dtime , 'month' ,( int )( substr ( $var , 4 , 2 )));
$this -> set_var ( $dtime , 'mday' ,( int )( substr ( $var , 6 , 2 )));
if ( substr ( $var , 8 , 1 ) == 'T' )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> set_var ( $dtime , 'hour' ,( int )( substr ( $var , 9 , 2 )));
$this -> set_var ( $dtime , 'min' ,( int )( substr ( $var , 11 , 2 )));
$this -> set_var ( $dtime , 'sec' ,( int )( substr ( $var , 13 , 2 )));
if ( strlen ( $var ) > 14 )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
if ( substr ( $var , 14 , 1 ) != 'Z' )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $this -> api )
2001-08-27 13:23:44 +02:00
{
2004-01-04 01:47:37 +01:00
$dtime [ 'hour' ] -= $GLOBALS [ 'phpgw_info' ][ 'users' ][ 'common' ][ 'tz_offset' ];
if ( $dtime [ 'hour' ] < 0 )
{
$dtime [ 'mday' ] -= 1 ;
$dtime [ 'hour' ] = 24 - $dtime [ 'hour' ];
}
elseif ( $dtime [ 'hour' ] >= 24 )
{
$dtime [ 'mday' ] += 1 ;
$dtime [ 'hour' ] = $dtime [ 'hour' ] - 24 ;
}
2001-08-27 13:23:44 +02:00
}
}
2001-07-09 13:35:13 +02:00
}
}
else
{
2004-01-04 01:47:37 +01:00
$this -> set_var ( $dtime , 'hour' , 0 );
$this -> set_var ( $dtime , 'min' , 0 );
$this -> set_var ( $dtime , 'sec' , 0 );
if ( $this -> api )
2001-09-07 18:37:11 +02:00
{
2004-01-04 01:47:37 +01:00
$dtime [ 'hour' ] -= $GLOBALS [ 'phpgw_info' ][ 'users' ][ 'common' ][ 'tz_offset' ];
if ( $dtime [ 'hour' ] < 0 )
{
$dtime [ 'mday' ] -= 1 ;
$dtime [ 'hour' ] = 24 - $dtime [ 'hour' ];
}
elseif ( $dtime [ 'hour' ] >= 24 )
{
$dtime [ 'mday' ] += 1 ;
$dtime [ 'hour' ] = $dtime [ 'hour' ] - 24 ;
}
2001-09-07 18:37:11 +02:00
}
2001-08-27 13:23:44 +02:00
}
2004-01-04 01:47:37 +01:00
$this -> debug ( 'DATETIME : ' . _debug_array ( $dtime , False ));
return $dtime ;
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_array ( $var ))
2001-07-02 05:31:13 +02:00
{
2004-01-04 01:47:37 +01:00
return date ( 'Ymd\THis\Z' , mktime ( $var [ 'hour' ], $var [ 'min' ], $var [ 'sec' ], $var [ 'month' ], $var [ 'mday' ], $var [ 'year' ]));
2001-07-02 05:31:13 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-07-02 05:31:13 +02:00
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-07-02 05:31:13 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_encoding ( $var )
2001-06-07 05:18:35 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-06-07 05:18:35 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case '8BIT' :
return _8BIT ;
break ;
case 'BASE64' :
return _BASE64 ;
break ;
default :
return OTHER ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case _8BIT :
return '8BIT' ;
break ;
case _BASE64 :
return 'BASE64' ;
break ;
case OTHER :
return 'OTHER' ;
break ;
}
2001-06-10 19:05:51 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-06-10 19:05:51 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_fbtype ( $var )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case 'FREE' :
return FREE ;
break ;
case 'BUSY' :
return BUSY ;
break ;
case 'BUSY-UNAVAILABLE' :
return BUSY_UNAVAILABLE ;
break ;
case 'BUSY-TENTATIVE' :
return BUSY_TENTATIVE ;
break ;
default :
return OTHER ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case FREE :
return 'FREE' ;
break ;
case BUSY :
return 'BUSY' ;
break ;
case BUSY_UNAVAILABLE :
return 'BUSY-UNAVAILABLE' ;
break ;
case BUSY_TENTATIVE :
return 'BUSY-TENTATIVE' ;
break ;
default :
return 'OTHER' ;
break ;
}
2001-07-09 13:35:13 +02:00
}
else
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-07-09 13:35:13 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_freq ( $var )
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case 'SECONDLY' :
return SECONDLY ;
break ;
case 'MINUTELY' :
return MINUTELY ;
break ;
case 'HOURLY' :
return HOURLY ;
break ;
case 'DAILY' :
return DAILY ;
break ;
case 'WEEKLY' :
return WEEKLY ;
break ;
case 'MONTHLY' :
return MONTHLY ;
break ;
case 'YEARLY' :
return YEARLY ;
break ;
}
2001-06-10 19:05:51 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case SECONDLY :
return 'SECONDLY' ;
break ;
case MINUTELY :
return 'MINUTELY' ;
break ;
case HOURLY :
return 'HOURLY' ;
break ;
case DAILY :
return 'DAILY' ;
break ;
case WEEKLY :
return 'WEEKLY' ;
break ;
case MONTHLY :
return 'MONTHLY' ;
break ;
case YEARLY :
return 'YEARLY' ;
break ;
}
}
else
{
return $var ;
2001-06-10 19:05:51 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_mailto ( $var )
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
if ( strpos ( ' ' . $var , ':' ))
{
$parts = explode ( ':' , $var );
$var = $parts [ 1 ];
}
$parts = explode ( '@' , $var );
$this -> debug ( " Count of mailto parts : " . count ( $parts ));
if ( count ( $parts ) == 2 )
{
$this -> debug ( " Splitting " . $parts [ 0 ] . " @ " . $parts [ 1 ]);
$temp_address = Array ();
$temp_address [ 'user' ] = $parts [ 0 ];
$temp_address [ 'host' ] = $parts [ 1 ];
return $temp_address ;
}
else
{
return False ;
}
2001-06-07 05:18:35 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_array ( $var ))
2001-06-10 06:02:50 +02:00
{
2004-01-04 01:47:37 +01:00
return $var [ 'user' ] . '@' . $var [ 'host' ];
2001-06-10 19:05:51 +02:00
}
}
2001-07-09 13:35:13 +02:00
2004-01-04 01:47:37 +01:00
function switch_partstat ( $var )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> debug ( 'PARTSTAT = ' . $var );
if ( is_string ( $var ))
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case 'NEEDS-ACTION' :
2004-10-15 19:30:49 +02:00
return NEEDS_ACTION ;
2004-01-04 01:47:37 +01:00
break ;
case 'ACCEPTED' :
2004-10-15 19:30:49 +02:00
return ACCEPTED ;
2004-01-04 01:47:37 +01:00
break ;
case 'DECLINED' :
2004-10-15 19:30:49 +02:00
return DECLINED ;
2004-01-04 01:47:37 +01:00
break ;
case 'TENTATIVE' :
2004-10-15 19:30:49 +02:00
return TENTATIVE ;
2004-01-04 01:47:37 +01:00
break ;
case 'DELEGATED' :
2004-10-15 19:30:49 +02:00
return DELEGATED ;
2004-01-04 01:47:37 +01:00
break ;
case 'COMPLETED' :
2004-10-15 19:30:49 +02:00
return COMPLETED ;
2004-01-04 01:47:37 +01:00
break ;
case 'IN-PROCESS' :
2004-10-15 19:30:49 +02:00
return IN_PROCESS ;
2004-01-04 01:47:37 +01:00
break ;
default :
2004-10-15 19:30:49 +02:00
return OTHER ;
2004-01-04 01:47:37 +01:00
break ;
}
2001-06-10 19:05:51 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-06-10 19:05:51 +02:00
{
2004-01-04 01:47:37 +01:00
switch (( int ) $var )
{
2004-10-15 19:30:49 +02:00
case NEEDS_ACTION :
2004-01-04 01:47:37 +01:00
return 'NEEDS-ACTION' ;
break ;
2004-10-15 19:30:49 +02:00
case ACCEPTED :
2004-01-04 01:47:37 +01:00
return 'ACCEPTED' ;
break ;
2004-10-15 19:30:49 +02:00
case DECLINED :
2004-01-04 01:47:37 +01:00
return 'DECLINED' ;
break ;
2004-10-15 19:30:49 +02:00
case TENTATIVE :
2004-01-04 01:47:37 +01:00
return 'TENTATIVE' ;
break ;
2004-10-15 19:30:49 +02:00
case DELEGATED :
2004-01-04 01:47:37 +01:00
return 'DELEGATED' ;
break ;
2004-10-15 19:30:49 +02:00
case COMPLETED :
2004-01-04 01:47:37 +01:00
return 'COMPLETED' ;
break ;
2004-10-15 19:30:49 +02:00
case IN_PROCESS :
2004-01-04 01:47:37 +01:00
return 'IN-PROCESS' ;
break ;
default :
return 'X-OTHER' ;
break ;
}
2001-06-10 19:05:51 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-06-25 00:13:17 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_range ( $var )
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case 'THISANDPRIOR' :
return THISANDPRIOR ;
break ;
case 'THISANDFUTURE' :
return THISANDFUTURE ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case THISANDPRIOR :
return 'THISANDPRIOR' ;
break ;
case THISANDFUTURE :
return 'THISANDFUTURE' ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-07-09 13:35:13 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_related ( $var )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
{
switch ( $var )
{
case 'START' :
return START ;
break ;
case 'END' :
return END ;
break ;
}
}
elseif ( is_int ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case START :
return 'START' ;
break ;
case END :
return 'END' ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-07-09 13:35:13 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_reltype ( $var )
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case 'PARENT' :
return PARENT ;
break ;
case 'CHILD' :
return CHILD ;
break ;
case 'SIBLING' :
return SIBLING ;
break ;
}
2001-07-09 13:35:13 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-07-09 13:35:13 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
{
case PARENT :
return 'PARENT' ;
break ;
case CHILD :
return 'CHILD' ;
break ;
case SIBLING :
return 'SIBLING' ;
break ;
}
}
else
{
return $var ;
2001-06-25 00:13:17 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_role ( $var )
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
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 ;
}
2001-06-25 00:13:17 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
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 ;
2001-06-25 00:13:17 +02:00
}
}
2004-01-04 01:47:37 +01:00
function switch_rsvp ( $var )
2001-06-10 06:02:50 +02:00
{
2004-01-04 01:47:37 +01:00
if ( is_string ( $var ))
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $var == 'TRUE' )
2001-07-06 05:29:29 +02:00
{
2004-01-04 01:47:37 +01:00
return 1 ;
2001-07-06 05:29:29 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( $var == 'FALSE' )
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
return 0 ;
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
}
elseif ( is_int ( $var ) || $var == False )
{
if ( $var == 1 )
{
return 'TRUE' ;
}
elseif ( $var == 0 )
2001-07-05 19:04:52 +02:00
{
2004-01-04 01:47:37 +01:00
return 'FALSE' ;
2001-07-05 19:04:52 +02:00
}
}
else
{
2004-01-04 01:47:37 +01:00
return $var ;
}
}
function switch_transp ( $var )
{
if ( is_string ( $var ))
{
switch ( $var )
{
case 'TRANSPARENT' :
return TRANSPARENT ;
2001-08-04 03:34:49 +02:00
break ;
2004-01-04 01:47:37 +01:00
case 'OPAQUE' :
return OPAQUE ;
2001-08-04 03:34:49 +02:00
break ;
2001-07-06 05:29:29 +02:00
}
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
elseif ( is_int ( $var ))
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
switch ( $var )
2001-07-06 05:29:29 +02:00
{
2004-01-04 01:47:37 +01:00
case TRANSPARENT :
return 'TRANSPARENT' ;
2001-08-04 03:34:49 +02:00
break ;
2004-01-04 01:47:37 +01:00
case OPAQUE :
return 'OPAQUE' ;
2001-08-04 03:34:49 +02:00
break ;
2001-07-06 05:29:29 +02:00
}
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
return $var ;
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
}
/*
* The brunt of the class
*/
function parse ( $ical_text )
{
$begin_regexp = '^' ;
$semi_colon_regexp = '[\;\:]' ;
$colon_regexp = '[\:]' ;
$catch_all_regexp = '(.*)' ;
$end_regexp = '$' ;
$property_regexp = $begin_regexp . '([A-Z\-]*)' . $semi_colon_regexp . $catch_all_regexp . $end_regexp ;
$param_regexp = $begin_regexp . $catch_all_regexp . ':' . $catch_all_regexp . $end_regexp ;
$mode = 'none' ;
$text = $this -> read_line_unfold ( $ical_text );
while ( $text )
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
ereg ( $property_regexp , $text , $temp );
$majortype = str_replace ( '-' , '_' , strtolower ( $temp [ 1 ]));
$value = chop ( $temp [ 2 ]);
if ( $mode != 'none' && ( $majortype != 'begin' && $majortype != 'end' ))
2001-07-06 05:29:29 +02:00
{
2004-01-04 01:47:37 +01:00
$this -> debug ( 'PARSE:MAJORTYPE : ' . $majortype );
if ( isset ( $this -> property [ $majortype ]))
{
$state = @ $this -> property [ $majortype ][ " $mode " ][ 'state' ];
$type = @ $this -> property [ $majortype ][ 'type' ];
$multiples = @ $this -> property [ $majortype ][ " $mode " ][ 'multiples' ];
$do_to_text = @ $this -> property [ $majortype ][ 'to_text' ];
}
elseif ( substr ( $majortype , 0 , 2 ) == 'x_' )
{
$state = 'optional' ;
$type = 'xtype' ;
$multiples = True ;
$do_to_test = True ;
}
else
{
$state = '' ;
}
2001-07-06 05:29:29 +02:00
}
2004-01-04 01:47:37 +01:00
else
2001-07-06 05:29:29 +02:00
{
2004-01-04 01:47:37 +01:00
$state = 'required' ;
}
if ( $majortype == 'duration' )
{
unset ( $dur );
2005-03-31 15:19:16 +02:00
// Split <20> DURATION<4F>
2004-01-04 01:47:37 +01:00
list ( $_f_ [ 'day_raw' ], $_f_ [ 'time_raw' ]) = split ( 'T' , substr ( $value , 1 , strlen ( $value ) - 1 ));
/* Datecode */
2004-10-15 19:40:22 +02:00
if ( isset ( $_f_ [ 'day_raw' ]) || $_f_ [ 'day_raw' ])
2004-01-04 01:47:37 +01:00
{
2004-10-15 19:28:34 +02:00
/* Days */
2004-01-04 01:47:37 +01:00
if ( strstr ( $_f_ [ 'day_raw' ], 'D' ))
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
$dur [ 'days' ] = eregi_replace ( " ([0-9]+)D(.*) " , " \\ 1 " , $_f_ [ 'day_raw' ]);
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
2004-10-15 19:28:34 +02:00
/* Weeks */
2004-01-04 01:47:37 +01:00
if ( strstr ( $_f_ [ 'day_raw' ], 'W' ))
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
$dur [ 'weeks' ] = eregi_replace ( " ([^|.*]+D)?([0-9]+)W " , " \\ 2 " , $_f_ [ 'day_raw' ]);
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
}
/* Timecode */
2004-10-15 19:40:22 +02:00
if ( isset ( $_f_ [ 'time_raw' ]) || $_f_ [ 'time_raw' ])
2004-01-04 01:47:37 +01:00
{
2004-10-15 19:28:34 +02:00
/* Hours */
2004-01-04 01:47:37 +01:00
if ( strstr ( $_f_ [ 'time_raw' ], 'H' ))
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
$dur [ 'hours' ] = eregi_replace ( " ([0-9]+)H(.*) " , " \\ 1 " , $_f_ [ 'time_raw' ]);
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
2004-10-15 19:28:34 +02:00
/* Minutes */
2004-01-04 01:47:37 +01:00
if ( strstr ( $_f_ [ 'time_raw' ], 'M' ))
2001-08-04 03:34:49 +02:00
{
2004-01-04 01:47:37 +01:00
$dur [ 'minutes' ] = eregi_replace ( " ([^|.*]+H)?([0-9]+)M(.*) " , " \\ 2 " , $_f_ [ 'time_raw' ]);
2001-08-04 03:34:49 +02:00
}
2004-01-04 01:47:37 +01:00
2004-10-15 19:28:34 +02:00
/* Seconds */
2004-01-04 01:47:37 +01:00
if ( strstr ( $_f_ [ 'time_raw' ], 'S' ))
{
$dur [ 'seconds' ] = eregi_replace ( " ([^|.*]+M)?([0-9]+)S(.*) " , " \\ 2 " , $_f_ [ 'time_raw' ]);
}
}
$dur [ 'raw' ] = Array (
'timecode' => $_f_ [ 'time_raw' ],
'datecode' => $_f_ [ 'day_raw' ],
'all' => $value
);
2004-10-15 19:28:34 +02:00
/* Add new parameters in Event */
2004-01-04 01:47:37 +01:00
$this -> set_var ( $event , $majortype , $dur );
}
if ( $majortype == 'begin' )
{
$tmode = $mode ;
$mode = strtolower ( $value );
switch ( strtolower ( $value ))
{
case 'daylight' :
case 'standard' :
$t_event = Array ();
$t_event = $event ;
$event = Array ();
break ;
case 'valarm' :
if ( $tmode == 'vevent' || $tmode == 'vtodo' )
{
$t_event = $event ;
unset ( $event );
$event = Array ();
}
else
{
$mode = $tmode ;
}
break ;
case 'vcalendar' :
$ical = $this -> new_ical ();
break ;
case 'vevent' :
case 'vfreebusy' :
case 'vjournal' :
case 'vtimezone' :
case 'vtodo' :
$event = Array ();
break ;
}
$event [ 'type' ] = strtolower ( $value );
}
elseif ( $majortype == 'end' )
{
$mode = 'none' ;
switch ( strtolower ( $value ))
{
case 'daylight' :
case 'standard' :
$tzdata [] = $event ;
unset ( $event );
$event = $t_event ;
unset ( $t_event );
$mode = 'vtimezone' ;
break ;
case 'valarm' :
$alarm [] = $event ;
unset ( $event );
$event = $t_event ;
unset ( $t_event );
$mode = $tmode ;
break ;
case 'vevent' :
if ( ! empty ( $alarm ))
{
$event [ 'alarm' ] = $alarm ;
unset ( $alarm );
}
$this -> event [] = $event ;
unset ( $event );
break ;
case 'vfreebusy' :
$this -> freebusy [] = $event ;
unset ( $event );
break ;
case 'vjournal' :
$this -> journal [] = $event ;
unset ( $event );
break ;
case 'vtimezone' :
if ( ! empty ( $tzdata ))
{
$event [ 'tzdata' ] = $tzdata ;
unset ( $tzdata );
}
$this -> timezone [] = $event ;
unset ( $event );
break ;
case 'vtodo' :
if ( ! empty ( $alarm ))
{
$event [ 'alarm' ] = $alarm ;
unset ( $alarm );
}
$this -> todo [] = $event [ 'alarm' ];
unset ( $event );
break ;
case 'vcalendar' :
$this -> ical = $ical ;
$this -> ical [ 'event' ] = $this -> event ;
$this -> ical [ 'freebusy' ] = $this -> freebusy ;
$this -> ical [ 'journal' ] = $this -> journal ;
$this -> ical [ 'timezone' ] = $this -> timezone ;
$this -> ical [ 'todo' ] = $this -> todo ;
break 2 ;
}
}
elseif ( $majortype == 'prodid' || $majortype == 'version' || $majortype == 'method' || $majortype == 'calscale' )
{
$this -> parse_parameters ( $ical , $majortype , $this -> from_text ( $value ));
}
elseif ( $state == 'optional' || $state == 'required' )
{
$this -> debug ( 'Mode : ' . $mode . ' Majortype : ' . $majortype );
if ( $do_to_text )
{
$value = $this -> from_text ( $value );
}
switch ( $type )
{
case 'text' :
$this -> parse_parameters ( $event , $majortype , $value );
break ;
case 'recur' :
case 'date-time' :
case 'cal-address' :
$this -> parse_value ( $event , $majortype , $value , $mode );
break ;
case 'integer' :
if ( $multiples )
{
$event [ $majortype ][] = ( int ) $value ;
}
else
{
$this -> set_var ( $event , $majortype ,( int ) $value );
}
break ;
case 'float' :
$event -> $majortype = new class_geo ;
$this -> parse_geo ( $event -> $majortype , $value );
break ;
case 'utc-offset' :
$this -> set_var ( $event , $majortype ,( int ) $value );
break ;
case 'uri' :
$new_var = Array ();
$this -> parse_parameters ( $new_var , $majortype , $value );
if ( $multiples )
{
switch ( $mode )
{
case 'valarm' :
$alarm [ 'attach' ][] = $new_var ;
break ;
default :
$event [ $majortype ][] = $new_var ;
break ;
}
}
else
{
$event [ $majortype ] = $new_var ;
}
unset ( $new_var );
break ;
case 'xtype' :
$this -> parse_xtype ( $event , $majortype , $value );
break ;
}
2001-07-05 19:04:52 +02:00
}
2004-01-04 01:47:37 +01:00
$text = $this -> read_line_unfold ( $ical_text );
2001-07-02 05:31:13 +02:00
}
2004-01-04 01:47:37 +01:00
return $this -> ical ;
2001-06-25 00:13:17 +02:00
}
2001-07-06 05:29:29 +02:00
2004-01-04 01:47:37 +01:00
function build_ical ( $ical )
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
$var = Array (
'timezone' ,
'event' ,
'todo' ,
'journal' ,
'freebusy'
);
$str = 'BEGIN:VCALENDAR' . " \r \n " ;
$str .= $this -> fold ( 'PRODID' . $this -> build_text ( $ical [ 'prodid' ], 'prodid' ));
$str .= $this -> fold ( 'VERSION' . $this -> build_text ( $ical [ 'version' ], 'version' ));
$str .= $this -> fold ( 'METHOD' . $this -> build_text ( $ical [ 'method' ], 'method' ));
2004-03-14 02:10:37 +01:00
foreach ( $var as $vtype )
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
if ( $ical [ $vtype ])
2001-06-25 00:13:17 +02:00
{
2004-01-04 01:47:37 +01:00
for ( $i = 0 ; $i < count ( $ical [ $vtype ]); $i ++ )
{
$str .= 'BEGIN:V' . strtoupper ( $vtype ) . " \r \n " ;
$str .= $this -> build_card_internals ( 'v' . $vtype , $ical [ $vtype ][ $i ]);
$str .= 'END:V' . strtoupper ( $vtype ) . " \r \n " ;
}
2001-06-25 00:13:17 +02:00
}
}
2004-01-04 01:47:37 +01:00
$str .= 'END:VCALENDAR' . " \r \n " ;
2001-06-25 00:13:17 +02:00
2004-01-04 01:47:37 +01:00
return $str ;
}
2001-08-04 03:34:49 +02:00
2001-09-17 04:33:19 +02:00
function switch_to_phpgw_status ( $partstat )
{
switch ( $partstat )
{
case 0 :
return 'U' ;
break ;
case 1 :
return 'A' ;
break ;
case 2 :
return 'R' ;
break ;
case 3 :
return 'T' ;
break ;
default :
return 'U' ;
break ;
}
}
function switch_phpgw_status ( $status )
{
switch ( $status )
{
case 'U' :
return 0 ;
break ;
case 'A' :
return 1 ;
break ;
case 'R' :
return 2 ;
break ;
case 'T' :
return 3 ;
break ;
}
}
2001-11-07 01:30:33 +01:00
function is_owner ( $part_record )
{
2004-08-25 17:33:59 +02:00
if (( $part_record [ 'mailto' ][ 'user' ] . '@' . $part_record [ 'mailto' ][ 'host' ] == $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'email' ][ 'address' ]) ||
2001-11-07 01:30:33 +01:00
( $part_record [ 'cn' ] == $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_lid' ]))
{
return True ;
}
else
{
return False ;
}
}
2001-09-17 04:33:19 +02:00
function check_owner ( & $event , $ical , $so_event )
{
if ( ! isset ( $event [ 'participant' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]]))
{
2001-11-07 01:30:33 +01:00
if ( isset ( $ical [ 'organizer' ]))
2001-09-17 04:33:19 +02:00
{
2001-11-07 01:30:33 +01:00
if ( $this -> is_owner ( $ical [ 'organizer' ]))
{
$so_event -> add_attribute ( 'owner' , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]);
$so_event -> add_attribute ( 'participants' , $this -> switch_to_phpgw_status ( $ical [ 'organizer' ][ 'partstat' ]), $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]);
}
2001-09-17 04:33:19 +02:00
}
2001-11-06 05:04:18 +01:00
elseif ( isset ( $ical [ 'attendee' ]))
2001-09-17 04:33:19 +02:00
{
$attendee_count = count ( $ical [ 'attendee' ]);
for ( $j = 0 ; $j < $attendee_count ; $j ++ )
{
2001-11-07 01:30:33 +01:00
if ( $this -> is_owner ( $ical [ 'attendee' ][ $j ]))
2001-09-17 04:33:19 +02:00
{
2004-01-04 01:47:37 +01:00
$so_event -> add_attribute ( 'participants' , $this -> switch_to_phpgw_status ( $ical [ 'attendee' ][ $j ][ 'partstat' ]),( int ) $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]);
2001-09-17 04:33:19 +02:00
}
}
}
2001-11-06 05:04:18 +01:00
else
{
$so_event -> add_attribute ( 'owner' , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]);
2001-11-07 01:30:33 +01:00
$so_event -> add_attribute ( 'participants' , 'A' , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]);
2001-11-06 05:04:18 +01:00
}
2001-09-17 04:33:19 +02:00
}
}
function import_file ()
{
2003-10-11 21:17:50 +02:00
if ( $_FILES [ 'uploadedfile' ][ 'tmp_name' ] == 'none' || $_FILES [ 'uploadedfile' ][ 'tmp_name' ] == '' )
2001-09-07 18:37:11 +02:00
{
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> link ( '/index.php' ,
Array (
'menuaction' => 'calendar.uiicalendar.import' ,
'action' => 'GetFile'
)
)
);
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpwg' ] -> common -> phpgw_exit ();
2001-09-07 18:37:11 +02:00
}
$uploaddir = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'temp_dir' ] . SEP ;
srand (( double ) microtime () * 1000000 );
$random_number = rand ( 100000000 , 999999999 );
2003-10-11 21:17:50 +02:00
$newfilename = md5 ( $_FILES [ 'uploadedfile' ][ 'tmp_name' ] . " , " . $uploadedfile_name . " , "
2001-09-07 18:37:11 +02:00
. time () . getenv ( " REMOTE_ADDR " ) . $random_number );
2001-09-17 04:33:19 +02:00
$filename = $uploaddir . $newfilename ;
2003-10-11 21:17:50 +02:00
move_uploaded_file ( $_FILES [ 'uploadedfile' ][ 'tmp_name' ], $filename );
2001-09-17 04:33:19 +02:00
return $filename ;
}
2001-09-07 18:37:11 +02:00
2001-09-17 04:33:19 +02:00
function import ( $mime_msg = '' )
{
2003-10-11 21:17:50 +02:00
if ( $_FILES [ 'uploadedfile' ][ 'tmp_name' ] != 'none' && $_FILES [ 'uploadedfile' ][ 'tmp_name' ] != '' )
2001-09-17 04:33:19 +02:00
{
$filename = $this -> import_file ();
$fp = fopen ( $filename , 'rt' );
2004-08-19 20:43:02 +02:00
$mime_msg = fread ( $fp , filesize ( $filename ));
2001-09-17 04:33:19 +02:00
fclose ( $fp );
unlink ( $filename );
2004-10-15 19:28:34 +02:00
/* explode can fail easily, so pre-chew the ical file */
$mime_msg = preg_replace ( " /( \r \n | \r )/ " , " \n " , $mime_msg ); /* dos2unix */
$mime_msg = preg_replace ( " / \n \n +/ " , " \n " , $mime_msg ); /* strip duplicate newlines */
$mime_msg = explode ( " \n " , $mime_msg ); /* explode the sanitized message into itself */
2001-09-17 04:33:19 +02:00
}
elseif ( ! $mime_msg )
{
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> link ( '/index.php' ,
Array (
'menuaction' => 'calendar.uiicalendar.import' ,
'action' => 'GetFile'
)
)
);
2004-01-04 01:47:37 +01:00
$GLOBALS [ 'phpwg' ] -> common -> phpgw_exit ();
2001-09-17 04:33:19 +02:00
}
if ( ! is_object ( $GLOBALS [ 'uicalendar' ]))
{
$so_event = createobject ( 'calendar.socalendar' ,
Array (
'owner' => 0 ,
'filter' => '' ,
'category' => ''
)
);
}
else
{
$so_event = $GLOBALS [ 'uicalendar' ] -> bo -> so ;
}
2004-01-04 01:47:37 +01:00
2001-09-07 18:37:11 +02:00
$datetime_vars = Array (
2004-10-15 19:28:34 +02:00
'start' => 'dtstart' ,
'end' => 'dtend' ,
2001-09-07 18:37:11 +02:00
'modtime' => 'dtstamp' ,
'modtime' => 'last_modified'
);
2004-01-04 01:47:37 +01:00
2001-09-07 18:37:11 +02:00
$date_array = Array (
'Y' => 'year' ,
'm' => 'month' ,
'd' => 'mday' ,
'H' => 'hour' ,
'i' => 'min' ,
's' => 'sec'
);
2004-10-15 19:28:34 +02:00
/* time limit should be controlled elsewhere */
2001-11-06 04:15:15 +01:00
@ set_time_limit ( 0 );
2001-11-13 13:17:10 +01:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ] = $GLOBALS [ 'phpgw' ] -> preferences -> create_email_preferences ();
2001-09-17 04:33:19 +02:00
$users_email = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'email' ][ 'address' ];
$cats = CreateObject ( 'phpgwapi.categories' );
2001-09-07 18:37:11 +02:00
$ical = $this -> parse ( $mime_msg );
2001-10-02 03:14:40 +02:00
switch ( $ical [ 'version' ][ 'value' ])
{
case '1.0' :
$cat_sep = ';' ;
break ;
case '2.0' :
default :
$cat_sep = ',' ;
break ;
}
2001-09-07 18:37:11 +02:00
$c_events = count ( $ical [ 'event' ]);
for ( $i = 0 ; $i < $c_events ; $i ++ )
{
if ( $ical [ 'event' ][ $i ][ 'uid' ][ 'value' ])
{
$uid_exists = $so_event -> find_uid ( $ical [ 'event' ][ $i ][ 'uid' ][ 'value' ]);
}
2001-11-13 13:17:10 +01:00
else
{
$uid_exists = False ;
}
2001-09-07 18:37:11 +02:00
if ( $uid_exists )
{
2001-09-17 04:33:19 +02:00
$event = $so_event -> read_entry ( $uid_exists );
$this -> check_owner ( $event , $ical [ 'event' ][ $i ], $so_event );
$event = $so_event -> get_cached_event ();
$so_event -> add_entry ( $event );
2001-09-07 18:37:11 +02:00
}
else
{
$so_event -> event_init ();
$so_event -> add_attribute ( 'id' , 0 );
$so_event -> add_attribute ( 'reference' , 0 );
if ( $ical [ 'event' ][ $i ][ 'uid' ][ 'value' ])
{
$so_event -> add_attribute ( 'uid' , $ical [ 'event' ][ $i ][ 'uid' ][ 'value' ]);
}
if ( $ical [ 'event' ][ $i ][ 'summary' ][ 'value' ])
{
$so_event -> set_title ( $ical [ 'event' ][ $i ][ 'summary' ][ 'value' ]);
}
if ( $ical [ 'event' ][ $i ][ 'description' ][ 'value' ])
{
$so_event -> set_description ( $ical [ 'event' ][ $i ][ 'description' ][ 'value' ]);
}
if ( $ical [ 'event' ][ $i ][ 'location' ][ 'value' ])
{
$so_event -> add_attribute ( 'location' , $ical [ 'event' ][ $i ][ 'location' ][ 'value' ]);
}
if ( isset ( $ical [ 'event' ][ $i ][ 'priority' ]))
{
$so_event -> add_attribute ( 'priority' , $ical [ 'event' ][ $i ][ 'priority' ]);
}
else
{
$so_event -> add_attribute ( 'priority' , 2 );
}
if ( ! isset ( $ical [ 'event' ][ $i ][ 'class' ]))
{
$ical [ 'event' ][ $i ][ 'class' ] = 1 ;
}
$so_event -> set_class ( $ical [ 'event' ][ $i ][ 'class' ]);
@ reset ( $datetime_vars );
while ( list ( $e_datevar , $i_datevar ) = each ( $datetime_vars ))
{
if ( isset ( $ical [ 'event' ][ $i ][ $i_datevar ]))
{
2002-06-25 01:24:24 +02:00
$temp_time = $so_event -> maketime ( $ical [ 'event' ][ $i ][ $i_datevar ]) + $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-09-07 18:37:11 +02:00
@ reset ( $date_array );
while ( list ( $key , $var ) = each ( $date_array ))
{
2004-01-04 01:47:37 +01:00
$event [ $e_datevar ][ $var ] = ( int )( date ( $key , $temp_time ));
2001-09-07 18:37:11 +02:00
}
$so_event -> set_date ( $e_datevar , $event [ $e_datevar ][ 'year' ], $event [ $e_datevar ][ 'month' ], $event [ $e_datevar ][ 'mday' ], $event [ $e_datevar ][ 'hour' ], $event [ $e_datevar ][ 'min' ], $event [ $e_datevar ][ 'sec' ]);
}
}
2001-09-17 04:33:19 +02:00
if ( ! isset ( $ical [ 'event' ][ $i ][ 'categories' ][ 'value' ]) || ! $ical [ 'event' ][ $i ][ 'categories' ][ 'value' ])
2001-09-07 18:37:11 +02:00
{
2001-09-17 04:33:19 +02:00
$so_event -> set_category ( 0 );
2001-09-07 18:37:11 +02:00
}
else
{
2001-09-17 04:33:19 +02:00
$ical_cats = Array ();
2001-10-02 03:14:40 +02:00
if ( strpos ( $ical [ 'event' ][ $i ][ 'categories' ][ 'value' ], $cat_sep ))
2001-09-17 04:33:19 +02:00
{
2001-10-02 03:14:40 +02:00
$ical_cats = explode ( $cat_sep , $ical [ 'event' ][ $i ][ 'categories' ][ 'value' ]);
2001-09-17 04:33:19 +02:00
}
else
{
$ical_cats [] = $ical [ 'event' ][ $i ][ 'categories' ][ 'value' ];
}
@ reset ( $ical_cats );
2001-10-01 04:42:29 +02:00
$cat_id_nums = Array ();
2001-09-17 04:33:19 +02:00
while ( list ( $key , $cat ) = each ( $ical_cats ))
{
if ( ! $cats -> exists ( 'appandmains' , $cat ))
{
$cats -> add (
Array (
'name' => $cat ,
'descr' => $cat ,
'parent' => '' ,
'access' => 'private' ,
'data' => ''
)
);
}
$cat_id_nums [] = $cats -> name2id ( $cat );
}
@ reset ( $cat_id_nums );
if ( count ( $cat_id_nums ) > 1 )
{
$so_event -> set_category ( implode ( $cat_id_nums , ',' ));
}
else
{
$so_event -> set_category ( $cat_id_nums [ 0 ]);
}
2001-09-07 18:37:11 +02:00
}
2004-10-15 19:28:34 +02:00
/* rrule */
if ( isset ( $ical [ 'event' ][ $i ][ 'rrule' ]) || isset ( $ical [ 'event' ][ $i ][ 'duration' ]))
2001-09-07 18:37:11 +02:00
{
2004-10-15 19:28:34 +02:00
/* recur_enddate */
2001-11-13 13:17:10 +01:00
if ( isset ( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ]))
2001-11-13 03:03:58 +01:00
{
2004-01-04 01:47:37 +01:00
$recur_enddate [ 'year' ] = ( int )( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'year' ]);
$recur_enddate [ 'month' ] = ( int )( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'month' ]);
$recur_enddate [ 'mday' ] = ( int )( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'mday' ]);
2004-10-15 19:33:03 +02:00
$recur_enddate [ 'hour' ] = ( int )( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'hour' ]);
$recur_enddate [ 'min' ] = ( int )( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'min' ]);
$recur_enddate [ 'sec' ] = ( int )( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'sec' ]);
2004-01-04 01:47:37 +01:00
}
elseif ( isset ( $ical [ 'event' ][ $i ][ 'duration' ]) )
{
2004-10-15 19:28:34 +02:00
/* Create timecode for strtotime */
2004-01-04 01:47:37 +01:00
$ptimer = mktime ( $ical [ 'event' ][ $i ][ 'dtstart' ][ 'hour' ],
2004-10-15 19:28:34 +02:00
$ical [ 'event' ][ $i ][ 'dtstart' ][ 'min' ],
$ical [ 'event' ][ $i ][ 'dtstart' ][ 'sec' ],
$ical [ 'event' ][ $i ][ 'dtstart' ][ 'month' ],
$ical [ 'event' ][ $i ][ 'dtstart' ][ 'mday' ],
$ical [ 'event' ][ $i ][ 'dtstart' ][ 'year' ]);
/*
* Subtract 1 second so we don ' t overlap with the beginning of
* another event .
*/
/* handle events with duration in weeks */
if ( $ical [ 'event' ][ $i ][ 'duration' ][ 'weeks' ] &&
( $ical [ 'event' ][ $i ][ 'duration' ][ 'hours' ] == 0 ) &&
( $ical [ 'event' ][ $i ][ 'duration' ][ 'minutes' ] == 0 ))
{
$ical [ 'event' ][ $i ][ 'duration' ][ 'days' ] =
( $ical [ 'event' ][ $i ][ 'duration' ][ 'days' ] +
( $ical [ 'event' ][ $i ][ 'duration' ][ 'weeks' ] * 7 )) - 1 ;
2004-01-04 01:47:37 +01:00
unset ( $ical [ 'event' ][ $i ][ 'duration' ][ 'weeks' ]);
2004-10-15 19:28:34 +02:00
2004-01-04 01:47:37 +01:00
$ical [ 'event' ][ $i ][ 'duration' ][ 'hours' ] = " 23 " ;
$ical [ 'event' ][ $i ][ 'duration' ][ 'minutes' ] = " 59 " ;
$ical [ 'event' ][ $i ][ 'duration' ][ 'seconds' ] = " 59 " ;
}
2004-10-15 19:28:34 +02:00
/* handle events with duration in days */
if (( $ical [ 'event' ][ $i ][ 'duration' ][ 'days' ] && $ical [ 'event' ][ $i ][ 'duration' ][ 'hours' ] == 0 ) &&
( $ical [ 'event' ][ $i ][ 'duration' ][ 'minutes' ] == 0 ))
2004-01-04 01:47:37 +01:00
{
$ical [ 'event' ][ $i ][ 'duration' ][ 'days' ] -- ;
$ical [ 'event' ][ $i ][ 'duration' ][ 'hours' ] = " 23 " ;
$ical [ 'event' ][ $i ][ 'duration' ][ 'minutes' ] = " 59 " ;
$ical [ 'event' ][ $i ][ 'duration' ][ 'seconds' ] = " 59 " ;
}
2004-10-15 19:28:34 +02:00
/* Create string contains datetime for strtotime */
2004-01-04 01:47:37 +01:00
$pdate = " + " ;
2004-10-15 19:28:34 +02:00
if ( isset ( $ical [ 'event' ][ $i ][ 'duration' ][ 'weeks' ]))
$pdate .= $ical [ 'event' ][ $i ][ 'duration' ][ 'weeks' ] . " weeks " ;
if ( isset ( $ical [ 'event' ][ $i ][ 'duration' ][ 'days' ]))
$pdate .= $ical [ 'event' ][ $i ][ 'duration' ][ 'days' ] . " days " ;
if ( isset ( $ical [ 'event' ][ $i ][ 'duration' ][ 'hours' ]))
$pdate .= $ical [ 'event' ][ $i ][ 'duration' ][ 'hours' ] . " hours " ;
if ( isset ( $ical [ 'event' ][ $i ][ 'duration' ][ 'minutes' ]))
$pdate .= $ical [ 'event' ][ $i ][ 'duration' ][ 'minutes' ] . " minutes " ;
if ( isset ( $ical [ 'event' ][ $i ][ 'duration' ][ 'seconds' ]))
$pdate .= $ical [ 'event' ][ $i ][ 'duration' ][ 'seconds' ] . " seconds " ;
/* What is datetime in 2192? */
2004-01-04 01:47:37 +01:00
$enddate = strtotime ( $pdate , $ptimer );
2004-10-15 19:28:34 +02:00
list (
$recur_enddate [ 'year' ],
$recur_enddate [ 'month' ],
$recur_enddate [ 'mday' ],
$recur_enddate [ 'hour' ],
$recur_enddate [ 'min' ],
$recur_enddate [ 'sec' ]
) = split ( " : " , date ( " Y:m:d:H:i:s " , $enddate ));
/* Set End of event */
$so_event -> set_end (
$recur_enddate [ 'year' ],
$recur_enddate [ 'month' ],
$recur_enddate [ 'mday' ],
$recur_enddate [ 'hour' ],
$recur_enddate [ 'min' ],
$recur_enddate [ 'sec' ]
);
2001-11-13 03:03:58 +01:00
}
else
{
$recur_enddate [ 'year' ] = 0 ;
$recur_enddate [ 'month' ] = 0 ;
$recur_enddate [ 'mday' ] = 0 ;
}
2004-10-15 19:28:34 +02:00
/* recur_data */
2001-11-07 03:58:08 +01:00
$recur_data = 0 ;
2001-11-13 13:17:10 +01:00
if ( isset ( $ical [ 'event' ][ $i ][ 'rrule' ][ 'byday' ]))
2001-11-07 03:58:08 +01:00
{
$week_days = Array (
2004-10-15 19:28:34 +02:00
MCAL_M_SUNDAY => 'SU' ,
MCAL_M_MONDAY => 'MO' ,
MCAL_M_TUESDAY => 'TU' ,
2001-11-07 03:58:08 +01:00
MCAL_M_WEDNESDAY => 'WE' ,
2004-10-15 19:28:34 +02:00
MCAL_M_THURSDAY => 'TH' ,
MCAL_M_FRIDAY => 'FR' ,
MCAL_M_SATURDAY => 'SA'
2001-11-07 03:58:08 +01:00
);
@ reset ( $week_days );
while ( list ( $key , $val ) = each ( $week_days ))
{
if ( strpos ( ' ' . $ical [ 'event' ][ $i ][ 'rrule' ][ 'byday' ], $val ))
{
$recur_data += $key ;
}
}
}
2004-10-15 19:28:34 +02:00
/* interval */
2001-11-07 04:04:56 +01:00
if ( ! isset ( $ical [ 'event' ][ $i ][ 'rrule' ][ 'interval' ]))
{
2001-11-13 03:03:58 +01:00
$interval = 1 ;
2001-11-07 04:04:56 +01:00
}
2001-11-13 03:03:58 +01:00
else
{
2004-01-04 01:47:37 +01:00
$interval = ( int ) $ical [ 'event' ][ $i ][ 'rrule' ][ 'interval' ];
2001-11-13 03:03:58 +01:00
}
2004-10-15 19:40:22 +02:00
/* recur_type */
2001-11-07 03:58:08 +01:00
switch ( $ical [ 'event' ][ $i ][ 'rrule' ][ 'freq' ])
{
2004-10-15 19:40:22 +02:00
case SECONDLY :
$so_event -> set_recur_secondly ( $recur_enddate [ 'year' ], $recur_enddate [ 'month' ], $recur_enddate [ 'mday' ], $interval );
break ;
case MINUTELY :
$so_event -> set_recur_minutely ( $recur_enddate [ 'year' ], $recur_enddate [ 'month' ], $recur_enddate [ 'mday' ], $interval );
break ;
case HOURLY :
$so_event -> set_recur_hourly ( $recur_enddate [ 'year' ], $recur_enddate [ 'month' ], $recur_enddate [ 'mday' ], $interval );
break ;
2001-11-07 03:58:08 +01:00
case DAILY :
2004-10-15 19:40:22 +02:00
$so_event -> set_recur_daily ( $recur_enddate [ 'year' ], $recur_enddate [ 'month' ], $recur_enddate [ 'mday' ], $interval );
2001-11-07 03:58:08 +01:00
break ;
case WEEKLY :
2001-11-13 13:17:10 +01:00
$so_event -> set_recur_weekly ( $recur_enddate [ 'year' ], $recur_enddate [ 'month' ], $recur_enddate [ 'mday' ], $interval , $recur_data );
2001-11-07 03:58:08 +01:00
break ;
case MONTHLY :
2004-10-15 19:40:22 +02:00
$so_event -> set_recur_monthly_mday ( $recur_enddate [ 'year' ], $recur_enddate [ 'month' ], $recur_enddate [ 'mday' ], $interval );
2001-11-07 03:58:08 +01:00
break ;
case YEARLY :
2001-11-13 13:17:10 +01:00
$so_event -> set_recur_yearly ( $recur_enddate [ 'year' ], $recur_enddate [ 'month' ], $recur_enddate [ 'mday' ], $interval );
2001-11-07 03:58:08 +01:00
break ;
}
2004-10-15 19:40:22 +02:00
if ( isset ( $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ]))
{
$so_event -> add_attribute ( 'recur_enddate' , $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'year' ], 'year' );
$so_event -> add_attribute ( 'recur_enddate' , $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'month' ], 'month' );
$so_event -> add_attribute ( 'recur_enddate' , $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'mday' ], 'mday' );
$so_event -> add_attribute ( 'recur_enddate' , $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'hour' ], 'hour' );
$so_event -> add_attribute ( 'recur_enddate' , $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'minute' ], 'min' );
$so_event -> add_attribute ( 'recur_enddate' , $ical [ 'event' ][ $i ][ 'rrule' ][ 'until' ][ 'second' ], 'sec' );
}
2001-09-07 18:37:11 +02:00
}
2001-11-13 03:03:58 +01:00
else
{
$so_event -> set_recur_none ();
}
2004-08-25 22:51:59 +02:00
/* the organizer must be the current user doing the importing */
if ( ! isset ( $ical [ 'event' ][ $i ][ 'organizer' ]) || ! $this -> is_owner ( $ical [ 'event' ][ $i ][ 'organizer' ]))
2001-09-07 18:37:11 +02:00
{
$so_event -> add_attribute ( 'owner' , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]);
2004-08-25 22:51:59 +02:00
$so_event -> add_attribute ( 'participants' , 'A' , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ]);
2001-09-07 18:37:11 +02:00
}
2004-08-25 22:51:59 +02:00
/* if the original organizer is an egroupware user, add the original user as an event participant */
2004-10-15 19:28:34 +02:00
/* NB: ['mailto'] has two parts, ['user'], containing the username, and ['host'], containing the domain of the user's email address */
2004-08-25 22:51:59 +02:00
if ( isset ( $ical [ 'event' ][ $i ][ 'organizer' ][ 'mailto' ][ 'user' ]) && $GLOBALS [ 'phpgw' ] -> accounts -> exists ( $ical [ 'event' ][ $i ][ 'organizer' ][ 'mailto' ][ 'user' ]) == True )
2001-09-07 18:37:11 +02:00
{
2004-08-25 22:51:59 +02:00
$so_event -> add_attribute ( 'participants' , 'A' ,( int ) $GLOBALS [ 'phpgw' ] -> accounts -> name2id ( $ical [ 'event' ][ $i ][ 'organizer' ][ 'mailto' ][ 'user' ]));
2001-09-07 18:37:11 +02:00
}
2004-01-04 01:47:37 +01:00
2001-09-07 18:37:11 +02:00
$event = $so_event -> get_cached_event ();
$so_event -> add_entry ( $event );
}
}
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> link ( '/index.php' ,
Array (
'menuaction' => 'calendar.uicalendar.view' ,
'cal_id' => $event [ 'id' ]
)
)
);
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ();
2001-09-17 04:33:19 +02:00
}
2001-09-07 18:37:11 +02:00
2003-08-28 16:31:11 +02:00
function export ( $params )
2001-09-17 04:33:19 +02:00
{
2004-03-14 02:10:37 +01:00
$event_id = $params [ 'l_event_id' ] ? $params [ 'l_event_id' ] : $_GET [ 'cal_id' ];
2003-08-28 16:31:11 +02:00
$this -> chunk_split = $params [ 'chunk_split' ];
2004-03-14 02:10:37 +01:00
$method = $params [ 'method' ] ? $params [ 'method' ] : 'publish' ;
2001-09-17 04:33:19 +02:00
$string_array = Array (
'summary' => 'description' ,
'location' => 'location' ,
2005-03-31 15:19:16 +02:00
'uid' => 'uid'
2001-09-17 04:33:19 +02:00
);
$cats = CreateObject ( 'phpgwapi.categories' );
2004-01-04 01:47:37 +01:00
2001-09-17 04:33:19 +02:00
if ( ! is_array ( $event_id ))
{
$ids [] = $event_id ;
}
else
{
$ids = $event_id ;
}
$ical = $this -> new_ical ();
2005-03-31 15:19:16 +02:00
$this -> set_var ( $ical [ 'prodid' ], 'value' , '-//eGroupWare//eGroupWare ' . $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'version' ] . ' MIMEDIR//' . strtoupper ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ]));
2004-08-24 21:43:19 +02:00
$this -> set_var ( $ical [ 'version' ], 'value' , '1.0' );
2003-08-28 16:31:11 +02:00
$this -> set_var ( $ical [ 'method' ], 'value' , strtoupper ( $method ));
2001-09-17 04:33:19 +02:00
if ( ! $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'included_classes' ][ 'uicalendar' ])
{
2001-12-02 23:19:48 +01:00
if ( ! $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'included_classes' ][ 'bocalendar' ])
{
$so_event = createobject ( 'calendar.socalendar' ,
Array (
'owner' => 0 ,
'filter' => '' ,
'category' => ''
)
);
}
else
{
$so_event = $GLOBALS [ 'bocalendar' ] -> so ;
}
2001-09-17 04:33:19 +02:00
}
else
{
$so_event = $GLOBALS [ 'uicalendar' ] -> bo -> so ;
}
2004-01-04 01:47:37 +01:00
2004-03-14 02:10:37 +01:00
foreach ( $ids as $event )
2001-09-17 04:33:19 +02:00
{
$ical_event = Array ();
2004-03-14 02:10:37 +01:00
if ( ! is_array ( $event ))
{
$event = $so_event -> read_entry ( $event );
}
2001-12-02 23:19:48 +01:00
if ( $event [ 'alarm' ])
{
2004-03-14 02:10:37 +01:00
foreach ( $event [ 'alarm' ] as $alarm )
2001-12-02 23:19:48 +01:00
{
$ical_temp = Array ();
$ical_temp [ 'action' ][ 'value' ] = 'DISPLAY' ;
$ical_temp [ 'description' ][ 'value' ] = $alarm [ 'text' ];
$this -> set_var ( $ical_temp [ 'trigger' ], 'value' , 'VALUE=DATE-TIME:' . date ( 'Ymd\THis\Z' , $alarm [ 'time' ]), 'valarm' );
$ical_event [ 'alarm' ][] = $ical_temp ;
}
}
2004-08-24 21:43:19 +02:00
// $event has times in user's time zone, so have to adjust them to GMT, which is used by ical
// To do that one must substract the users time zone difference with the server and then substract the server's time zone difference with GMT
$gmt_offset = date ( 'O' ); // server's offset to GMT
$offset = (( int )( substr ( $gmt_offset , 0 , 3 )) + $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'tz_offset' ]) * 60 + ( int )( substr ( $gmt_offset , 3 , 2 ));
2004-01-28 21:24:02 +01:00
$event [ 'start' ][ 'min' ] -= $offset ;
$event [ 'end' ][ 'min' ] -= $offset ;
$event [ 'modtime' ][ 'min' ] -= $offset ;
2003-08-28 16:31:11 +02:00
2001-09-17 04:33:19 +02:00
$ical_event [ 'priority' ] = $event [ 'priority' ];
2004-01-04 01:47:37 +01:00
$ical_event [ 'class' ] = ( int ) $event [ 'public' ];
2003-08-28 16:31:11 +02:00
$dtstart_mktime = $so_event -> maketime ( $event [ 'start' ]);
2001-09-17 04:33:19 +02:00
$this -> parse_value ( $ical_event , 'dtstart' , date ( 'Ymd\THis\Z' , $dtstart_mktime ), 'vevent' );
2003-08-28 16:31:11 +02:00
$dtend_mktime = $so_event -> maketime ( $event [ 'end' ]);
2001-09-17 04:33:19 +02:00
$this -> parse_value ( $ical_event , 'dtend' , date ( 'Ymd\THis\Z' , $dtend_mktime ), 'vevent' );
2003-08-28 16:31:11 +02:00
$mod_mktime = $so_event -> maketime ( $event [ 'modtime' ]);
2001-09-17 04:33:19 +02:00
$this -> parse_value ( $ical_event , 'last_modified' , date ( 'Ymd\THis\Z' , $mod_mktime ), 'vevent' );
2004-03-14 02:10:37 +01:00
foreach ( $string_array as $ical_value => $event_value )
2001-09-17 04:33:19 +02:00
{
if ( $event [ $event_value ])
{
$this -> set_var ( $ical_event [ $ical_value ], 'value' , $event [ $event_value ]);
}
}
2004-01-04 01:47:37 +01:00
2001-09-17 04:33:19 +02:00
if ( $event [ 'category' ])
{
$cats -> categories ( 0 , 'calendar' );
2004-03-14 02:10:37 +01:00
foreach ( explode ( ',' , $event [ 'category' ]) as $cat )
2001-09-17 04:33:19 +02:00
{
$_cat = $cats -> return_single ( $cat );
$cat_string [] = $_cat [ 0 ][ 'name' ];
}
@ reset ( $cat_string );
$this -> set_var ( $ical_event [ 'categories' ], 'value' , implode ( $cat_string , ',' ));
}
if ( count ( $event [ 'participants' ]) > 1 )
{
if ( ! is_object ( $db ))
{
$db = $GLOBALS [ 'phpgw' ] -> db ;
}
2004-03-14 02:10:37 +01:00
foreach ( $event [ 'participants' ] as $part => $status )
2001-09-17 04:33:19 +02:00
{
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw' ] -> accounts -> get_account_name ( $part , $lid , $fname , $lname );
2001-09-17 04:33:19 +02:00
$name = $fname . ' ' . $lname ;
2003-08-28 16:31:11 +02:00
2004-01-04 01:47:37 +01:00
$owner_status = $this -> switch_partstat (( int ) $this -> switch_phpgw_status ( $event [ 'participants' ][ $part ]));
2003-08-28 16:31:11 +02:00
2005-03-31 15:19:16 +02:00
$mailto = $GLOBALS [ 'phpgw' ] -> accounts -> id2name ( $part , 'account_email' );
2003-08-28 16:31:11 +02:00
$str = 'CN="' . $name . '";PARTSTAT=' . $owner_status . ':' . $mailto ;
2001-09-17 04:33:19 +02:00
if ( $part == $event [ 'owner' ])
{
$str = 'ROLE=CHAIR;' . $str ;
}
else
{
$str = 'ROLE=REQ-PARTICIPANT;' . $str ;
}
2003-08-28 16:31:11 +02:00
if ( $method != 'reply' || $part == $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_id' ])
{
$this -> parse_value ( $ical_event , 'attendee' , $str , 'vevent' );
}
2001-09-17 04:33:19 +02:00
if ( $part == $event [ 'owner' ])
{
$this -> parse_value ( $ical_event , 'organizer' , $str , 'vevent' );
}
}
}
if ( $event [ 'recur_type' ])
{
$str = '' ;
switch ( $event [ 'recur_type' ])
{
2004-10-15 19:40:22 +02:00
case MCAL_RECUR_SECONDLY :
$str .= 'FREQ=SECONDLY' ;
break ;
case MCAL_RECUR_MINUTELY :
$str .= 'FREQ=MINUTELY' ;
break ;
case MCAL_RECUR_HOURLY :
$str .= 'FREQ=HOURLY' ;
break ;
2001-09-17 04:33:19 +02:00
case MCAL_RECUR_DAILY :
$str .= 'FREQ=DAILY' ;
break ;
case MCAL_RECUR_WEEKLY :
$str .= 'FREQ=WEEKLY' ;
if ( $event [ 'recur_data' ])
{
$str .= ';BYDAY=' ;
for ( $i = 1 ; $i < MCAL_M_ALLDAYS ; $i = $i * 2 )
{
if ( $i & $event [ 'recur_data' ])
{
switch ( $i )
{
case MCAL_M_SUNDAY :
$day [] = 'SU' ;
break ;
case MCAL_M_MONDAY :
$day [] = 'MO' ;
break ;
CASE MCAL_M_TUESDAY :
$day [] = 'TU' ;
break ;
case MCAL_M_WEDNESDAY :
$day [] = 'WE' ;
break ;
case MCAL_M_THURSDAY :
$day [] = 'TH' ;
break ;
case MCAL_M_FRIDAY :
$day [] = 'FR' ;
break ;
case MCAL_M_SATURDAY :
$day [] = 'SA' ;
break ;
}
}
}
$str .= implode ( ',' , $day );
}
break ;
case MCAL_RECUR_MONTHLY_MDAY :
break ;
case MCAL_RECUR_MONTHLY_WDAY :
break ;
case MCAL_RECUR_YEARLY :
$str .= 'FREQ=YEARLY' ;
break ;
}
if ( $event [ 'recur_interval' ])
{
$str .= ';INTERVAL=' . $event [ 'recur_interval' ];
}
if ( $event [ 'recur_enddate' ][ 'month' ] != 0 && $event [ 'recur_enddate' ][ 'mday' ] != 0 && $event [ 'recur_enddate' ][ 'year' ] != 0 )
{
2002-06-25 01:24:24 +02:00
$recur_mktime = $so_event -> maketime ( $event [ 'recur_enddate' ]) - $GLOBALS [ 'phpgw' ] -> datetime -> tz_offset ;
2001-09-17 04:33:19 +02:00
$str .= ';UNTIL=' . date ( 'Ymd\THis\Z' , $recur_mktime );
}
$this -> parse_value ( $ical_event , 'rrule' , $str , 'vevent' );
2001-12-02 23:19:48 +01:00
$exceptions = $event [ 'recur_exception' ];
if ( is_array ( $exceptions ))
{
2004-03-14 02:10:37 +01:00
foreach ( $exceptions as $except_datetime )
2001-12-02 23:19:48 +01:00
{
$ical_event [ 'exdate' ][] = $this -> switch_date ( date ( 'Ymd\THis\Z' , $except_datetime ));
}
}
2001-09-17 04:33:19 +02:00
}
$ical_events [] = $ical_event ;
}
2005-03-31 15:19:16 +02:00
$ical [ 'event' ] = $ical_events ;
2004-03-14 02:10:37 +01:00
// iCals are by default utf-8
return $GLOBALS [ 'phpgw' ] -> translation -> convert ( $this -> build_ical ( $ical ), $GLOBALS [ 'phpgw' ] -> translation -> charset (), 'utf-8' );
}
function freebusy ( $params = False )
{
if ( ! $params ) $params = $_GET ;
2005-03-31 15:19:16 +02:00
$this -> chunk_split = $params [ 'chunk_split' ];
$method = $params [ 'method' ] ? $params [ 'method' ] : 'publish' ;
2004-03-14 02:10:37 +01:00
$user = is_numeric ( $params [ 'user' ]) ? ( int ) $params [ 'user' ] : $GLOBALS [ 'phpgw' ] -> accounts -> name2id ( $params [ 'user' ]);
$start = isset ( $params [ 'start' ]) ? $params [ 'start' ] : date ( 'Ymd' );
$end = isset ( $params [ 'end' ]) ? $params [ 'end' ] : ( date ( 'Y' ) + 1 ) . date ( 'md' );
$this -> bo = CreateObject ( 'calendar.bocalendar' );
$events_per_day = $this -> bo -> store_to_cache ( array (
'owner' => $user ,
'syear' => ( int ) substr ( $start , 0 , 4 ),
'smonth' => ( int ) substr ( $start , 4 , 2 ),
'sday' => ( int ) substr ( $start , 6 , 2 ),
'eyear' => ( int ) substr ( $end , 0 , 4 ),
'emonth' => ( int ) substr ( $end , 4 , 2 ),
'eday' => ( int ) substr ( $end , 6 , 2 ),
'no_doubles' => True , // report events only on the startday
));
if ( ! is_array ( $events_per_day )) $events_per_day = array ();
2005-03-31 15:19:16 +02:00
$browser = CreateObject ( 'phpgwapi.browser' );
$browser -> content_header ( $GLOBALS [ 'phpgw' ] -> accounts -> id2name ( $user ) . '.ifb' , 'text/calendar' );
$ical = $this -> new_ical ();
$this -> set_var ( $ical [ 'prodid' ], 'value' , '-//eGroupWare//eGroupWare ' . $GLOBALS [ 'phpgw_info' ][ 'apps' ][ 'calendar' ][ 'version' ] . ' MIMEDIR//' . strtoupper ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ]));
$this -> set_var ( $ical [ 'version' ], 'value' , '1.0' );
$this -> set_var ( $ical [ 'method' ], 'value' , strtoupper ( $method ));
$ical_freebusy = array ();
$mailto = $GLOBALS [ 'phpgw' ] -> accounts -> id2name ( $user , 'account_email' );
$name = $GLOBALS [ 'phpgw' ] -> common -> grab_owner_name ( $user );
$str = 'CN="' . $name . '";MAILTO=' . $mailto ;
$this -> parse_value ( $ical_freebusy , 'organizer' , $str , 'vfreebusy' );
$freebusy_url = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . '/calendar/freebusy.php?user=' . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'account_lid' ] /* not sure if this should be in the file .'&password='.$GLOBALS['phpgw_info']['user']['preferences']['calendar']['freebusy_pw']*/ ;
if ( $freebusy_url [ 0 ] == '/' )
{
$freebusy_url = ( $_SERVER [ 'HTTPS' ] ? 'https://' : 'http://' ) . $_SERVER [ 'HTTP_HOST' ] . $freebusy_url ;
}
$this -> parse_value ( $ical_freebusy , 'url' , $freebusy_url , 'vfreebusy' );
$this -> parse_value ( $ical_freebusy , 'dtstart' , $start . 'T000000Z' , 'vfreebusy' );
$this -> parse_value ( $ical_freebusy , 'dtend' , $end . 'T000000Z' , 'vfreebusy' );
// $event has times in user's time zone, so have to adjust them to GMT, which is used by ical
// To do that one must substract the users time zone difference with the server and then substract the server's time zone difference with GMT
$gmt_offset = date ( 'O' ); // server's offset to GMT
$offset = (( int )( substr ( $gmt_offset , 0 , 3 )) + $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'tz_offset' ]) * 60 + ( int )( substr ( $gmt_offset , 3 , 2 ));
2004-03-14 02:10:37 +01:00
foreach ( $events_per_day as $day => $events )
{
foreach ( $events as $event )
{
2005-03-31 15:19:16 +02:00
$event [ 'start' ][ 'min' ] -= $offset ;
$event [ 'end' ][ 'min' ] -= $offset ;
$dtstart_mktime = $this -> bo -> so -> maketime ( $event [ 'start' ]);
$dtend_mktime = $this -> bo -> so -> maketime ( $event [ 'end' ]);
$this -> parse_value ( $ical_freebusy , 'freebusy' , date ( 'Ymd\THis\Z' , $dtstart_mktime ) . '/' . date ( 'Ymd\THis\Z' , $dtend_mktime ), 'vfreebusy' );
2004-03-14 02:10:37 +01:00
}
}
2005-03-31 15:19:16 +02:00
$ical [ 'freebusy' ][ 0 ] =& $ical_freebusy ;
//_debug_array($ical);
// iCals are by default utf-8
echo $GLOBALS [ 'phpgw' ] -> translation -> convert ( $this -> build_ical ( $ical ), $GLOBALS [ 'phpgw' ] -> translation -> charset (), 'utf-8' );
2001-09-17 04:33:19 +02:00
}
function debug ( $str = '' )
2001-08-04 03:34:49 +02:00
{
2001-09-17 04:33:19 +02:00
if ( $this -> debug_str )
{
echo $str . " <br> \n " ;
}
2001-08-04 03:34:49 +02:00
}
}
2001-03-17 20:39:56 +01:00
?>