Skip to content

Commit

Permalink
Add Horde_Core_History to work around chicken/egg problem.
Browse files Browse the repository at this point in the history
Bug: 13105
  • Loading branch information
mrubinsk committed May 15, 2014
1 parent fa9f3da commit a599f7e
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 3 deletions.
3 changes: 2 additions & 1 deletion framework/Core/lib/Horde/Core/Factory/History.php
Expand Up @@ -24,7 +24,7 @@
class Horde_Core_Factory_History extends Horde_Core_Factory_Injector
{
/**
* @return Horde_History
* @return Horde_Core_History
* @throws Horde_Exception
*/
public function create(Horde_Injector $injector)
Expand Down Expand Up @@ -64,6 +64,7 @@ public function create(Horde_Injector $injector)
$history = new Horde_History_Null($user);
} elseif ($cache = $injector->getInstance('Horde_Cache')) {
$history->setCache($cache);
$history = new Horde_Core_History($history);
}

return $history;
Expand Down
163 changes: 163 additions & 0 deletions framework/Core/lib/Horde/Core/History.php
@@ -0,0 +1,163 @@
<?php
/**
* Copyright 2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @category Horde
* @copyright 2014 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Core
*/
/**
* Decorate the base Horde_History class to allow the username to be reset
* if the authenticated status changes after the history object has been
* initialized.
*
* Copyright 2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Core
*
* @todo For H6 we can replace type hints for Horde_History with
* Horde_Core_History so we can get rid of all the extra methods here
* and simply use __call().
*/
class Horde_Core_History extends Horde_History
{
/**
* @var Horde_History
*/
protected $_history;

/**
* Const'r
*
* @param Horde_History $history The actual history object.
*/
public function __construct(Horde_History $history)
{
$this->_history = $history;
}

/**
* @see Horde_History::setLogger()
*/
public function setLogger(Horde_Log_Logger $logger)
{
$this->_history->setLogger($logger);
}

/**
* Set Cache object.
*
* @param Horde_Cache $cache The cache instance.
*/
public function setCache(Horde_Cache $cache)
{
$this->_history->setCache($cache);
}

/**
* @see Horde_History::log()
*
* Overridden to ensure we have the current auth username.
*/
public function log($guid, array $attributes = array(), $replaceAction = false)
{
if (empty($attributes['who'])) {
$attributes['who'] = $GLOBALS['registry']->getAuth()
? $GLOBALS['registry']->getAuth()
: '';
}
$this->_history->log($guid, $attributes, $replaceAction);
}

/**
* @see Horde_History::getHistory()
*/
public function getHistory($guid)
{
return $this->_history->getHistory($guid);
}

/**
* @see Horde_History::getByTimestamp()
*/
public function getByTimestamp($cmp, $ts, array $filters = array(), $parent = null)
{
return $this->_history->getByTimestamp($cmp, $ts, $filters, $parent);
}

/**
* @see Horde_History:getByModSeq()
*/
public function getByModSeq($start, $end, $filters = array(), $parent = null)
{
return $this->_history->getByModSeq($start, $end, $filters, $parent);
}

/**
* @see Horde_History::removeByNames()
*/
public function removeByNames(array $names)
{
$this->_history->removeByNames($names);
}

/**
* @see Horde_History::getActionTimestamp()
*/
public function getActionTimestamp($guid, $action)
{
return $this->_history->getActionTimestamp($guid, $action);
}

/**
* @see Horde_History::removeByParent()
*/
public function removeByParent($parent)
{
$this->_history->removeByParent($parent);
}

/**
* @see Horde_History::getActionModSeq()
*/
public function getActionModSeq($guid, $action)
{
return $this->_history->getActionModSeq($guid, $action);
}

/**
* @see Horde_History::getLatestEntry()
*/
public function getLatestEntry($guid, $use_ts = false)
{
return $this->_history->getLatestEntry($guid, $use_ts);
}

protected function _log(Horde_History_Log $history, array $attributes, $replaceAction = false)
{
// NOOP. Here to satisfy the Horde_History API since we must extend the
// Horde_History class to satisfy any typehints.
}

public function _getByTimestamp($cmp, $ts, array $filters = array(), $parent = null)
{
// NOOP
}

public function _getHistory($guid)
{
// NOOP
}

}
6 changes: 4 additions & 2 deletions framework/Core/package.xml
Expand Up @@ -28,7 +28,7 @@
<email>mrubinsk@horde.org</email>
<active>yes</active>
</developer>
<date>2014-05-14</date>
<date>2014-05-15</date>
<version>
<release>2.12.0beta1</release>
<api>2.12.0</api>
Expand Down Expand Up @@ -619,6 +619,7 @@
<file name="Browser.php" role="php" />
<file name="Bundle.php" role="php" />
<file name="Cli.php" role="php" />
<file name="History.php" role="php" />
<file name="Hooks.php" role="php" />
<file name="HordeMap.php" role="php" />
<file name="LoginTasks.php" role="php" />
Expand Down Expand Up @@ -1716,6 +1717,7 @@
<install as="Horde/Core/Browser.php" name="lib/Horde/Core/Browser.php" />
<install as="Horde/Core/Bundle.php" name="lib/Horde/Core/Bundle.php" />
<install as="Horde/Core/Cli.php" name="lib/Horde/Core/Cli.php" />
<install as="Horde/Core/History.php" name="lib/Horde/Core/History.php" />
<install as="Horde/Core/Hooks.php" name="lib/Horde/Core/Hooks.php" />
<install as="Horde/Core/HordeMap.php" name="lib/Horde/Core/HordeMap.php" />
<install as="Horde/Core/LoginTasks.php" name="lib/Horde/Core/LoginTasks.php" />
Expand Down Expand Up @@ -3385,7 +3387,7 @@
<stability>
<release>beta</release>
<api>beta</api></stability>
<date>2014-05-14</date>
<date>2014-05-15</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Support LMTP servers when sending mail.
Expand Down

0 comments on commit a599f7e

Please sign in to comment.