boinfolog_vtodos Class Reference

Inheritance diagram for boinfolog_vtodos:

egwical_resourcehandler Collaboration diagram for boinfolog_vtodos:

Collaboration graph
[legend]
List of all members.

Detailed Description

Concrete subclass resourcehandler for iCal vtodos import and export with a egroupware boinfolog infolog resource.

Synopsis

Some simple examples. Firs we need a couple of egw tasks and an instance of our (concrete) infologresource handler class:
  $binf =& CreateObject('infolog.boinfolog');

  $tsk1 = $binf->read(1233);                    // get 3 tasks
  $tsk2 = $binf->read(4011);
  $tsk3 = $binf->read(4012);

  $binfhnd =& CreateObject('egwical.boinfolog_vtodos',$binf);
Now export a task as VTODO and render it as iCalendar string
   // alternative 1
   $vtodo1 = $binfhnd->export_vtodo($ev1,UMM_ID2UID);
   $vcalstr1 = egwical_resourcehandler::render_velt2vcal($vtodo1);

   // alternative 2 (generic for all resourcehandlers)
   $binfhnd->uid_mapping_export = UMM_ID2UID;
   $vtodo2  = $binfhnd->export_ncvelt($tsk2);
   $vcalstr2 = egwical_resourcehandler::render_velt2vcal($vtodo2);

   // alternative 3 (via baseclass, without intermediate vtodo)
   $vcalstr3 = $binfhnd->export_vcal($tsk3);
An example for importing the vtodos
    // alternative 1 (via the concrete method)
    $vtodo1  = ..... a good vtodo
    $tsk_id1 = $binfhnd->import_vtodo($vtodo1, UMM_UID2ID,1);
    if ($tsk_id1 > 0)    {
      echo "imported vtodo1 as task with id $tsk_id1";
    }

    // alternative 2 (generic for all resourcehandlers)
    $binfhnd->uid_mapping_import = UMM_UID2ID;
    $tsk_id2  = $binfhnd->import_ncvelt($vtodo2);
    if ($tsk_id2 > 0)    {
      echo "imported vtodo2 as task with id $tsk_id2";
    }

    // alternative 3 (via base class, easier for multiple vtodos)
    $my_vtodos = array($vtodo1, $vtodo2,..);
    $binfhnd->uid_mapping_import = UMM_UID2ID;
    $tids = $binfhnd->import_velts($my_vtodos);
    echo "we imported" . count($tids) . "vtodos";

And finally an example of importing all the vtodos from a vcalstring
    // alternative 1
    $vcalstr = .. an vcalendar format string with multiple vtodos

    $compvelt  = egwical_resourcehandler::parse_vcal2velt($vcalstr);
    if($compvelt === false) exit;

    $tids = $binfhnd->import_velts($compvelt);
    if ($tids)
    {
       echo "we imported" . count($tids) . "tasks";
    }

    // alternative 2 (using the baseclass its methods)
   $tids = $binfhnd->import_vcal($vcalstr);
   if ($tids)   echo "we imported" . count($tids) . "tasks";

Note:
Warning: When importing a vtodo resulting from parsing a vcalstring or any other VElt for which you do not know if it is a single vtodo or possibily a compound element with multiple vtodos in it, you should preferable use the import_velts() routine of the baseclass instead of the import_ncvelt() or the import_vtodo() routines. This is because the former can handle compound VElts, while the latter two cannot!
Inpackage: egwical

Author:
Jan van Lieshout <jvl-AT-xs4all.nl> (This version. new api rewrite, refactoring, and extension).

Lars Kneschke <lkneschke@egroupware.org> (parts from boical that are reused here)

Ralf Becker <RalfBecker-AT-outdoor-training.de> (parts from boical that are reused here)

Version:
0.9.37-ng-a6 fixed empty summary field (semi)
Since:
0.9.37-ng-a2 removed double charset translation

0.9.36 first version for napi3.1 (with rsc_owner_id parameter)

0.9.30 first version for napi3

license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License


Public Member Functions

 boinfolog_vtodos (egwobj $egwrsc=null, ProductType $devicetype='all', string $rscownid='0')
 Our Constructor, if given it sets the egw resource $egwrsc is set as so called bound egw resource.
VTODO export_ncvelt (TaskId-I-TaskData &$tid)
 Wrapper around export_vtodo() with simplified parameters.
VTODO I false export_vtodo (TaskId-I-TaskData &$task, int $uid_mapping_export=ID2UID)
 Export infolog task from bound boinfolog resource as VTODO.
TaskId I errorstring import_ncvelt (&$velt, int $tid=-1)
 Wrapper around import_vtodo() with simplified set of call parameters.
TaskId I Errorstring import_vtodo (VTODO &$vtodo, int $uid_mapping_import, boolean $reimport_missing_tasks=false, int $cal_id=0)
 Import a VTODO as a task into the Egw infolog.
boolean set_rsc (egwobj $egw_rsc)
 Set the egw infolog resource that this worker will handle.
