ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCalendarExport Class Reference

Export calendar(s) to ical format More...

+ Collaboration diagram for ilCalendarExport:

Public Member Functions

 __construct ($a_calendar_ids=array())
 getUserSettings ()
 Get user settings.
 setExportType ($a_type)
 setAppointments ($a_apps)
 getAppointments ()
 setCalendarIds ($a_cal_ids)
 getCalendarIds ()
 getExportType ()
 export ()
 getExportString ()

Data Fields

const EXPORT_CALENDARS = 1
const EXPORT_APPOINTMENTS = 2

Protected Member Functions

 addTimezone ()
 addCategories ()
 addAppointments ()
 addAppointment ($a_app_id)
 createVTODO ($app)
 createVEVENT ($app)
 createRecurrences ($app)
 buildAppointmentUrl (ilCalendarEntry $entry)
 Build url from calendar entry.

Protected Attributes

 $export_type = self::EXPORT_CALENDARS
 $calendars = array()
 $user_settings = NULL
 $appointments = array()
 $writer = null

Detailed Description

Export calendar(s) to ical format

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 37 of file class.ilCalendarExport.php.

Constructor & Destructor Documentation

ilCalendarExport::__construct (   $a_calendar_ids = array())

Definition at line 50 of file class.ilCalendarExport.php.

References $GLOBALS, and ilCalendarUserSettings\_getInstanceByUserId().

{
$this->calendars = $a_calendar_ids;
$this->writer = new ilICalWriter();
$this->user_settings = ilCalendarUserSettings::_getInstanceByUserId($GLOBALS['ilUser']->getId());
}

+ Here is the call graph for this function:

Member Function Documentation

ilCalendarExport::addAppointment (   $a_app_id)
protected

Definition at line 162 of file class.ilCalendarExport.php.

References createVEVENT(), and createVTODO().

Referenced by addAppointments(), and addCategories().

