when re-using an existing Ical driver.
Don't re-use the HTTP client if opening another calendar.
Fix caching of error messages.
Remote calendar user names are not encrypted.
}
/**
+ * Sets all configuration parameters for this driver.
+ *
+ * @param string $params A parameters hash.
+ */
+ public function setParams($params)
+ {
+ $this->_params = $params;
+ }
+
+ /**
* Selects a calendar as the currently opened calendar.
*
* @param string $calendar A calendar identifier.
private $_client;
/**
+ * Selects a calendar as the currently opened calendar.
+ *
+ * @param string $calendar A calendar identifier.
+ */
+ public function open($calendar)
+ {
+ parent::open($calendar);
+ $this->_client = null;
+ }
+
+ /**
* Returns the background color of the current calendar.
*
* @return string The calendar color.
} catch (Horde_Http_Exception $e) {
Horde::logMessage($e, 'INFO');
if ($cache) {
- $cacheOb->set($signature, $e->getMessage());
+ $cacheOb->set($signature, serialize($e->getMessage()));
}
throw new Kronolith_Exception($e);
}
$url, $response->code), 'INFO');
$error = sprintf(_("Could not open %s."), $url);
if ($cache) {
- $cacheOb->set($signature, $error);
+ $cacheOb->set($signature, serialize($error));
}
throw new Kronolith_Exception($error, $response->code);
}
$ical = new Horde_iCalendar();
$result = $ical->parsevCalendar($data);
if ($cache) {
- $cacheOb->set($signature, $ical);
+ $cacheOb->set($signature, serialize($ical));
}
if ($result instanceof PEAR_Error) {
throw new Kronolith_Exception($result);
}
/* Remote Calendars. */
- $driver = self::getDriver('Ical');
foreach ($GLOBALS['display_remote_calendars'] as $url) {
- $driver->open($url);
- foreach (self::getRemoteParams($url) as $param => $value) {
- $driver->setParam($param, $value);
- }
+ $driver = self::getDriver('Ical', $url);
$events = $driver->listEvents($startDate, $endDate, $showRecurrence);
self::mergeEvents($results, $events);
}
}
if (!isset(self::$_instances[$driver])) {
- $params = array();
switch ($driver) {
case 'Sql':
case 'Resource':
break;
case 'Ical':
- $params = self::getRemoteParams($calendar);
- /* Check for HTTP proxy configuration */
- if (!empty($GLOBALS['conf']['http']['proxy']['proxy_host'])) {
- $params['proxy'] = $GLOBALS['conf']['http']['proxy'];
- }
+ $params = array();
break;
case 'Horde':
if (!is_null($calendar)) {
self::$_instances[$driver]->open($calendar);
+ /* Remote calendar parameters are per calendar. */
+ if ($driver == 'Ical') {
+ self::$_instances[$driver]->setParams(self::getRemoteParams($calendar));
+ }
}
return self::$_instances[$driver];
$user = isset($cal['user']) ? $cal['user'] : '';
$password = isset($cal['password']) ? $cal['password'] : '';
$key = $GLOBALS['registry']->getAuthCredential('password');
- if ($key && $user) {
+ if ($key && $password) {
$secret = $GLOBALS['injector']->getInstance('Horde_Secret');
- $user = $secret->read($key, base64_decode($user));
$password = $secret->read($key, base64_decode($password));
}
if (!empty($user)) {