First setup the basic objects we need: we create an egw resource, read a task from it, create a vtodo object and create a conversion library object (because not all the conversion routines can yet be called as class methods):
$binf =& CreateObject('infolog.boinfolog'); $task = $binf->read(1233); .... $vtodo = Horde_iCalendar::newComponent('VTODO',....); ... $eicnv =& CreateObject('egwical.eicnvutils');
Now we use three routines from our class to fill the ATTENDEE attribute of $vtodo
with info for the first responsible person we found in the task in $task
.
$actor1_id = $task['info_responsible'][0]; $propval = $eicnv->mki_v_CAL_ADDRESS($actor1_id); $propparams = $eicnv->mki_p_CN($actor1_id); $eicnv->updi_c_addAttribute($vtodo,'ATTENDEE',$propval,$propparams);
mki_v_CAL_ADDRESS()
) and a full Calendar Name as vtodo parameter (by use of the method mki_p_CN()
). Finally the property value and the property parameters are added to the new vtodo element by use of the updi_c_addAttribute()
routine.
As a result of this code you might find in the printed variant of $vtodo
a line added like:
BEGIN:VTODO ... ATTENDEE;CN=Paul Demoman:MAILTO:paul@demoland.org ... END:VTODO
VEVENT
s) to specific Egw Elements (like e.g. calendar event
s), can profitably use the set auxiliary conversion methods that the eicnvutils provides. This class should be used as a kind of (read only) library: no state is needed. The members of this class are only used as constants. So one instance should do for multiple worker objects that used it. No need to duplicate it.Most of the utility methods that are provideda follow a generic naming scheme based on their functionality. The generic prefixes are:
mki_
mki_c
to make ical Components like VEVENTS or VALARMS mki_v
to make ical field Values like e.g. a ATTENDEE field value mki_vp
to make both ical field Values and Parameters mke_
updi_
upde_
eicnvutils::method_x(...)
) are labeled as such. You dont need more than a singleton of the class egwical.eicnvutils though, as it carries no state.
0.9.34-b3 dst-patch fixed
0.9.31 added some FREEBUSY routines
0.9.30 using napi3 api
0.9.22 separated the conversion utilties into eicnvutils class
0.9.04 RRULE count= impl.
Lars Kneschke <lkneschke@egroupware.org> (original code of reused parts)
Ralf Becker <RalfBecker-AT-outdoor-training.de> (original code of reused parts)
Generic Conversion Auxiliary routines | |
int | a6toutime (array $a6) |
Convert a 6 field hash array in the current active timezone to a unix servertime timestamp. | |
int | st_dst_patch (int $so_utime) |
Patch a servertime timestamp with a DaylightSavingsTime offset. | |
array | utimetoa6 (int $utime) |
Convert a unix timestamp to a 6 field hash array in the current active timezone. | |
int | get_TSdbAdd (int $id, string $appname='calendar') |
Get database add date of event or todo. | |
Public Member Functions | |
eicnvutils () | |
Constructor, init the auxiliary object $hi and $TASKMAGIC and instantiate the $reg_rscworkers workers registry and the $reg_rscs resources registry. | |
Vcalendar Element Building Help Routines | |
Routines to add parts to VElts | |
string I false | cats_ids2idnamescstr (array $cids) |
Translate cat-ids to commasepstingh cat-names. | |
horde_iCalendar_valarm I false | mki_c_VALARM (array &$alarm, horde_object &$vcomp, $utstart, array &$veExportFields) |
Convert egw alarm info to a ical VALARM object. | |
array | mki_default_vcalendar_attributes () |
produce array of default vcalendar attributes. | |
array | mki_p_CN (int $account_id) |
Convert and egw account id into a iCalendar CN type parameter string. | |
string | mki_p_FBTYPE ($fbtype=null) |
Convert an egw act-type label to a freebusytype parameter. | |
string | mki_v_CAL_ADDRESS (int $aid) |
Convert and egw account id into a iCalendar CAL-ADDRESS type value string. | |
array | mki_v_FREEBUSY (int $utstart, int $utend) |
Convert an egw period with start and end times to a freebusy value. | |
string I false | mki_v_guid (string-I-int $egw_id, string $app_prefix='egw') |
Generate ical UID from egw id. | |
int | mki_v_prio (int $eprio=0) |
Convert a egw prio into a value for the ical property PRIORITY. | |
string | mki_v_RECUR (string $recur_type, mixed $recur_data, int $recur_interval, $recur_start, utime $recur_enddate) |
Make a value of type RECUR for a ical RRULE property. | |
array | mki_vp_4ATTENDEE (int $pid, array $partstat, int $owner_id) |
Convert the egw person id and its participant status into an ATTENDEE value and parameterslist. | |
array | mki_vp_4EXDATE (array $recur_exceptions, boolean $dtmode=false) |
Make a value (commasep string of dates) for the EXDATE property. | |
boolean I Horde_iCalendar | parsevCalendar (string $vcalstr) |
Parse a vCalendar string into an Horde_iCalendar object. | |
true | updi_c_addAttribute (VElt &$vobj, string $aname, mixed $avalue, array $aparams) |
Add (append) an new attribute (aka field) to the vevent. | |
Egw Element Building Help Routines | |
Routines to add parts to EElts | |
string | cats_names2idscstr (array $cnames, string $owner_id, string $app_name='infolog') |
Translate catnames back to cat-ids creating/modifying cats on the fly. | |
array | mke_ATTENDEE2cneml (string $aval, array $aparams) |
Parse a CAL_ADDRESS and PARAMS to find the CN name and email. | |
int I false | mke_CAL_ADDRESS2pid (string $attrval) |
Parse a CAL_ADDRESS and try to find the associated egw person_id. | |
int | mke_DDT2utime (array-I-string $ddtval) |
Convert a horde_icalendar parsed attribute date- or date-time value to a unix timestamp. | |
array | mke_EXDATEpv2udays (array $params, array $dvals) |
Convert DDT possible DATE|DATE-TIME params and a value commalist into an array of utime dates. | |
false I int | mke_guid2id (string $guid, string $app_prefix='egw') |
Try to decode an egw id from a ical UID. | |
array I false | mke_params2partstat (array $params) |
Search a ical parameterlist for possible setting for a egw participant status. | |
int | mke_prio (int $iprio=0) |
Convert a ical prio into a value for egw. | |
array | mke_RECUR2rar (string $recur, mixed $rstart) |
Convert a RECUR value into the corresponding egw recur fields. | |
true | upde_c_VALARM2alarms (array &$alarms, horde_iCalendar_valarm &$valarm, int $user_id, array &$veImportFields) |
Update the egw alarms array with info from a VALARM. | |
true | upde_nonegwParticipants2description (string &$edescription, array &$ne_participants) |
Update an egw event description with a list of nonegw participants. | |
Public Attributes | |
Horde_iCalendar | $hi |
Placeholder object used to access various Horde_iCalendar methods In here the constructor will create a Horde_iCalendar object that can be used by the various routines in the class. | |
Private Attributes | |
array | $dowseqid |
Get sequential indexes for the daynames in a week. | |
boolean | $eicnvdebug = false |
Switch to print extra debugging about imported and exported events to the httpd errorlog stream. | |
array | $partstatus_egw2ical |
Conversion of the egw used participant status values to the corresponding icalendar attendee status terminology. | |
array | $partstatus_ical2egw |
Conversion of the icalendar used attendee status values to the corresponding icalendar participants status terminology. | |
array | $priority_egw2ical |
Conversion of the egw used priority values(0. | |
array | $priority_ical2egw |
Conversion of the icalendar used priority values(0. | |
array | $recur_days |
recur_days translates MCAL recur-days to verbose labels (copied from class.bocal.inc.php file | |
array | $recur_egw2ical |
Conversion of egw recur-type to ical FREQ values for RRULE fields. | |
string | $TASKMAGIC = 'dummy' |
Magic unique number used for de/encoding our uids. |
|
Constructor, init the auxiliary object $hi and $TASKMAGIC and instantiate the $reg_rscworkers workers registry and the $reg_rscs resources registry.
|
|
Convert a 6 field hash array in the current active timezone to a unix servertime timestamp. --Class method-- This is basically the inverseof php getdate() function. The a6date array has fields as in the php getdate() function:
|
|
Translate cat-ids to commasepstingh cat-names. --Class method-- JVLNOTE: boldly copied from class.xmlrpc_server.inc.php because I donot know how to instantiate $GLOBALS['server'] (that provides this method) atm.
|
|
Translate catnames back to cat-ids creating/modifying cats on the fly. --Class method--
|
|
Get database add date of event or todo. --Class method--
|
|
Parse a CAL_ADDRESS and PARAMS to find the CN name and email. --Class method--
|
|
Parse a CAL_ADDRESS and try to find the associated egw person_id. --Class method--
|
|
Convert a horde_icalendar parsed attribute date- or date-time value to a unix timestamp. --Class method--
|
|
Convert DDT possible DATE|DATE-TIME params and a value commalist into an array of utime dates. --Class method--
ex1: ...;VALUE=DATE:20060123,20060124 ex2: ...:20060118T101500Z,20060119T1000Z ex3: ...:VALUE=DATE-TIME:20060118T101500Z,20060119T1000Z
|
|
Try to decode an egw id from a ical UID.
|
|
Search a ical parameterlist for possible setting for a egw participant status. Parse the params array to find a PARTSTAT param, convert this to a egw partstatus (may occur e.g. in ATTENDEE params)
|
|
Convert a ical prio into a value for egw.
|
|
Convert a RECUR value into the corresponding egw recur fields.
A value of type RECUR (for a ical RRULE property) is parsed into the 4 related egw fields. Fields unfilled stay false A simple example:
|
|
Convert egw alarm info to a ical VALARM object. --Class method-- Make a VALARM object form data in $alarms and $utstart (in utc) and with $vevent as container
|
|
produce array of default vcalendar attributes. --Class method--
|
|
Convert and egw account id into a iCalendar CN type parameter string. --Class method--
|
|
Convert an egw act-type label to a freebusytype parameter. --Class method-- Generate parameter a according to rfc2445,sec.4.2.9
|
|
Convert and egw account id into a iCalendar CAL-ADDRESS type value string. --Class method--
|
|
Convert an egw period with start and end times to a freebusy value. --Class method-- Generate a simple, single freebusy value according to rfc2445,sec.4.8.2.6 as start and end dt times
|
|
Generate ical UID from egw id. generate a unique id, with the egw id encoded into it, which can be used for later synchronisation.
|
|
Convert a egw prio into a value for the ical property PRIORITY.
|
|
Make a value of type RECUR for a ical RRULE property.
A simple example:
|
|
Convert the egw person id and its participant status into an ATTENDEE value and parameterslist. The resulting value of the ATTENDEE field will be in CAL_ADDRESS type format. The resulting parameterlist may contain fields of the following:
|
|
Make a value (commasep string of dates) for the EXDATE property. --Class method-- In the conversion you can chose between a commastring of DATES or DATE-TIMES
|
|
Parse a vCalendar string into an Horde_iCalendar object. To actually parse the string, the Horde_iCalendar in member $hi is used.
|
|
Patch a servertime timestamp with a DaylightSavingsTime offset. --Class method-- As the current export of servertime to UTC routine from Horde does not respect daylight savings time, the conversion from a server time, for a server working in a locale with day savings time, to a UTC value wont work correctly. This function returns the the time value in $so_utime patched (i.e. added or subtracted) by an offset based on the DST setting of the server time zone servertime for the date in $so_utime.
|
|
Update the egw alarms array with info from a VALARM. --Class method--
|
|
Update an egw event description with a list of nonegw participants. --Class method-- note: this is a adhoc solution, preferably the nonegw participants should be added automatically to the addressbook
|
|
Add (append) an new attribute (aka field) to the vevent. --Class method--
|
|
Convert a unix timestamp to a 6 field hash array in the current active timezone. --Class method-- This is basically alike the php getdate() function but with different field names The a6date array has fields as in the php getdate() function:
|
|
Initial value: array('SU' => 1, 'MO' => 2, 'TU' => 3, 'WE' => 4, 'TH' => 5, 'FR' => 6, 'SA' => 7) Used for recurrence count calculations. |
|
Switch to print extra debugging about imported and exported events to the httpd errorlog stream.
|
|
Placeholder object used to access various Horde_iCalendar methods In here the constructor will create a Horde_iCalendar object that can be used by the various routines in the class.
|
|
Initial value: array( 'U' => 'NEEDS-ACTION', 'A' => 'ACCEPTED', 'R' => 'DECLINED', 'T' => 'TENTATIVE', )
|
|
Initial value: array( 'NEEDS-ACTION' => 'U', 'ACCEPTED' => 'A', 'DECLINED' => 'R', 'TENTATIVE' => 'T', )
|
|
Initial value: array( 0 => 0, // undefined 1 => 9, // low 2 => 5, // normal 3 => 1, // high ) .3) to corresponding ical values(0..9). |
|
Initial value: array( 0 => 0, // undefined 9 => 1, 8 => 1, 7 => 1, // low 6 => 2, 5 => 2, 4 => 2, // normal 3 => 3, 2 => 3, 1 => 3, // high ) .9) to corresponding egw values (0..3). |
|
Initial value: array( MCAL_M_MONDAY => 'Monday', MCAL_M_TUESDAY => 'Tuesday', MCAL_M_WEDNESDAY => 'Wednesday', MCAL_M_THURSDAY => 'Thursday', MCAL_M_FRIDAY => 'Friday', MCAL_M_SATURDAY => 'Saturday', MCAL_M_SUNDAY => 'Sunday', )
|
|
Initial value: array( MCAL_RECUR_DAILY => 'DAILY', MCAL_RECUR_WEEKLY => 'WEEKLY', MCAL_RECUR_MONTHLY_MDAY => 'MONTHLY', MCAL_RECUR_MONTHLY_WDAY => 'MONTHLY', MCAL_RECUR_YEARLY => 'YEARLY', )
|
|
Magic unique number used for de/encoding our uids. This string that contains global unique magic number that is unique for our current database installed etc. It is used to recognize earlier exported VTODO or VEVENT UID fields as referring to their eGW counterparts. |