void setSupportedFields (ProductType $devicetype= 'all')
 Set the list of ical fields that are supported during the next imports and exports.

Private Member Functions

array _provided_vtodo2taskFields ()
 Deliver the implemented vtodo to task mapping as provided by this class.

Private Attributes

boinfolog $rsc = null
 The Bound Egw (Infolog) Resource that we handle.
array $status_task2vtodo
 conversion of infologtask status to vtodo status
array $status_vtodo2task
 conversion of vtodo status to infolog status
boolean $tsdebug = true
 Switch to print extra debugging about imported and exported todos to the httpd errorlog stream.
array $vtodo2taskFields = array()
 mapping from iCalendar VTODO fields to egw infolog task fields


Constructor & Destructor Documentation

boinfolog_vtodos::boinfolog_vtodos egwobj $  egwrsc = null,
ProductType $  devicetype = 'all',
string $  rscownid = '0'
 

Our Constructor, if given it sets the egw resource $egwrsc is set as so called bound egw resource.

And $prodid, the product id of the client that will use or produce ical data is set to determine which fields to use in coming import and exportd conversions between vcalendar and egw data.

Parameters:
$egwrsc Egroupware data resource object that will be used to transport (i.e. import and export) the vcalendar elements to and from. This can also later be set using the set_rsc() method.
$devicetype The type identification of the device that is used to the transport the ical data to and from. This is used to set the supportedFields already.
Note:
These can also later be set using the setSupportedFields() method.
Parameters:
$rscownid the id of the calendar owner. This is only needed for import in calendars not owned by the authenticated user. Default (0) the id of the authenticated user is used.


Member Function Documentation

array boinfolog_vtodos::_provided_vtodo2taskFields  )  [private]
 

Deliver the implemented vtodo to task mapping as provided by this class.

Todo:
find out the correct conversion between info_owner, info_responsible, and ORGANIZER and ATTENDEES for tasks

add support for multiple2single category conversion et vice versa

add routines for resources conversions

add routines for url conversions

Todo:
find out if infolog supports yet ALARMS, if so do conversion
Note:
when a field is filled with a array('rn' => xxx) this means that for conversion the value from xxx can simply be copied to the new field. For other values the conversion is more complex and needs to be handled by specific functions.
Produce the array of vtodo to task field mappings that this class implements. These are stored on instantiation in the variable $vtodo2taskFields
Returns:
The provided vtodo to task fields mapping.

VTODO boinfolog_vtodos::export_ncvelt TaskId-I-TaskData &$  tid  ) 
 

Wrapper around export_vtodo() with simplified parameters.

Note:
the settings of $this->uid_mapping_export is respected as to chose the method of UID field generation for the VTODO. See UID to ID Mapping and Matching. in the egwical_resourcehandler documentation.
Parameters:
$tid id or arraydata of an task in the bound boinfolog resource that is to be exported.
Returns:
the exported egw task converted to a VTODO object. on error False.

VTODO I false boinfolog_vtodos::export_vtodo TaskId-I-TaskData &$  task,
int $  uid_mapping_export = ID2UID
 

Export infolog task from bound boinfolog resource as VTODO.

The eGW task in $task is exported to iCalendar VTODO (of type Horde_iCalendar_vtodo) Note that only the set of supported Fields, as indicated by the $supportedFields member variable, are exported into the VTODO.

The uid field of the generated VTODO will be filled according to the setting of the $uid_mapping_export parameter. Either with the task id encoded (ID2UID) or with the task uid field copied (UID2UID) or with a completey new generated string (NEWUID). For more info see UID to ID Mapping and Matching.

The mapping is inspired on rfc 2445 -sec 4.6.2

Bug:
created field is not fetched oke from db.
Parameters:
$task id or data of the eGW task that will be exported
$uid_mapping_export switch to set the export mode for the uid fields. Default UMM_ID2UID is used.
Returns:
the iCalendar VTODO object representing the data from the egw input task. On error: false $supportedFields determines which fields in the VTODO will be filled

TaskId I errorstring boinfolog_vtodos::import_ncvelt &$  velt,
int $  tid = -1
 

Wrapper around import_vtodo() with simplified set of call parameters.

Note:
this function only imports Vtodo elements!
The value of the member variable $reimport_missing_elements is used to possibly allow to reimport of gone tasks in the infolog.

The value of the member variable $uid_mapping_import is used to control the set of iCalendar fields that are imported.

Parameters:
$ncvelt VTODO object (horde_iCalendar_vtodo)
$tid id for a selected task to be updated by the info from $velt If left out or set to -1 then uid_mapping_import is switched back to its standard setting as found in the member variable $uid_mapping_import.
Returns:
the id of the imported(or updated) ege infolog task. On error: a string indicating the error: ERROR | NOACC | DELOK | NOELT

TaskId I Errorstring boinfolog_vtodos::import_vtodo VTODO &$  vtodo,
int $  uid_mapping_import,
boolean $  reimport_missing_tasks = false,
int $  cal_id = 0
 

