protected $_params = array();
/**
+ * Logger.
+ *
+ * @var Horde_Log_Logger
+ */
+ protected $_logger;
+
+ /**
* Construct a new Horde_Cache object.
*
- * @param array $params Parameter array.
+ * @param array $params Parameter array:
+ * <pre>
+ * 'lifetime' - (integer) Lifetime of data, in seconds.
+ * DEFAULT: 86400 seconds
+ * 'logger' - (Horde_Log_Logger) Log object to use for log/debug messages.
+ * </pre>
*/
public function __construct($params = array())
{
: 86400;
}
+ if (isset($params['logger'])) {
+ $this->_logger = $params['logger'];
+ unset($params['logger']);
+ }
+
$this->_params = $params;
}
try {
$this->_connect();
} catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($e, 'ERR');
+ }
return;
}
$result = $this->_write_db->query($query, $values);
if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($result, 'ERR');
+ }
}
}
try {
$this->_connect();
} catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($e, 'ERR');
+ }
return false;
}
$result = $this->_db->getOne($query, $values);
if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($result, 'ERR');
+ }
return false;
} elseif (is_null($result)) {
/* No rows were found - cache miss */
- Horde::logMessage(sprintf('Cache miss: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+ if ($this->_logger) {
+ $this->_logger->log(sprintf('Cache miss: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+ }
return false;
}
if ($this->_mc) {
$this->_mc->set($key, $result);
}
- Horde::logMessage(sprintf('Cache hit: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+
+ if ($this->_logger) {
+ $this->_logger->log(sprintf('Cache hit: %s (Id %s newer than %d)', $okey, $key, $maxage), 'DEBUG');
+ }
return $result;
}
try {
$this->_connect();
} catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($e, 'ERR');
+ }
return false;
}
? 0
: $this->_getLifetime($lifetime) + $timestamp;
- Horde::logMessage(sprintf('Cache set: %s (Id %s set at %d expires at %d)', $okey, $key, $timestamp, $expiration), 'DEBUG');
+ if ($this->_logger) {
+ $this->_logger->log(sprintf('Cache set: %s (Id %s set at %d expires at %d)', $okey, $key, $timestamp, $expiration), 'DEBUG');
+ }
// Remove any old cache data and prevent duplicate keys
$query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE cache_id=?';
$result = $this->_write_db->query($query, $values);
if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($result, 'ERR');
+ }
return false;
}
try {
$this->_connect();
} catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($e, 'ERR');
+ }
return false;
}
$result = $this->_db->getRow($query, $values);
if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($result, 'ERR');
+ }
return false;
}
$timestamp = time();
if (empty($result)) {
- Horde::logMessage(sprintf('Cache exists() miss: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+ if ($this->_logger) {
+ $this->_logger->log(sprintf('Cache exists() miss: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+ }
return false;
}
- Horde::logMessage(sprintf('Cache exists() hit: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+
+ if ($this->_logger) {
+ $this->_logger->log(sprintf('Cache exists() hit: %s (Id %s newer than %d)', $okey, $key, $timestamp), 'DEBUG');
+ }
return true;
}
try {
$this->_connect();
} catch (Horde_Exception $e) {
- Horde::logMessage($e, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($e, 'ERR');
+ }
return false;
}
$result = $this->_write_db->query($query, $values);
if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, 'ERR');
+ if ($this->_logger) {
+ $this->_logger->log($result, 'ERR');
+ }
return false;
}
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.</notes>
+ <notes>* Removed dependency on Horde Core.
+ * Initial Horde 4 package.</notes>
<contents>
<dir name="/">
<dir name="data">
<extension>
<name>memcache</name>
</extension>
+ <package>
+ <name>Log</name>
+ <channel>pear.horde.org</channel>
+ </package>
</optional>
</dependencies>
<phprelease>
}
}
+ $params['logger'] = $injector->getInstance('Horde_Log_Logger');
+
return Horde_Cache::factory($driver, $params);
}
{
return empty($GLOBALS['conf']['memcache']['enabled'])
? null
- : new Horde_Memcache($GLOBALS['conf']['memcache']);
+ : new Horde_Memcache(array_merge($GLOBALS['conf']['memcache'], array('logger' => $injector->getInstance('Horde_Log_Logger'))));
}
public function equals(Horde_Injector_Binder $binder)
$notify->addType('status', 'horde.*', 'Horde_Core_Notification_Status');
$notify->addDecorator(new Horde_Notification_Handler_Decorator_Alarm(Horde_Alarm::factory(), Horde_Auth::getAuth()));
- $notify->addDecorator(new Horde_Notification_Handler_Decorator_Hordelog());
+ $notify->addDecorator(new Horde_Core_Notification_Hordelog());
return $notify;
}
{
public function create(Horde_Injector $injector)
{
- $perm_driver = $perm_params = null;
+ $perm_params = array(
+ 'cache' => $injector->getInstance('Horde_Cache'),
+ 'logger' => $injector->getInstance('Horde_Logger')
+ );
- if (empty($GLOBALS['conf']['perms']['driver'])) {
- $perm_driver = empty($GLOBALS['conf']['datatree']['driver'])
- ? null
- : 'datatree';
- } else {
- $perm_driver = $GLOBALS['conf']['perms']['driver'];
- $perm_params = Horde::getDriverConfig('perms', $perm_driver);
+ $perm_driver = empty($GLOBALS['conf']['perms']['driver'])
+ ? (empty($GLOBALS['conf']['datatree']['driver']) ? null : 'datatree')
+ : $GLOBALS['conf']['perms']['driver'];
+
+ switch (strtolower($perm_driver)) {
+ case 'datatree':
+ $driver = $GLOBALS['conf']['datatree']['driver'];
+ $perm_params['datatree'] = DataTree::singleton(
+ $driver,
+ array_merge(Horde::getDriverConfig('datatree', $driver), array('group' => 'horde.perms'))
+ );
+ break;
+
+ case 'sql':
+ // TODO
+ break;
}
return Horde_Perms::factory($perm_driver, $perm_params);
public function create(Horde_Injector $injector)
{
return new Horde_Template(array(
- 'cacheob' => $injector->getInstance('Horde_Cache')
+ 'cacheob' => $injector->getInstance('Horde_Cache'),
+ 'logger' => $injector->getInstance('Horde_Log_Logger')
));
}
--- /dev/null
+<?php
+/**
+ * The Hordelog Decorator logs error events via Horde::logMessage().
+ *
+ * Copyright 2001-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 Jan Schneider <jan@horde.org>
+ * @package Horde_Core
+ */
+class Horde_Core_Notification_Hordelog
+extends Horde_Notification_Handler_Decorator_Base
+{
+ /**
+ * Event is being added to the Horde message stack.
+ *
+ * @param Horde_Notification_Event $event Event object.
+ * @param array $options Additional options (see
+ * Horde_Notification_Handler for
+ * details).
+ */
+ public function push(Horde_Notification_Event $event, $options)
+ {
+ Horde::logMessage($event->message, 'DEBUG');
+ }
+
+}
<file name="Logger.php" role="php" />
</dir> <!-- /lib/Horde/Core/Log -->
<dir name="Notification">
+ <file name="Hordelog.php" role="php" />
<file name="Status.php" role="php" />
</dir> <!-- /lib/Horde/Core/Notification -->
</dir> <!-- /lib/Horde/Core -->
<install name="lib/Horde/Core/Binder/Template.php" as="Horde/Core/Binder/Template.php" />
<install name="lib/Horde/Core/Factory/KolabServer.php" as="Horde/Core/Factory/KolabServer.php" />
<install name="lib/Horde/Core/Log/Logger.php" as="Horde/Core/Log/Logger.php" />
+ <install name="lib/Horde/Core/Notification/Hordelog.php" as="Horde/Core/Notification/Hordelog.php" />
<install name="lib/Horde/Core/Notification/Status.php" as="Horde/Core/Notification/Status.php" />
<install name="lib/Horde/ErrorHandler.php" as="Horde/ErrorHandler.php" />
<install name="lib/Horde/Exception/HookNotSet.php" as="Horde/Exception/HookNotSet.php" />
protected $_noexist = array();
/**
+ * Logger instance.
+ *
+ * @var Horde_Log_Logger
+ */
+ protected $_logger;
+
+ /**
* Constructor.
*
* @param array $params TODO
$this->_params['prefix'] = (empty($this->_params['prefix'])) ? 'horde' : $this->_params['prefix'];
$this->_large = !empty($this->_params['large_items']);
+ if (isset($params['logger'])) {
+ $this->_logger = $params['logger'];
+ }
+
$this->__wakeup();
}
// Force consistent hashing
ini_set('memcache.hash_strategy', 'consistent');
- Horde::logMessage('Connected to the following memcache servers:' . implode($servers, ', '), 'DEBUG');
+ if ($this->_logger) {
+ $this->_logger->log('Connected to the following memcache servers:' . implode($servers, ', '), 'DEBUG');
+ }
}
/**
+++ /dev/null
-<?php
-/**
- * The Hordelog Decorator logs error events via Horde::logMessage().
- *
- * Copyright 2001-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 Jan Schneider <jan@horde.org>
- * @package Horde_Notification
- */
-class Horde_Notification_Handler_Decorator_Hordelog
-extends Horde_Notification_Handler_Decorator_Base
-{
- /**
- * Event is being added to the Horde message stack.
- *
- * @param Horde_Notification_Event $event Event object.
- * @param array $options Additional options (see
- * Horde_Notification_Handler for
- * details).
- */
- public function push(Horde_Notification_Event $event, $options)
- {
- Horde::logMessage($event->message, 'DEBUG');
- }
-
-}
<dir name="Decorator">
<file name="Alarm.php" role="php" />
<file name="Base.php" role="php" />
- <file name="Hordelog.php" role="php" />
<file name="Log.php" role="php" />
</dir> <!-- /lib/Horde/Notification/Handler/Decorator -->
</dir> <!-- /lib/Horde/Notification/Handler -->
<dir name="Handler">
<dir name="Decorator">
<file name="AlarmTest.php" role="test" />
- <file name="HordelogTest.php" role="test" />
<file name="LogTest.php" role="test" />
</dir> <!-- /test/Horde/Notification/Class/Notification/Handler/Decorator -->
</dir> <!-- /test/Horde/Notification/Class/Notification/Handler -->
<install name="lib/Horde/Notification/Event/Status.php" as="Horde/Notification/Event/Status.php" />
<install name="lib/Horde/Notification/Handler/Decorator/Alarm.php" as="Horde/Notification/Handler/Decorator/Alarm.php" />
<install name="lib/Horde/Notification/Handler/Decorator/Base.php" as="Horde/Notification/Handler/Decorator/Base.php" />
- <install name="lib/Horde/Notification/Handler/Decorator/Hordelog.php" as="Horde/Notification/Handler/Decorator/Hordelog.php" />
<install name="lib/Horde/Notification/Handler/Decorator/Log.php" as="Horde/Notification/Handler/Decorator/Log.php" />
<install name="lib/Horde/Notification/Listener/Audio.php" as="Horde/Notification/Listener/Audio.php" />
<install name="lib/Horde/Notification/Listener/Javascript.php" as="Horde/Notification/Listener/Javascript.php" />
<install name="test/Horde/Notification/Class/Notification/HandlerTest.php" as="Horde/Notification/Class/Notification/HandlerTest.php" />
<install name="test/Horde/Notification/Class/Notification/EventTest.php" as="Horde/Notification/Class/Notification/EventTest.php" />
<install name="test/Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/AlarmTest.php" />
- <install name="test/Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/HordelogTest.php" />
<install name="test/Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" as="Horde/Notification/Class/Notification/Handler/Decorator/LogTest.php" />
<install name="test/Horde/Notification/Class/Notification/ListenerTest.php" as="Horde/Notification/Class/Notification/ListenerTest.php" />
<install name="test/Horde/Notification/Class/Notification/Listener/AudioTest.php" as="Horde/Notification/Class/Notification/Listener/AudioTest.php" />
const ROOT = -1;
/**
+ * Cache object.
+ *
+ * @var Horde_Cache
+ */
+ protected $_cache;
+
+ /**
+ * Logger.
+ *
+ * @var Horde_Log_Logger
+ */
+ protected $_logger;
+
+ /**
* Caches information about application permissions.
*
* @var array
}
/**
+ * Constructor.
+ *
+ * @param array $params Configuration parameters:
+ * <pre>
+ * 'cache' - (Horde_Cache) The object to use to cache perms.
+ * 'logger' - (Horde_Log_Logger) A logger object.
+ * </pre>
+ *
+ * @throws Horde_Perms_Exception
+ */
+ public function __construct($params = array())
+ {
+ if (isset($params['cache'])) {
+ $this->_cache = $params['cache'];
+ }
+
+ if (isset($params['logger'])) {
+ $this->_logger = $params['logger'];
+ }
+ }
+
+ /**
* Returns the available permissions for a given level.
*
* @param string $name The permission's name.
try {
$permission = $this->getPermission($permission);
} catch (Horde_Perms_Exception $e) {
- Horde::logMessage($e, 'DEBUG');
+ if ($this->_logger) {
+ $this->_logger->log($e, 'DEBUG');
+ }
return false;
}
}
protected $_datatree;
/**
- * Pointer to a Horde_Cache instance.
- *
- * @var Horde_Cache
- */
- protected $_cache;
-
- /**
* Incrementing version number if cached classes change.
*
* @var integer
/**
* Constructor.
*
- * @throws Horde_Exception
+ * @param array $params Configuration parameters (in addition to base
+ * Horde_Perms parameters):
+ * <pre>
+ * 'datatree' - (DataTree) A datatree object. [REQUIRED]
+ * </pre>
+ *
+ * @throws Horde_Perms_Exception
*/
- public function __construct()
+ public function __construct($params = array())
{
- global $conf;
-
- if (empty($conf['datatree']['driver'])) {
- throw new Horde_Exception('You must configure a DataTree backend.');
+ if (empty($params['datatree'])) {
+ throw new Horde_Perms_Exception('You must configure a DataTree backend.');
}
- $driver = $conf['datatree']['driver'];
- $this->_datatree = DataTree::singleton($driver,
- array_merge(Horde::getDriverConfig('datatree', $driver),
- array('group' => 'horde.perms')));
+ $this->_datatree = $params['datatree'];
- $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
+ parent::__construct($params);
}
/**
protected $_write_db;
/**
- * Pointer to a Horde_Cache instance
- *
- * @var Horde_Cache
- */
- protected $_cache;
-
- /**
* Incrementing version number if cached classes change.
*
* @var integer
/**
* Constructor.
+ *
+ * @param array $params Configuration parameters (in addition to base
+ * Horde_Perms parameters):
+ * <pre>
+ * NONE (TODO - pass in SQL object)
+ * </pre>
+ *
+ * @throws Horde_Perms_Exception
*/
- public function __construct()
+ public function __construct($params = array())
{
- $this->_cache = $GLOBALS['injector']->getInstance('Horde_Cache');
+ parent::__construct($params);
}
/**
protected $_cache;
/**
+ * Logger.
+ *
+ * @var Horde_Log_Logger
+ */
+ protected $_logger;
+
+ /**
* Option values.
*
* @var array
* <pre>
* 'basepath' - (string) The directory where templates are read from.
* 'cacheob' - (Horde_Cache) A caching object used to cache the output.
+ * 'logger' - (Horde_Log_Logger) A logger object.
* </pre>
*/
- public function __construct($basepath = null)
+ public function __construct($params = array())
{
if (isset($params['basepath'])) {
$this->_basepath = $params['basepath'];
if (isset($params['cacheob'])) {
$this->_cache = $params['cacheob'];
}
+
+ if (isset($params['logger'])) {
+ $this->_logger = $params['logger'];
+ }
}
/**
$this->_parse();
if ($this->_cache &&
isset($cacheid) &&
- !$this->_cache->set($cacheid, $this->_template)) {
- Horde::logMessage(sprintf(_("Could not save the compiled template file '%s'."), $file), 'ERR');
+ !$this->_cache->set($cacheid, $this->_template) &&
+ $this->_logger) {
+ $this->_logger->log(sprintf('Could not save the compiled template file "%s".', $file), 'ERR');
}
}
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial Horde 4 package.
+ <notes>* Remove dependency on Horde_Core.
+ * Initial Horde 4 package.
</notes>
<contents>
<dir name="/">