From 02d3a7d2971a6c7babea8fa7ca8abad9ef8e1176 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Thu, 15 Jul 2010 22:36:55 +0200
Subject: [PATCH] MFB: Avoid a notice when checking for locked resources. Fix
the package specific exception. Correct freebusy driver selection. Fix search
call to Kolab_Server.
---
.../Kolab_Resource/lib/Horde/Kolab/Resource.php | 2 +-
.../lib/Horde/Kolab/Resource/Exception.php | 39 +---------------------
.../lib/Horde/Kolab/Resource/Freebusy.php | 6 +++-
.../lib/Horde/Kolab/Resource/Freebusy/Kolab.php | 2 +-
framework/Kolab_Resource/package.xml | 34 +++++++++----------
5 files changed, 25 insertions(+), 58 deletions(-)
diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php
index e08377405..3f2624067 100644
--- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php
+++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource.php
@@ -495,7 +495,7 @@ class Kolab_Resource
if (is_dir($lockdir)) {
$lockfile = $lockdir . '/' . $resource . '.lock';
$counter = 0;
- while ($counter < $timeout && @file_get_contents($lockfile) == 'LOCKED') {
+ while ($counter < $timeout && file_exists($lockfile)) {
sleep(1);
$counter++;
}
diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Exception.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Exception.php
index 02c6ee957..a90dfd26c 100644
--- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Exception.php
+++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Exception.php
@@ -25,48 +25,11 @@
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Resource
*/
-class Horde_Kolab_Resource_Exception extends Horde_Exception
+class Horde_Kolab_Resource_Exception extends Exception
{
/**
* Constants to define the error type.
*/
const SYSTEM = 1;
const NO_FREEBUSY = 2;
-
- /**
- * The array of available error messages. These are connected to the error
- * codes used above and might be used to differentiate between what we show
- * the user in the frontend and what we actually log in the backend.
- *
- * @var array
- */
- protected $messages;
-
- /**
- * Exception constructor
- *
- * @param mixed $message The exception message, a PEAR_Error object, or an
- * Exception object.
- * @param mixed $code A numeric error code, or
- * an array from error_get_last().
- */
- public function __construct($message = null, $code = null)
- {
- $this->setMessages();
-
- parent::__construct($message, $code);
- }
-
- /**
- * Initialize the messages handled by this exception.
- *
- * @return NULL
- */
- protected function setMessages()
- {
- $this->messages = array(
- self::SYSTEM => _("An internal error occured."),
- self::NO_FREEBUSY => _("There is no free/busy data available."),
- );
- }
}
diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php
index 031e8badd..8ba2806b5 100644
--- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php
+++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy.php
@@ -115,7 +115,11 @@ class Horde_Kolab_Resource_Freebusy
}
if (empty($driver)) {
- $driver = $conf['freebusy']['driver'];
+ if (isset($conf['freebusy']['driver'])) {
+ $driver = $conf['freebusy']['driver'];
+ } else {
+ $driver = 'Kolab';
+ }
}
ksort($params);
diff --git a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php
index bc45cc69f..0560bc5b7 100644
--- a/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php
+++ b/framework/Kolab_Resource/lib/Horde/Kolab/Resource/Freebusy/Kolab.php
@@ -40,7 +40,7 @@ class Horde_Kolab_Resource_Freebusy_Kolab extends Horde_Kolab_Resource_Freebusy
protected function getUrl($resource)
{
$server = Horde_Kolab_Server::singleton();
- $uid = $server->uidForIdOrMailOrAlias($resource);
+ $uid = $server->uidForMailAddress($resource);
$result = $server->fetch($uid)->getServer('freebusy');
return sprintf('%s/%s.xfb', $result, $resource);
}
diff --git a/framework/Kolab_Resource/package.xml b/framework/Kolab_Resource/package.xml
index d6c58266c..2b4694af1 100644
--- a/framework/Kolab_Resource/package.xml
+++ b/framework/Kolab_Resource/package.xml
@@ -22,8 +22,8 @@