return new Horde_Kolab_Storage(
$master,
+ $this->_injector->getInstance('Horde_Cache'),
$params
);
}
*/
public function __construct(
Horde_Kolab_Storage_Driver $master,
+ Horde_Cache $cache,
$params = array()
) {
$this->_master = $master;
+ $this->_cache = new Horde_Kolab_Storage_Cache($cache);
$this->_params = $params;
}
/**
+ * Return the data cache associated with this storage instance.
+ *
+ * @return Horde_Kolab_Storage_Cache The cache object
+ */
+ public function getDataCache()
+ {
+ return $this->_cache;
+ }
+
+ /**
* Return the connection driver and the folder name for the given key.
*
* @param string $key The key specifying a connection (may be a folder name)
*/
/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
* The Kolab_Cache class provides a cache for Kolab groupware objects.
*
* The Horde_Kolab_Storage_Cache singleton instance provides caching for all
class Horde_Kolab_Storage_Cache
{
/**
- * Singleton instance.
- *
- * @var array
- */
- static protected $instance;
-
- /**
* The version of the cache we loaded.
*
* @var int
/**
* Constructor.
*
- * @todo Improve the cache setup and allow different cache types.
- *
- * @throws Horde_Exception
- */
- public function __construct()
- {
- if (!isset($GLOBALS['conf']['kolab']['storage']['cache']['data']['driver'])) {
- $driver = 'file';
- $params = array('prefix' => 'kolab_cache', 'dir' => Horde::getTempDir());
- } else {
- $driver = $GLOBALS['conf']['kolab']['storage']['cache']['data']['driver'];
- if (!isset($GLOBALS['conf']['kolab']['storage']['cache']['data']['params'])) {
-
- $params = array();
- } else {
- $params = $GLOBALS['conf']['kolab']['storage']['cache']['data']['params'];
- }
- }
- $this->horde_cache = Horde_Cache::factory($driver, $params);
- }
-
- /**
- * Attempts to return a reference to a concrete Horde_Kolab_Storage_Cache
- * instance. It will only create a new instance if no
- * Horde_Kolab_Storage_Cache instance currently exists.
- *
- * @return Horde_Kolab_Storage_Cache The concrete Horde_Kolab_Storage_Cache
- * reference, or false on error.
+ * @param Horde_Cache $cache The global cache for temporary data storage.
*/
- static public function singleton()
+ public function __construct($cache)
{
- if (!isset(self::$instance)) {
- self::$instance = new self();
- }
-
- return self::$instance;
+ $this->horde_cache = $cache;
}
/**
*/
/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
* The Kolab_Data class represents a data type in a Kolab storage
* folder on the Kolab server.
*
} else {
$this->_type_key = '';
}
- $this->__wakeup();
- }
-
- /**
- * Initializes the object.
- *
- * @return NULL
- */
- public function __wakeup()
- {
- $this->_cache = &Horde_Kolab_Storage_Cache::singleton();
}
/**
/**
* Set the folder handler for this data instance.
*
- * @param Kolab_Folder &$folder The handler for the folder.
+ * @param Kolab_Folder $folder The handler for the folder.
*
* @return NULL
*/
- public function setFolder(&$folder)
+ public function setFolder($folder)
{
- $this->_folder = &$folder;
+ $this->_folder = $folder;
$this->_cache_key = $this->getCacheKey();
}
/**
+ * Set the folder handler for this data instance.
+ *
+ * @param Kolab_Folder &$folder The handler for the folder.
+ *
+ * @return NULL
+ */
+ public function setCache($cache)
+ {
+ $this->_cache = $cache;
+ }
+
+ /**
* Expire the cache.
*
* @return NULL
/* Log the action on this item in the history log. */
try {
- $GLOBALS['injector']->getInstance('Horde_History')
- ->log($app . ':' . $this->_folder->getShareId() . ':' . $object_uid,
- array('action' => $action, 'ts' => $mod_ts),
- true);
+ /* $GLOBALS['injector']->getInstance('Horde_History') */
+ /* ->log($app . ':' . $this->_folder->getShareId() . ':' . $object_uid, */
+ /* array('action' => $action, 'ts' => $mod_ts), */
+ /* true); */
} catch (Horde_Exception $e) {
}
}
*
* @return Horde_Kolab_Storage_Data The data handler.
*/
- function &getData($object_type = null, $data_version = 1)
+ public function getData($object_type = null, $data_version = 1)
{
if (empty($object_type)) {
$object_type = $this->getType();
}
$data = new Horde_Kolab_Storage_Data($type, $object_type, $data_version);
$data->setFolder($this);
+ $data->setCache($this->_storage->getDataCache());
$data->synchronize();
$this->_data[$key] = &$data;
}
}
}
- $session = &Horde_Kolab_Session_Singleton::singleton();
-
// Update email headers
- $new_headers->addHeader('From', $session->user_mail);
- $new_headers->addHeader('To', $session->user_mail);
+ $new_headers->addHeader('From', $this->_driver->getAuth());
+ $new_headers->addHeader('To', $this->_driver->getAuth());
$new_headers->addHeader('Date', date('r'));
$new_headers->addHeader('X-Kolab-Type', $handlers['XML']->getMimeType());
$new_headers->addHeader('Subject', $object['uid']);
}
/**
- * Get annotation values on IMAP server that do not support
+ * Get annotation values on IMAP servers that do not support
* METADATA.
*
* @return array|PEAR_Error The anotations of this folder.