{
$app = new ilCalendarEntry($a_app_id);
if($app->isMilestone())
{
$this->createVTODO($app);
}
else
{
$this->createVEVENT($app);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::addAppointments ( )
protected

Definition at line 154 of file class.ilCalendarExport.php.

References addAppointment(), and getAppointments().

Referenced by export().

{
foreach($this->getAppointments() as $app)
{
$this->addAppointment($app);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::addCategories ( )
protected

Definition at line 143 of file class.ilCalendarExport.php.

References ilCalendarCategoryAssignments\_getAssignedAppointments(), and addAppointment().

Referenced by export().

{
foreach($this->calendars as $category_id)
{
foreach(ilCalendarCategoryAssignments::_getAssignedAppointments(array($category_id)) as $app_id)
{
$this->addAppointment($app_id);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::addTimezone ( )
protected

Definition at line 120 of file class.ilCalendarExport.php.

References $GLOBALS, $reader, ilCalendarUserSettings\CAL_EXPORT_TZ_UTC, getUserSettings(), and ilCalendarUtil\getZoneInfoFile().

Referenced by export().

{
if($this->getUserSettings()->getExportTimeZoneType() == ilCalendarUserSettings::CAL_EXPORT_TZ_UTC)
{
return;
}
$this->writer->addLine('X-WR-TIMEZONE:'.$GLOBALS['ilUser']->getTimeZone());
include_once './Services/Calendar/classes/class.ilCalendarUtil.php';
$tzid_file = ilCalendarUtil::getZoneInfoFile($GLOBALS['ilUser']->getTimeZone());
if(!is_file($tzid_file))
{
$tzid_file = ilCalendarUtil::getZoneInfoFile('Europe/Berlin');
}
$reader = fopen($tzid_file,'r');
while($line = fgets($reader))
{
$line = str_replace("\n", '', $line);
$this->writer->addLine($line);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::buildAppointmentUrl ( ilCalendarEntry  $entry)
protected

Build url from calendar entry.

Parameters
ilCalendarEntry$entry
Returns
string

Definition at line 306 of file class.ilCalendarExport.php.

References ilObject\_getAllReferences(), ilLink\_getLink(), ilCalendarCategoryAssignments\_lookupCategories(), ilCalendarEntry\getEntryId(), ilCalendarCategory\getInstanceByCategoryId(), and ilCalendarCategory\TYPE_OBJ.

Referenced by createVEVENT().

{
);
if($cat->getType() != ilCalendarCategory::TYPE_OBJ)
{
$this->writer->addLine('URL;VALUE=URI:'.ILIAS_HTTP_PATH);
}
else
{
$refs = ilObject::_getAllReferences($cat->getObjId());
include_once './Services/Link/classes/class.ilLink.php';
$this->writer->addLine(
'URL;VALUE=URI:'.ilLink::_getLink(current((array) $refs))
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::createRecurrences (   $app)
protected

Definition at line 280 of file class.ilCalendarExport.php.

References $ilUser, ilCalendarRecurrences\_getRecurrences(), and ilCalendarRecurrenceExclusions\getExclusionDates().

Referenced by createVEVENT().

{
global $ilUser;
include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
foreach(ilCalendarRecurrences::_getRecurrences($app->getEntryId()) as $rec)
{
foreach(ilCalendarRecurrenceExclusions::getExclusionDates($app->getEntryId()) as $excl)
{
$this->writer->addLine($excl->toICal());
}
$this->writer->addLine($rec->toICal($ilUser->getId()));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::createVEVENT (   $app)
protected

Definition at line 181 of file class.ilCalendarExport.php.

References $ilUser, ilCalendarRecurrences\_getFirstRecurrence(), buildAppointmentUrl(), ilCalendarUserSettings\CAL_EXPORT_TZ_UTC, createRecurrences(), ilICalWriter\escapeText(), getUserSettings(), IL_CAL_DATE, IL_CAL_DAY, IL_CAL_FKT_DATE, IL_CAL_UNIX, IL_CAL_YEAR, and ilTimeZone\UTC.

Referenced by addAppointment().

{
global $ilUser;
$this->writer->addLine('BEGIN:VEVENT');
// TODO only domain
$this->writer->addLine('UID:'.ilICalWriter::escapeText(
$app->getEntryId().'_'.CLIENT_ID.'@'.ILIAS_HTTP_PATH));
$last_mod = $app->getLastUpdate()->get(IL_CAL_FKT_DATE,'Ymd\THis\Z',ilTimeZone::UTC);
#$last_mod = $app->getLastUpdate()->get(IL_CAL_FKT_DATE,'Ymd\THis\Z',$ilUser->getTimeZone());
$this->writer->addLine('LAST-MODIFIED:'.$last_mod);
// begin-patch aptar
include_once './Services/Calendar/classes/class.ilCalendarRecurrences.php';
if($rec = ilCalendarRecurrences::_getFirstRecurrence($app->getEntryId()))
{
// Set starting time to first appointment that matches the recurrence rule
include_once './Services/Calendar/classes/class.ilCalendarRecurrenceCalculator.php';
$calc = new ilCalendarRecurrenceCalculator($app,$rec);
$pStart = $app->getStart();
$pEnd = clone $app->getStart();
$pEnd->increment(IL_CAL_YEAR,5);
$appDiff = $app->getEnd()->get(IL_CAL_UNIX) - $app->getStart()->get(IL_CAL_UNIX);
$recs = $calc->calculateDateList($pStart, $pEnd);
// defaults
$startInit = $app->getStart();
$endInit = $app->getEnd();
foreach($recs as $dt)
{
$startInit = $dt;
$endInit = clone($dt);
$endInit->setDate($startInit->get(IL_CAL_UNIX) + $appDiff,IL_CAL_UNIX);
break;
}
}
else
{
$startInit = $app->getStart();
$endInit = $app->getEnd();
}
if($app->isFullday())
{
// According to RFC 5545 3.6.1 DTEND is not inklusive.
// But ILIAS stores inklusive dates in the database.
#$app->getEnd()->increment(IL_CAL_DAY,1);
$endInit->increment(IL_CAL_DATE,1);
#$start = $app->getStart()->get(IL_CAL_FKT_DATE,'Ymd\Z',ilTimeZone::UTC);
#$start = $app->getStart()->get(IL_CAL_FKT_DATE,'Ymd',$ilUser->getTimeZone());
$start = $startInit->get(IL_CAL_FKT_DATE,'Ymd',$ilUser->getTimeZone());
#$end = $app->getEnd()->get(IL_CAL_FKT_DATE,'Ymd\Z',ilTimeZone::UTC);
#$end = $app->getEnd()->get(IL_CAL_FKT_DATE,'Ymd',$ilUser->getTimeZone());
$endInit->increment(IL_CAL_DAY,1);
$end = $endInit->get(IL_CAL_FKT_DATE,'Ymd',$ilUser->getTimeZone());
$this->writer->addLine('DTSTART;VALUE=DATE:' . $start);
$this->writer->addLine('DTEND;VALUE=DATE:'.$end);
}
else
{
if($this->getUserSettings()->getExportTimeZoneType() == ilCalendarUserSettings::CAL_EXPORT_TZ_UTC)
{
$start = $app->getStart()->get(IL_CAL_FKT_DATE,'Ymd\THis\Z',ilTimeZone::UTC);
$end = $app->getEnd()->get(IL_CAL_FKT_DATE,'Ymd\THis\Z',ilTimeZone::UTC);
$this->writer->addLine('DTSTART:'. $start);
$this->writer->addLine('DTEND:'.$end);
}
else
{
$start = $startInit->get(IL_CAL_FKT_DATE,'Ymd\THis',$ilUser->getTimeZone());
$end = $endInit->get(IL_CAL_FKT_DATE,'Ymd\THis',$ilUser->getTimeZone());
$this->writer->addLine('DTSTART;TZID='.$ilUser->getTimezone().':'. $start);
$this->writer->addLine('DTEND;TZID='.$ilUser->getTimezone().':'.$end);
}
}
// end-patch aptar
$this->createRecurrences($app);
$this->writer->addLine('SUMMARY:'.ilICalWriter::escapeText($app->getPresentationTitle(false)));
if(strlen($app->getDescription()))
$this->writer->addLine('DESCRIPTION:'.ilICalWriter::escapeText($app->getDescription()));
if(strlen($app->getLocation()))
$this->writer->addLine('LOCATION:'.ilICalWriter::escapeText($app->getLocation()));
// TODO: URL
$this->buildAppointmentUrl($app);
$this->writer->addLine('END:VEVENT');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::createVTODO (   $app)
protected

Definition at line 175 of file class.ilCalendarExport.php.

Referenced by addAppointment().

{
// TODO
return true;
}

+ Here is the caller graph for this function:

ilCalendarExport::export ( )

Definition at line 98 of file class.ilCalendarExport.php.

References addAppointments(), addCategories(), addTimezone(), and getExportType().

Referenced by ilCalendarRemoteAccessHandler\handleRequest().

{
$this->writer->addLine('BEGIN:VCALENDAR');
$this->writer->addLine('VERSION:2.0');
$this->writer->addLine('METHOD:PUBLISH');
$this->writer->addLine('PRODID:-//ilias.de/NONSGML ILIAS Calendar V4.4//EN');
$this->addTimezone();
switch($this->getExportType())
{
case self::EXPORT_CALENDARS:
$this->addCategories();
break;
case self::EXPORT_APPOINTMENTS:
$this->addAppointments();
break;
}
$this->writer->addLine('END:VCALENDAR');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCalendarExport::getAppointments ( )

Definition at line 78 of file class.ilCalendarExport.php.

References $appointments.

Referenced by addAppointments().

{
}

+ Here is the caller graph for this function:

ilCalendarExport::getCalendarIds ( )

Definition at line 88 of file class.ilCalendarExport.php.

References $calendars.

{
return (array) $this->calendars;
}
ilCalendarExport::getExportString ( )

Definition at line 296 of file class.ilCalendarExport.php.

{
return $this->writer->__toString();
}
ilCalendarExport::getExportType ( )

Definition at line 93 of file class.ilCalendarExport.php.

References $export_type.

Referenced by export().

{
}

+ Here is the caller graph for this function:

ilCalendarExport::getUserSettings ( )

Get user settings.

Returns
ilCalendarUserSettings

Definition at line 62 of file class.ilCalendarExport.php.

References $user_settings.

Referenced by addTimezone(), and createVEVENT().

{
}

+ Here is the caller graph for this function:

ilCalendarExport::setAppointments (   $a_apps)

Definition at line 73 of file class.ilCalendarExport.php.

{
$this->appointments = $a_apps;
}
ilCalendarExport::setCalendarIds (   $a_cal_ids)

Definition at line 83 of file class.ilCalendarExport.php.

{
$this->calendars = $a_cal_ids;
}
ilCalendarExport::setExportType (   $a_type)

Definition at line 68 of file class.ilCalendarExport.php.

{
$this->export_type = $a_type;
}

Field Documentation

ilCalendarExport::$appointments = array()
protected

Definition at line 47 of file class.ilCalendarExport.php.

Referenced by getAppointments().

ilCalendarExport::$calendars = array()
protected

Definition at line 45 of file class.ilCalendarExport.php.

Referenced by getCalendarIds().

ilCalendarExport::$export_type = self::EXPORT_CALENDARS
protected

Definition at line 42 of file class.ilCalendarExport.php.

Referenced by getExportType().

ilCalendarExport::$user_settings = NULL
protected

Definition at line 46 of file class.ilCalendarExport.php.

Referenced by getUserSettings().

ilCalendarExport::$writer = null
protected

Definition at line 48 of file class.ilCalendarExport.php.

const ilCalendarExport::EXPORT_APPOINTMENTS = 2

Definition at line 40 of file class.ilCalendarExport.php.

Referenced by ilCalendarMailNotification\addAttachment().

const ilCalendarExport::EXPORT_CALENDARS = 1

Definition at line 39 of file class.ilCalendarExport.php.


The documentation for this class was generated from the following file: