/** * Merges the busy periods of another Horde_Icalendar_Vfreebusy object * into this one. * * This might lead to simplification no matter what you specify for the * "simplify" flag since periods with the same start date will lead to the * shorter period being removed (see addBusyPeriod). * * @param Horde_Icalendar_Vfreebusy $freebusy A freebusy object. * @param boolean $simplify If true, simplify() will * called after the merge. */ public function merge(Horde_Icalendar_Vfreebusy $freebusy, $simplify = true) { $extra = $freebusy->getExtraParams(); foreach ($freebusy->getBusyPeriods() as $start => $end) { // This might simplify the busy periods without taking the // "simplify" flag into account. $this->addBusyPeriod('BUSY', $start, $end, null, isset($extra[$start]) ? $extra[$start] : array()); } foreach (array('DTSTART', 'DTEND') as $val) { try { $thisattr = $this->getAttribute($val); } catch (Horde_Icalendar_Exception $e) { $thisattr = null; } try { $thatattr = $freebusy->getAttribute($val); } catch (Horde_Icalendar_Exception $e) { $thatattr = null; } if (is_null($thisattr) && !is_null($thatattr)) { $this->setAttribute($val, $thatattr, array(), false); } elseif (!is_null($thatattr)) { switch ($val) { case 'DTSTART': $set = $thatattr < $thisattr; break; case 'DTEND': $set = $thatattr > $thisattr; break; } if ($set) { $this->setAttribute($val, $thatattr, array(), false); } } } if ($simplify) { $this->simplify(); } return true; }
continue; } try { if ($attendee->user) { $vfb = Kronolith_Freebusy::getForUser($attendee->user, $fbOpts); } elseif (is_null($attendee->addressObject->host)) { $vfb = new Horde_Icalendar_Vfreebusy(); } else { $vfb = Kronolith_FreeBusy::get($attendee->email); } } catch (Exception $e) { $notification->push(sprintf(_("Error retrieving free/busy information for %s: %s"), $attendee, $e->getMessage())); $vfb = new Horde_Icalendar_Vfreebusy(); } try { $organizer = $vfb->getAttribute('ORGANIZER'); } catch (Horde_Icalendar_Exception $e) { $organizer = null; } if (empty($organizer)) { if (strlen($attendee->name)) { $name = array('CN' => $attendee->name); } else { $name = array(); } $vfb->setAttribute('ORGANIZER', 'mailto:' . $attendee->email, $name, false); } if ($attendee->role == Kronolith::PART_REQUIRED) { $fbView->addRequiredMember($vfb); } else { $fbView->addOptionalMember($vfb);