From: Michael M Slusarz Date: Fri, 29 Jan 2010 05:45:30 +0000 (-0700) Subject: Add IMP_Imap::loadCacheConfig() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7735dfd29644885f8398b523dea1b6a30ec043bd;p=horde.git Add IMP_Imap::loadCacheConfig() --- diff --git a/imp/lib/Imap.php b/imp/lib/Imap.php index a36b945c7..6e9e865d1 100644 --- a/imp/lib/Imap.php +++ b/imp/lib/Imap.php @@ -191,17 +191,7 @@ class IMP_Imap /* Initialize caching. */ if (!empty($server['cache'])) { - $c = $server['cache']; - $driver = $GLOBALS['conf']['cache']['driver']; - if ($driver != 'none') { - $imap_config['cache'] = array( - 'compress' => empty($c['compress']) ? false : $c['compress'], - 'driver' => $driver, - 'driver_params' => Horde::getDriverConfig('cache', $driver), - 'lifetime' => empty($c['lifetime']) ? false : $c['lifetime'], - 'slicesize' => empty($c['slicesize']) ? false : $c['slicesize'], - ); - } + $imap_config['cache'] = $this->loadCacheConfig(is_array($server['cache']) ? $server['cache'] : array()); } try { @@ -219,6 +209,39 @@ class IMP_Imap } /** + * Prepare the config parameters necessary to use IMAP caching. + * + * @param mixed $config Either a list of cache config parameters, or a + * string containing the name of the driver with + * which to load the cache config from. + * + * @return array The configuration array. + */ + public function loadCacheConfig($config) + { + $driver = $GLOBALS['conf']['cache']['driver']; + if ($driver == 'none') { + return array(); + } + + if (is_string($config)) { + if ((($server = $this->loadServerConfig($config)) === false) || + empty($server['cache'])) { + return array(); + } + $config = $server['cache']; + } + + return array( + 'compress' => empty($config['compress']) ? false : $config['compress'], + 'driver' => $driver, + 'driver_params' => Horde::getDriverConfig('cache', $driver), + 'lifetime' => empty($config['lifetime']) ? false : $config['lifetime'], + 'slicesize' => empty($config['slicesize']) ? false : $config['slicesize'], + ); + } + + /** * Alter some IMP settings once we load/create the global object. * * @param string $protocol The protocol used to connect.