From b62da86243b037d9db864106d583b1244809d5d6 Mon Sep 17 00:00:00 2001
From: Gunnar Wrobel
Date: Wed, 24 Mar 2010 11:40:45 +0100
Subject: [PATCH] Move the triggering functionality into a decorator.
---
.../lib/Horde/Kolab/Storage/Folder.php | 97 +++++++-
.../lib/Horde/Kolab/Storage/Folder/Base.php | 210 ++--------------
.../Horde/Kolab/Storage/Folder/Decorator/Base.php | 154 ++++++++++++
.../Kolab/Storage/Folder/Decorator/Trigger.php | 267 +++++++++++++++++++++
framework/Kolab_Storage/package.xml | 6 +
5 files changed, 543 insertions(+), 191 deletions(-)
create mode 100644 framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Base.php
create mode 100644 framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Trigger.php
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php
index b44d930f4..7b7ecf352 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php
@@ -6,7 +6,9 @@
*
* @category Kolab
* @package Kolab_Storage
+ * @author Stuart Binge
* @author Gunnar Wrobel
+ * @author Thomas Jarosch
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
@@ -19,11 +21,98 @@
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
- * @author Stuart Binge
- * @author Gunnar Wrobel
- * @author Thomas Jarosch
- * @package Kolab_Storage
+ * @category Kolab
+ * @package Kolab_Storage
+ * @author Stuart Binge
+ * @author Gunnar Wrobel
+ * @author Thomas Jarosch
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
*/
interface Horde_Kolab_Storage_Folder
{
+ /**
+ * Saves the folder.
+ *
+ * @param array $attributes An array of folder attributes. You can
+ * set any attribute but there are a few
+ * special ones like 'type', 'default',
+ * 'owner' and 'desc'.
+ *
+ * @return NULL
+ */
+ public function save($attributes = null);
+
+ /**
+ * Delete the specified message from this folder.
+ *
+ * @param string $id IMAP id of the message to be deleted.
+ * @param boolean $trigger Should the folder be triggered?
+ *
+ * @return NULL
+ */
+ public function deleteMessage($id, $trigger = true);
+
+ /**
+ * Move the specified message to the specified folder.
+ *
+ * @param string $id IMAP id of the message to be moved.
+ * @param string $folder Name of the receiving folder.
+ *
+ * @return boolean True if successful.
+ */
+ public function moveMessage($id, $folder);
+
+ /**
+ * Move the specified message to the specified share.
+ *
+ * @param string $id IMAP id of the message to be moved.
+ * @param string $share Name of the receiving share.
+ *
+ * @return NULL
+ */
+ public function moveMessageToShare($id, $share);
+
+ /**
+ * Save an object in this folder.
+ *
+ * @param array $object The array that holds the data of the object.
+ * @param int $data_version The format handler version.
+ * @param string $object_type The type of the kolab object.
+ * @param string $id The IMAP id of the old object if it
+ * existed before
+ * @param array $old_object The array that holds the current data of the
+ * object.
+ *
+ * @return boolean True on success.
+ */
+ public function saveObject(&$object, $data_version, $object_type, $id = null,
+ &$old_object = null);
+
+ /**
+ * Return the IMAP ACL of this folder.
+ *
+ * @return array An array with IMAP ACL.
+ */
+ public function getACL();
+
+ /**
+ * Set the ACL of this folder.
+ *
+ * @param $user The user for whom the ACL should be set.
+ * @param $acl The new ACL value.
+ *
+ * @return NULL
+ */
+ public function setACL($user, $acl);
+
+ /**
+ * Delete the ACL for a user on this folder.
+ *
+ * @param $user The user for whom the ACL should be deleted.
+ *
+ * @return NULL
+ */
+ public function deleteACL($user);
+
}
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php
index a8b2dc564..4bab4ac78 100644
--- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php
@@ -276,9 +276,9 @@ implements Horde_Kolab_Storage_Folder
* special ones like 'type', 'default',
* 'owner' and 'desc'.
*
- * @return boolean|PEAR_Error True on success.
+ * @return NULL
*/
- function save($attributes = null)
+ public function save($attributes = null)
{
if (!isset($this->name)) {
/* A new folder needs to be created */
@@ -348,21 +348,6 @@ implements Horde_Kolab_Storage_Folder
$result = $this->_connection->rename($this->name, $this->new_name);
$this->_storage->removeFromCache($this);
- /**
- * Trigger the old folder on an empty IMAP folder.
- */
- try {
- $this->_connection->create($this->name);
- $this->_connection->setAnnotation(self::ANNOT_FOLDER_TYPE,
- $this->_type,
- $this->name);
- $this->trigger($this->name);
- $this->_connection->delete($this->name);
- } catch (Exception $e) {
- Horde::logMessage(sprintf('Failed handling the dummy folder: %s!',
- $e->getMessage()), 'ERR');
- }
-
$this->name = $this->new_name;
$this->new_name = null;
$this->_title = null;
@@ -434,13 +419,6 @@ implements Horde_Kolab_Storage_Folder
$this->_storage->addToCache($this);
- try {
- $this->trigger();
- } catch (Horde_Kolab_Storage_Exception $e) {
- Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
- $this->name, $e->getMessage()), 'ERR');
- }
-
return true;
}
@@ -497,6 +475,8 @@ implements Horde_Kolab_Storage_Folder
* @param string $name Name of the folder that should be triggered.
*
* @return string|PEAR_Error The subpath of this folder.
+ *
+ * @todo Is this is only needed by triggering? Can it be removed/moved?
*/
public function getSubpath($name = null)
{
@@ -693,24 +673,13 @@ implements Horde_Kolab_Storage_Folder
* @param string $id IMAP id of the message to be deleted.
* @param boolean $trigger Should the folder be triggered?
*
- * @return boolean|PEAR_Error True if successful.
+ * @return NULL
*/
- function deleteMessage($id, $trigger = true)
+ public function deleteMessage($id, $trigger = true)
{
// Select folder
$this->_connection->deleteMessages($this->name, $id);
$this->_connection->expunge($this->name);
-
- if ($trigger) {
- try {
- $result = $this->trigger();
- } catch (Horde_Kolab_Storage_Exception $e) {
- Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
- $this->name, $result->getMessage()), 'ERR');
- }
- }
-
- return true;
}
/**
@@ -719,33 +688,13 @@ implements Horde_Kolab_Storage_Folder
* @param string $id IMAP id of the message to be moved.
* @param string $folder Name of the receiving folder.
*
- * @return boolean|PEAR_Error True if successful.
+ * @return boolean True if successful.
*/
- function moveMessage($id, $folder)
+ public function moveMessage($id, $folder)
{
- // Select folder
- $result = $this->_connection->select($this->name);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
-
- $result = $this->_connection->moveMessage($this->name, $id, $folder);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
-
- $result = $this->_connection->expunge($this->name);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
-
- $result = $this->trigger();
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
- $this->name, $result->getMessage()), 'ERR');
- }
-
- return true;
+ $this->_connection->select($this->name);
+ $this->_connection->moveMessage($this->name, $id, $folder);
+ $this->_connection->expunge($this->name);
}
/**
@@ -754,24 +703,14 @@ implements Horde_Kolab_Storage_Folder
* @param string $id IMAP id of the message to be moved.
* @param string $share Name of the receiving share.
*
- * @return boolean|PEAR_Error True if successful.
+ * @return NULL
*/
- function moveMessageToShare($id, $share)
+ public function moveMessageToShare($id, $share)
{
$folder = $this->_storage->getByShare($share, $this->getType());
- if (is_a($folder, 'PEAR_Error')) {
- return $folder;
- }
$folder->tainted = true;
$success = $this->moveMessage($id, $folder->name);
-
- $result = $this->trigger();
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
- $this->name, $result->getMessage()), 'ERR');
- }
- return $success;
}
/**
@@ -810,7 +749,7 @@ implements Horde_Kolab_Storage_Folder
*
* @return boolean True on success.
*/
- function saveObject(&$object, $data_version, $object_type, $id = null,
+ public function saveObject(&$object, $data_version, $object_type, $id = null,
&$old_object = null)
{
// Select folder
@@ -980,15 +919,6 @@ implements Horde_Kolab_Storage_Folder
if ($id != null) {
$this->_connection->expunge($this->name);
}
-
- try {
- $this->trigger();
- } catch (Horde_Kolab_Storage_Exception $e) {
- Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
- $this->name, $result->getMessage()), 'ERR');
- }
-
- return true;
}
/**
@@ -1101,84 +1031,6 @@ implements Horde_Kolab_Storage_Folder
}
/**
- * Triggers any required updates after changes within the
- * folder. This is currently only required for handling free/busy
- * information with Kolab.
- *
- * @param string $name Name of the folder that should be triggered.
- *
- * @return boolean|PEAR_Error True if successfull.
- */
- function trigger($name = null)
- {
- $type = $this->getType();
- if (is_a($type, 'PEAR_Error')) {
- return $type;
- }
-
- $owner = $this->getOwner();
- if (is_a($owner, 'PEAR_Error')) {
- return $owner;
- }
-
- $subpath = $this->getSubpath($name);
- if (is_a($subpath, 'PEAR_Error')) {
- return $subpath;
- }
-
- switch($type) {
- case 'event':
- $session = &Horde_Kolab_Session_Singleton::singleton();
- $url = sprintf('%s/trigger/%s/%s.pfb',
- $session->freebusy_server, $owner, $subpath);
- break;
- default:
- return true;
- }
-
- $result = $this->triggerUrl($url);
- if (is_a($result, 'PEAR_Error')) {
- return PEAR::raiseError(sprintf(_("Failed triggering folder %s. Error was: %s"),
- $this->name, $result->getMessage()));
- }
- return $result;
- }
-
- /**
- * Triggers a URL.
- *
- * @param string $url The URL to be triggered.
- *
- * @return boolean|PEAR_Error True if successfull.
- */
- function triggerUrl($url)
- {
- global $conf;
-
- if (!empty($conf['kolab']['no_triggering'])) {
- return true;
- }
-
- $options['method'] = 'GET';
- $options['timeout'] = 5;
- $options['allowRedirects'] = true;
-
- if (isset($conf['http']['proxy']) && !empty($conf['http']['proxy']['proxy_host'])) {
- $options = array_merge($options, $conf['http']['proxy']);
- }
-
- require_once 'HTTP/Request.php';
- $http = new HTTP_Request($url, $options);
- $http->setBasicAuth(Horde_Auth::getAuth(), Horde_Auth::getCredential('password'));
- @$http->sendRequest();
- if ($http->getResponseCode() != 200) {
- return PEAR::raiseError(sprintf(_("Unable to trigger URL %s. Response: %s"),
- $url, $http->getResponseCode()));
- }
- return true;
- }
-
- /**
* Checks to see if a user has a given permission.
*
* @param string $userid The userid of the user.
@@ -1254,24 +1106,24 @@ implements Horde_Kolab_Storage_Folder
}
/**
- * Return the IMAP ACL of this folder.
+ * Return the ACL of this folder.
*
- * @return array|PEAR_Error An array with IMAP ACL.
+ * @return array An array with ACL.
*/
- function getACL()
+ public function getACL()
{
return $this->_connection->getACL($this->name);
}
/**
- * Set the IMAP ACL of this folder.
+ * Set the ACL of this folder.
*
* @param $user The user for whom the ACL should be set.
* @param $acl The new ACL value.
*
- * @return boolean|PEAR_Error True on success.
+ * @return NULL
*/
- function setACL($user, $acl)
+ public function setACL($user, $acl)
{
$this->_connection->setACL($this->name, $user, $acl);
@@ -1279,24 +1131,16 @@ implements Horde_Kolab_Storage_Folder
/** Refresh the cache after changing the permissions */
$this->_perms->getPerm();
}
-
- $result = $this->trigger();
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
- $this->name, $result->getMessage()), 'ERR');
- }
-
- return $result;
}
/**
- * Delete the IMAP ACL for a user on this folder.
+ * Delete the ACL for a user on this folder.
*
* @param $user The user for whom the ACL should be deleted.
*
- * @return boolean|PEAR_Error True on success.
+ * @return NULL
*/
- function deleteACL($user)
+ public function deleteACL($user)
{
global $conf;
@@ -1305,14 +1149,6 @@ implements Horde_Kolab_Storage_Folder
}
$this->_connection->deleteACL($this->name, $user);
-
- $result = $this->trigger();
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
- $this->name, $result->getMessage()), 'ERR');
- }
-
- return $iresult;
}
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Base.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Base.php
new file mode 100644
index 000000000..11640f408
--- /dev/null
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Base.php
@@ -0,0 +1,154 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * The basic decorator definition for Kolab folders.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Gunnar Wrobel
+ * @package Kolab_Storage
+ */
+class Horde_Kolab_Storage_Folder_Decorator_Base
+implements Horde_Kolab_Storage_Folder
+{
+
+ /**
+ * The decorated folder.
+ *
+ * @var Horde_Kolab_Storage_Folder
+ */
+ protected $_folder;
+
+ /**
+ * Constructor
+ *
+ * @param Horde_Kolab_Storage_Folder $folder The folder to be decorated.
+ */
+ public function __construct(Horde_Kolab_Storage_Folder $folder)
+ {
+ $this->_folder = $folder;
+ }
+
+ /**
+ * Saves the folder.
+ *
+ * @param array $attributes An array of folder attributes. You can
+ * set any attribute but there are a few
+ * special ones like 'type', 'default',
+ * 'owner' and 'desc'.
+ *
+ * @return NULL
+ */
+ public function save($attributes = null)
+ {
+ $this->_folder->save($attributes);
+ }
+
+ /**
+ * Delete the specified message from this folder.
+ *
+ * @param string $id IMAP id of the message to be deleted.
+ * @param boolean $trigger Should the folder be triggered?
+ *
+ * @return NULL
+ */
+ public function deleteMessage($id, $trigger = true)
+ {
+ $this->_folder->deleteMessage($id, $trigger);
+ }
+
+ /**
+ * Move the specified message to the specified folder.
+ *
+ * @param string $id IMAP id of the message to be moved.
+ * @param string $folder Name of the receiving folder.
+ *
+ * @return boolean True if successful.
+ */
+ public function moveMessage($id, $folder)
+ {
+ $this->_folder->moveMessage($id, $folder);
+ }
+
+ /**
+ * Move the specified message to the specified share.
+ *
+ * @param string $id IMAP id of the message to be moved.
+ * @param string $share Name of the receiving share.
+ *
+ * @return NULL
+ */
+ public function moveMessageToShare($id, $share)
+ {
+ $this->_folder->moveMessageToShare($id, $share);
+ }
+
+ /**
+ * Save an object in this folder.
+ *
+ * @param array $object The array that holds the data of the object.
+ * @param int $data_version The format handler version.
+ * @param string $object_type The type of the kolab object.
+ * @param string $id The IMAP id of the old object if it
+ * existed before
+ * @param array $old_object The array that holds the current data of the
+ * object.
+ *
+ * @return boolean True on success.
+ */
+ public function saveObject(&$object, $data_version, $object_type, $id = null,
+ &$old_object = null)
+ {
+ $this->_folder->saveObject($object, $data_version, $object_type, $id, $old_object = null);
+ }
+
+ /**
+ * Return the IMAP ACL of this folder.
+ *
+ * @return array An array with IMAP ACL.
+ */
+ public function getACL()
+ {
+ return $this->_folder->getACL();
+ }
+
+ /**
+ * Set the ACL of this folder.
+ *
+ * @param $user The user for whom the ACL should be set.
+ * @param $acl The new ACL value.
+ *
+ * @return NULL
+ */
+ public function setACL($user, $acl)
+ {
+ $this->_folder->setACL($user, $acl);
+ }
+
+ /**
+ * Delete the ACL for a user on this folder.
+ *
+ * @param $user The user for whom the ACL should be deleted.
+ *
+ * @return NULL
+ */
+ public function deleteACL($user)
+ {
+ $this->_folder->deleteACL($user);
+ }
+
+}
diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Trigger.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Trigger.php
new file mode 100644
index 000000000..fa345fb97
--- /dev/null
+++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Decorator/Trigger.php
@@ -0,0 +1,267 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * This decorator triggers a URL following certain actions on the folder.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Gunnar Wrobel
+ * @package Kolab_Storage
+ */
+class Horde_Kolab_Storage_Folder_Decorator_Trigger
+extends Horde_Kolab_Storage_Folder_Decorator_Base
+{
+ /**
+ * Saves the folder.
+ *
+ * @param array $attributes An array of folder attributes. You can
+ * set any attribute but there are a few
+ * special ones like 'type', 'default',
+ * 'owner' and 'desc'.
+ *
+ * @return NULL
+ */
+ public function save($attributes = null)
+ {
+ /**
+ * Trigger the old folder on an empty IMAP folder after renaming a folder!
+ */
+ try {
+ $this->_connection->create($this->name);
+ $this->_connection->setAnnotation(self::ANNOT_FOLDER_TYPE,
+ $this->_type,
+ $this->name);
+ $this->trigger($this->name);
+ $this->_connection->delete($this->name);
+ } catch (Exception $e) {
+ Horde::logMessage(sprintf('Failed handling the dummy folder: %s!',
+ $e->getMessage()), 'ERR');
+ }
+
+
+ /** Finally trigger the folder after saving.*/
+ try {
+ $this->trigger();
+ } catch (Horde_Kolab_Storage_Exception $e) {
+ Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
+ $this->name, $e->getMessage()), 'ERR');
+ }
+
+
+ }
+
+ /**
+ * Delete the specified message from this folder.
+ *
+ * @param string $id IMAP id of the message to be deleted.
+ * @param boolean $trigger Should the folder be triggered?
+ *
+ * @return NULL
+ */
+ public function deleteMessage($id, $trigger = true)
+ {
+ $this->_folder->deleteMessage($id, $trigger);
+
+ if ($trigger) {
+ try {
+ $result = $this->trigger();
+ } catch (Horde_Kolab_Storage_Exception $e) {
+ Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
+ $this->name, $result->getMessage()), 'ERR');
+ }
+ }
+ }
+
+ /**
+ * Move the specified message to the specified folder.
+ *
+ * @param string $id IMAP id of the message to be moved.
+ * @param string $folder Name of the receiving folder.
+ *
+ * @return boolean True if successful.
+ */
+ public function moveMessage($id, $folder)
+ {
+ $this->_folder->moveMessage($id, $folder);
+
+ //@todo: shouldn't we trigger both folders here?
+
+ $result = $this->trigger();
+ if (is_a($result, 'PEAR_Error')) {
+ Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
+ $this->name, $result->getMessage()), 'ERR');
+ }
+
+ return true;
+ }
+
+ /**
+ * Move the specified message to the specified share.
+ *
+ * @param string $id IMAP id of the message to be moved.
+ * @param string $share Name of the receiving share.
+ *
+ * @return NULL
+ */
+ public function moveMessageToShare($id, $share)
+ {
+ $this->_folder->moveMessageToShare($id, $share);
+
+ //@todo: shouldn't we trigger both folders here?
+ $result = $this->trigger();
+ if (is_a($result, 'PEAR_Error')) {
+ Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
+ $this->name, $result->getMessage()), 'ERR');
+ }
+ return $success;
+ }
+
+ /**
+ * Save an object in this folder.
+ *
+ * @param array $object The array that holds the data of the object.
+ * @param int $data_version The format handler version.
+ * @param string $object_type The type of the kolab object.
+ * @param string $id The IMAP id of the old object if it
+ * existed before
+ * @param array $old_object The array that holds the current data of the
+ * object.
+ *
+ * @return boolean True on success.
+ */
+ public function saveObject(&$object, $data_version, $object_type, $id = null,
+ &$old_object = null)
+ {
+ $this->_folder->saveObject($object, $data_version, $object_type, $id, $old_object);
+ try {
+ $this->trigger();
+ } catch (Horde_Kolab_Storage_Exception $e) {
+ Horde::logMessage(sprintf('Failed triggering folder %s! Error was: %s',
+ $this->name, $result->getMessage()), 'ERR');
+ }
+
+ return true;
+ }
+
+ /**
+ * Set the ACL of this folder.
+ *
+ * @param $user The user for whom the ACL should be set.
+ * @param $acl The new ACL value.
+ *
+ * @return NULL
+ */
+ public function setACL($user, $acl)
+ {
+ $this->_folder->setACL($user, $acl);
+
+ $this->trigger();
+ }
+
+ /**
+ * Delete the ACL for a user on this folder.
+ *
+ * @param $user The user for whom the ACL should be deleted.
+ *
+ * @return NULL
+ */
+ public function deleteACL($user)
+ {
+ $this->_folder->deleteACL($user);
+
+ $this->trigger();
+ }
+
+ /**
+ * Triggers any required updates after changes within the
+ * folder. This is currently only required for handling free/busy
+ * information with Kolab.
+ *
+ * @param string $name Name of the folder that should be triggered.
+ *
+ * @return boolean|PEAR_Error True if successfull.
+ */
+ private function trigger($name = null)
+ {
+ $type = $this->getType();
+ if (is_a($type, 'PEAR_Error')) {
+ return $type;
+ }
+
+ $owner = $this->getOwner();
+ if (is_a($owner, 'PEAR_Error')) {
+ return $owner;
+ }
+
+ $subpath = $this->getSubpath($name);
+ if (is_a($subpath, 'PEAR_Error')) {
+ return $subpath;
+ }
+
+ switch($type) {
+ case 'event':
+ $session = &Horde_Kolab_Session_Singleton::singleton();
+ $url = sprintf('%s/trigger/%s/%s.pfb',
+ $session->freebusy_server, $owner, $subpath);
+ break;
+ default:
+ return true;
+ }
+
+ $result = $this->triggerUrl($url);
+ if (is_a($result, 'PEAR_Error')) {
+ return PEAR::raiseError(sprintf(_("Failed triggering folder %s. Error was: %s"),
+ $this->name, $result->getMessage()));
+ }
+ return $result;
+ }
+
+ /**
+ * Triggers a URL.
+ *
+ * @param string $url The URL to be triggered.
+ *
+ * @return boolean|PEAR_Error True if successfull.
+ */
+ private function triggerUrl($url)
+ {
+ global $conf;
+
+ if (!empty($conf['kolab']['no_triggering'])) {
+ return true;
+ }
+
+ $options['method'] = 'GET';
+ $options['timeout'] = 5;
+ $options['allowRedirects'] = true;
+
+ if (isset($conf['http']['proxy']) && !empty($conf['http']['proxy']['proxy_host'])) {
+ $options = array_merge($options, $conf['http']['proxy']);
+ }
+
+ require_once 'HTTP/Request.php';
+ $http = new HTTP_Request($url, $options);
+ $http->setBasicAuth(Horde_Auth::getAuth(), Horde_Auth::getCredential('password'));
+ @$http->sendRequest();
+ if ($http->getResponseCode() != 200) {
+ return PEAR::raiseError(sprintf(_("Unable to trigger URL %s. Response: %s"),
+ $url, $http->getResponseCode()));
+ }
+ return true;
+ }
+
+}
diff --git a/framework/Kolab_Storage/package.xml b/framework/Kolab_Storage/package.xml
index d0df99788..86297d753 100644
--- a/framework/Kolab_Storage/package.xml
+++ b/framework/Kolab_Storage/package.xml
@@ -83,6 +83,10 @@
+
+
+
+
@@ -206,6 +210,8 @@
+
+
--
2.11.0