Beispiel #1
0
  public static function generateIcs($event, $method, $userId, $include_attachments = false) {
    include_once('obminclude/of/vcalendar/writer/ICS.php');
    include_once('obminclude/of/vcalendar/reader/OBM.php');
    
    $reader = new Vcalendar_Reader_OBM(array('user' => array($userId => 'dummy')), array($event->id));
    $document = $reader->getDocument($method, $include_attachments);
    $writer = new Vcalendar_Writer_ICS();  
    $writer->writeDocument($document);

    $tmpFilename = secure_tmpname('.ics','ics_');
    $res = fopen($tmpFilename, 'w');

    if (!$res) {
      throw new Exception('Unable to open file');
    }
    fputs($res, $writer->buffer);
    fclose($res);
    return $tmpFilename;
  }
Beispiel #2
0
 /**
  * Perform the export of the calendar to the vCalendar format
  */
 private function user_vcalendar_export($user_id)
 {
     $date = new Of_date();
     $start = clone $date;
     $start = $start->subYear(100);
     $end = clone $date;
     $end->addYear(100);
     $calendar_user['user'] = array($user_id => 'dummy');
     include_once 'php/calendar/calendar_query.inc';
     include_once 'obminclude/of/vcalendar/writer/ICS.php';
     include_once 'obminclude/of/vcalendar/reader/OBM.php';
     $reader = new Vcalendar_Reader_OBM($calendar_user, NULL, $start, $end);
     $document = $reader->getDocument();
     $writer = new Vcalendar_Writer_ICS();
     $writer->writeDocument($document);
     $document->destroy();
     return $writer->buffer;
 }