$driver->open($this->_vars->url);
$ical = $driver->getRemoteCalendar(false);
$result->success = true;
- $name = $ical->getAttribute('X-WR-CALNAME');
- if (!($name instanceof PEAR_Error)) {
+ try {
+ $name = $ical->getAttribute('X-WR-CALNAME');
$result->name = $name;
- }
- $desc = $ical->getAttribute('X-WR-CALDESC');
- if (!($desc instanceof PEAR_Error)) {
+ } catch (Horde_Icalendar_Exception $e) {}
+ try {
+ $desc = $ical->getAttribute('X-WR-CALDESC');
$result->desc = $desc;
- }
+ } catch (Horde_Icalendar_Exception $e) {}
} catch (Exception $e) {
if ($e->getCode() == 401) {
$result->auth = true;
// Need to ensure that the original recurring event is
// added before any of the instance exceptions. Easiest way
// to do that is just add all the recurrence-id entries last
- $recurrenceId = $content->getAttribute('RECURRENCE-ID');
- if (!($recurrenceId instanceof PEAR_Error)) {
+ try {
+ $recurrenceId = $content->getAttribute('RECURRENCE-ID');
$recurrences[] = $content;
- } else {
+ } catch (Horde_Icalendar_Exception $e) {
$ids[] = $this->_addiCalEvent($content, $kronolith_driver);
}
}
/* Catch RECURRENCE-ID attributes which mark single recurrence
* instances. */
- $recurrence_id = $component->getAttribute('RECURRENCE-ID');
- if (is_int($recurrence_id) &&
- is_string($uid = $component->getAttribute('UID')) &&
- is_int($seq = $component->getAttribute('SEQUENCE'))) {
- $exceptions[$uid][$seq] = $recurrence_id;
- }
+ try {
+ $recurrence_id = $component->getAttribute('RECURRENCE-ID');
+ if (is_int($recurrence_id) &&
+ is_string($uid = $component->getAttribute('UID')) &&
+ is_int($seq = $component->getAttribute('SEQUENCE'))) {
+ $exceptions[$uid][$seq] = $recurrence_id;
+ }
+ } catch (Horde_Icalendar_Exception $e) {}
/* Ignore events out of the period. */
if (
*
* @param boolean $cache Whether to return data from the session cache.
*
- * @return Horde_Icalendar The calendar data, or an error on failure.
+ * @return Horde_Icalendar The calendar data.
* @throws Kronolith_Exception
*/
public function getRemoteCalendar($cache = true)
$data = $response->getBody();
$ical = new Horde_Icalendar();
- $result = $ical->parsevCalendar($data);
+ try {
+ $result = $ical->parsevCalendar($data);
+ } catch (Horde_Icalendar_Exception $e) {
+ if ($cache) {
+ $cacheOb->set($signature, serialize($e->getMessage()));
+ }
+ throw new Kronolith_Exception($e);
+ }
+
if ($cache) {
$cacheOb->set($signature, serialize($ical));
}
- if ($result instanceof PEAR_Error) {
- throw new Kronolith_Exception($result);
- }
return $ical;
}