Import a VTODO as a task into the Egw infolog.

The ical VTODO component is converted to an eGW task for the infolog resource in $rsc and then imported into this eGW infolog resource.

Depending on the value of $uid_mapping_import, the conversion will either:

  • generate either an eGW task with a completely new id (UMM_NEWID) and fill that with the data. Or
  • search for an existing Egw task based on a id search, with an id search key decoded from the VTODO uid field (UMM_UID2ID) to update with the data. Or
  • use the value in the VTODO uid field a search key for a uid search amongst the Egw tasks (UMM_UID2UID) to use as task to update. Or finally
  • update a specific existing Egw task defined by the $cal_id parameter, with the data (UMM_FIXEDID).

Default the mode UMM_UID2ID is used. For more info see UID to ID Mapping and Matching.

$supportedFields determines the VTODOS that will be used for import

Todo:
implement ATTENDEE and ORGANIZER import for VTODOS
Parameters:
$vtodo VTODO object (horde_iCalendar_vtodo)
$uid_mapping_import uid mapping import mode used. see UID to ID Mapping and Matching. Default UMM_UID2ID.
$reimport_missing_tasks enable the import of previously exported tasks that are now gone in egw (probably deleted by someone else) Default false.
$cal_id the id of the egw task that is to be updated when UMM_FIXEDID mode is is set for $uid_mapping_import. If set as -1 the uid_mapping_import will switch to UMM_NEWID mode, if set as 0 the uid_mapping_import will switch to the default UMM_UID2ID mode.
Returns:
the id of the imported(or updated) egw infolog task. On error: a string indicating the error: ERROR | NOACC | DELOK | NOELT | BTYPE

boolean boinfolog_vtodos::set_rsc egwobj $  egw_rsc  ) 
 

Set the egw infolog resource that this worker will handle.

This worker is only capable of handling boinfolog task objects, so it should be of that class. The $egw_rsc is registered in the $rsc variable and the supported ical element is set to be 'vtodo'. This is registered in $rsc_vtypes.

Parameters:
$egw_rsc the resource object of type boinfolog that will be used to transport the ical data to and from.
Returns:
false on error, true if the $egw_rsc was indeed a correct resource of the supported type (boinfolog).

void boinfolog_vtodos::setSupportedFields ProductType $  devicetype = 'all'  ) 
 

Set the list of ical fields that are supported during the next imports and exports.

The list of iCal fields that should be converted during the following imports and exports of VTODOS is set. This is done according to a given ProductType as mostly set in the $deviceType field of the egwical_resourcehandler. See there for a further description.

In a small lookup table the set of currently supported fields is searched for and then and then these are set accordingly in the class member $supportedFields.

Note:
to find the ProductType for a device (like a iCalendar, browser, a syncml client etc.) the egwical_resoucehandler class provides some handy methods, like: icalendarProdId2devicetype(), httpUserAgent2deviceType() and product2devicetype()
Parameters:
$devicetype a string indicating the communicating client his type of device
Returns:


Member Data Documentation

boinfolog boinfolog_vtodos::$rsc = null [private]
 

The Bound Egw (Infolog) Resource that we handle.

Registry for the egw resource object (infolog,..) that will be used to transport ical elements from and to: The socalled Bound Resource This can be set by the constructor or later by set_rsc().

Reimplemented from egwical_resourcehandler.

array boinfolog_vtodos::$status_task2vtodo [private]
 

Initial value:

                array(
                          'offer'       => 'NEEDS-ACTION',
                          'not-started' => 'NEEDS-ACTION',
                          'ongoing'     => 'IN-PROCESS',
                          'done'        => 'COMPLETED',
                          'cancelled'   => 'CANCELLED',
                          'billed'      => 'DONE',
                          'call'        => 'NEEDS-ACTION',
                          'will-call'   => 'IN-PROCESS',
                          )
conversion of infologtask status to vtodo status

array boinfolog_vtodos::$status_vtodo2task [private]
 

Initial value:

                array(
                          'NEEDS-ACTION' => 'not-started',
                          'IN-PROCESS'   => 'ongoing',
                          'COMPLETED'    => 'done',
                          'CANCELLED'    => 'cancelled',
                          )
conversion of vtodo status to infolog status

boolean boinfolog_vtodos::$tsdebug = true [private]
 

Switch to print extra debugging about imported and exported todos to the httpd errorlog stream.

array boinfolog_vtodos::$vtodo2taskFields = array() [private]
 

mapping from iCalendar VTODO fields to egw infolog task fields

An array containing roughly the mapping from iCalendar to egw fields. Set by constructor. example entry (rn stands for "Resourced_Name"):

			'SUMMARY'	=> array('rn' => 'title'),
  	    
Here rn stands for "Resourced Name", to indicate the name of the related related field in the bound egw resource
Todo:
integrate this with the egwical base $ical2egw conversion table


The documentation for this class was generated from the following file:
Generated on Thu Jun 8 21:57:23 2006 for EgwIcal by  doxygen 1.4.6