Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Horde_Core_History to work around chicken/egg problem.
Bug: 13105
- Loading branch information
Showing
3 changed files
with
169 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters