+++ /dev/null
-<?php
-/**
- * Cached data output script.
- *
- * Parameters in (via PATH_INFO):
- * 1st parameter = The type of content to output ('css', 'fckeditor', 'js')
- * 2nd parameter = Cache ID
- *
- * Copyright 2007-2009 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 Michael Slusarz <slusarz@horde.org>
- * @package IMP
- */
-
-/* The amount of time (in minutes) to cache the generated CSS and JS files.
- * DEFAULT: 525600 = 1 year */
-$expire_time = 525600;
-
-// Need to load Horde_Util:: to give us access to Horde_Util::getPathInfo().
-require_once dirname(__FILE__) . '/lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
-$path_info = trim(Horde_Util::getPathInfo(), '/');
-if (empty($path_info)) {
- exit;
-}
-
-// 'fckeditor' output won't have a second slash, so ignore errors
-$old_error = error_reporting(0);
-list($type, $cid) = explode('/', $path_info, 2);
-error_reporting($old_error);
-
-/* Allow CSS and JS caches to be cached on the browser since there is no
- * dynamic code that will change over the course of a session. Can't cache
- * fckeditor setting as it may change. Only authenticate for 'fckeditor'
- * actions (for access to user's prefs). */
-if ($type == 'fckeditor') {
- $session_cache_limiter = 'nocache';
-} else {
- $session_cache_limiter = 'public';
- session_cache_expire($expire_time);
- @define('AUTH_HANDLER', true);
- $authentication = 'none';
-}
-$session_control = 'readonly';
-$session_timeout = 'none';
-require_once IMP_BASE . '/lib/base.php';
-
-switch ($type) {
-case 'css':
- $type = 'text/css';
- $lifetime = (empty($GLOBALS['conf']['server']['cachecssparams']['lifetime'])) ? 0 : $GLOBALS['conf']['server']['cachecssparams']['lifetime'];
- break;
-
-case 'fckeditor':
- header('Content-Type: text/javascript');
- echo 'FCKConfig.ToolbarSets["ImpToolbar"] = ' . $GLOBALS['prefs']->getValue('fckeditor_buttons') . ';' . "\n" .
- // To more closely match "normal" textarea behavior, send <BR> on
- // enter instead of <P>.
- 'FCKConfig.EnterMode = \'br\';' . "\n" .
- 'FCKConfig.ShiftEnterMode = \'p\';';
- exit;
-
-case 'js':
- $type = 'text/javascript';
- $lifetime = (empty($GLOBALS['conf']['server']['cachejsparams']['lifetime'])) ? 0 : $GLOBALS['conf']['server']['cachejsparams']['lifetime'];
- break;
-
-default:
- exit;
-}
-
-if (empty($cid)) {
- exit;
-}
-
-if (!($cache = IMP::getCache())) {
- Horde::fatal(new Horde_Exception('No cache backend available.'));
-}
-
-// If cache info doesn't exist, just output an empty body.
-header('Content-Type: ' . $type);
-$cache->output($cid, $lifetime);
break;
case 'horde_cache':
+ // Do lifetime checking here, not on cache display page.
$exists = $cache->exists($sig, empty($conf['server']['cachejsparams']['lifetime']) ? 0 : $conf['server']['cachejsparams']['lifetime']);
- $js_url = self::getCacheURL('js', $sig);
+ $js_url = Horde::getCacheUrl('js', array('cid' => $sig));
break;
}
}
/**
- * Creates a URL for cached IMP data.
- *
- * @param string $type The cache type.
- * @param string $cid The cache id.
- *
- * @return string The URL to the cache page.
- */
- static public function getCacheURL($type, $cid)
- {
- $parts = array(
- $GLOBALS['registry']->get('webroot', 'imp'),
- 'cache.php',
- $type,
- $cid
- );
- return Horde::url(implode('/', $parts));
- }
-
- /**
* Outputs the necessary style tags, honoring local configuration
* choices as to stylesheet caching.
*
break;
case 'horde_cache':
+ // Do lifetime checking here, not on cache display page.
$exists = $cache->exists($sig, empty($GLOBALS['conf']['server']['cachecssparams']['lifetime']) ? 0 : $GLOBALS['conf']['server']['cachecssparams']['lifetime']);
- $css_url = self::getCacheURL('css', $sig);
+ $css_url = Horde::getCacheUrl('css', array('cid' => $sig));
break;
}
$fck_buttons = $GLOBALS['prefs']->getValue('fckeditor_buttons');
if (!empty($fck_buttons)) {
$js_onload = array(
- 'oFCKeditor.Config.CustomConfigurationsPath = "' . IMP::getCacheURL('fckeditor', null) . '"',
+ // This needs to work even if Horde_Cache is not available,
+ // so need to use app-specific cache output.
+ 'oFCKeditor.Config.CustomConfigurationsPath = "' . Horde::getCacheUrl('app', array('app' => 'imp', 'id' => 'fckeditor')) . '"',
'oFCKeditor.ToolbarSet = "ImpToolbar"'
);
if ($mode == 'imp') {
'type' => 'boolean'
),
+ /* Cache display method. */
+ 'cacheOutput' => array(
+ 'args' => array(
+ '{urn:horde}hashHash'
+ ),
+ 'type' => '{urn:horde}hashHash'
+ ),
+
+ /* Horde_Auth_Application method. */
'authAuthenticate' => array(
'args' => array(
'userID' => 'string',
}
/**
+ * Application-specific cache output driver.
+ *
+ * @param array $params A list of params needed (USED: 'id').
+ *
+ * @return array See Horde::getCacheUrl().
+ * @throws Horde_Exception
+ */
+function _imp_cacheOutput($params)
+{
+ $GLOBALS['authentication'] = 'none';
+ require_once dirname(__FILE__) . '/base.php';
+
+ if (IMP::checkAuthentication(true)) {
+ switch ($params['id']) {
+ case 'fckeditor':
+ return array(
+ 'data' =>
+ 'FCKConfig.ToolbarSets["ImpToolbar"] = ' . $GLOBALS['prefs']->getValue('fckeditor_buttons') . ';' . "\n" .
+ // To more closely match "normal" textarea behavior,
+ // send <BR> on enter instead of <P>.
+ 'FCKConfig.EnterMode = \'br\';' . "\n" .
+ 'FCKConfig.ShiftEnterMode = \'p\';',
+ 'type' => 'text/javascript'
+ );
+ }
+ }
+
+ throw new Horde_Exception('No cache data available');
+}
+
+/**
* Tries to authenticate with the mail server and create a mail session.
*
* @param string $userID The username of the user.