Ejemplo n.º 1
0
Archivo: Base.php Proyecto: horde/horde
 /**
  * Generates the free/busy export.
  *
  * @return Horde_iCalendar  The iCal object.
  */
 public function export()
 {
     /* Create the new iCalendar. */
     $vCal = new Horde_iCalendar();
     $vCal->setAttribute('PRODID', $this->_backend->getProductId());
     $vCal->setAttribute('METHOD', 'PUBLISH');
     /* Create the new vFreebusy component. */
     $vFb =& Horde_iCalendar::newComponent('vfreebusy', $vCal);
     $vFb->setAttribute('ORGANIZER', $this->getOrganizerMail(), $this->getOrganizerName());
     $vFb->setAttribute('DTSTAMP', $this->getDateStamp());
     $vFb->setAttribute('DTSTART', $this->getStart()->timestamp());
     $vFb->setAttribute('DTEND', $this->getEnd()->timestamp());
     $url = $this->_backend->getUrl();
     if (!empty($url)) {
         $vFb->setAttribute('URL', $this->getUrl());
     }
     /* Add all the busy periods. */
     foreach ($this->_resource->listEvents($this->getStart(), $this->getEnd()) as $event) {
         $status = $this->_status_map->map($event->getStatus());
         $duration = $event->duration();
         $extra = $event->getEncodedInformation();
         foreach ($event->getBusyTimes($this->getStart(), $this->getEnd()) as $busy) {
             $vFb->addBusyPeriod($status, $busy, null, $duration, $extra);
         }
     }
     /* Remove the overlaps. */
     $vFb->simplify();
     /* Combine and return. */
     $vCal->addComponent($vFb);
     return $vCal;
 }