From: Michael M Slusarz Date: Wed, 14 Apr 2010 10:14:13 +0000 (-0600) Subject: Decouple Horde_History from Core. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3729c269d5cbd21e849894cac34440684b008d6f;p=horde.git Decouple Horde_History from Core. --- diff --git a/fima/lib/Driver.php b/fima/lib/Driver.php index 92018ce45..766607343 100644 --- a/fima/lib/Driver.php +++ b/fima/lib/Driver.php @@ -125,8 +125,7 @@ class Fima_Driver { } /* Log the creation of this item in the history log. */ - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':' . $accountId, array('action' => 'add'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':' . $accountId, array('action' => 'add'), true); return $accountId; } @@ -154,8 +153,7 @@ class Fima_Driver { /* Log the modification of this item in the history log. */ $account = $this->getAccount($accountId); if (!is_a($account, 'PEAR_Error')) { - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':' . $account['account_id'], array('action' => 'modify'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':' . $account['account_id'], array('action' => 'modify'), true); } return true; @@ -184,8 +182,7 @@ class Fima_Driver { /* Log the deletion of this item in the history log. */ if (!is_a($account, 'PEAR_Error')) { - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':' . $account['account_id'], array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':' . $account['account_id'], array('action' => 'delete'), true); } return true; @@ -212,8 +209,7 @@ class Fima_Driver { } /* Log the creation of this item in the history log. */ - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':' . $postingId, array('action' => 'add'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':' . $postingId, array('action' => 'add'), true); return $postingId; } @@ -242,8 +238,7 @@ class Fima_Driver { /* Log the modification of this item in the history log. */ $posting = $this->getPosting($postingId); if (!is_a($posting, 'PEAR_Error')) { - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':' . $posting['posting_id'], array('action' => 'modify'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':' . $posting['posting_id'], array('action' => 'modify'), true); } return true; @@ -268,8 +263,7 @@ class Fima_Driver { /* Log the deletion of this item in the history log. */ if (!is_a($posting, 'PEAR_Error')) { - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':' . $posting['posting_id'], array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':' . $posting['posting_id'], array('action' => 'delete'), true); } return true; @@ -296,8 +290,7 @@ class Fima_Driver { /* Log the shifting of this item in the history log. */ if (!is_a($posting, 'PEAR_Error')) { - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':' . $posting['posting_id'], array('action' => 'shift'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':' . $posting['posting_id'], array('action' => 'shift'), true); } return true; @@ -319,8 +312,7 @@ class Fima_Driver { } /* Log the deletion of this item in the history log. */ - $history = &Horde_History::singleton(); - $history->log('fima:' . $this->_ledger . ':all', array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:' . $this->_ledger . ':all', array('action' => 'delete'), true); return true; } diff --git a/fima/lib/Report.php b/fima/lib/Report.php index b66c851e7..eb60d5f38 100644 --- a/fima/lib/Report.php +++ b/fima/lib/Report.php @@ -92,8 +92,7 @@ class Fima_Report { } /* Log the execution of the report in the history log. */ - $history = &Horde_History::singleton(); - $history->log('fima:report:' . $this->_params['report_id'], array('action' => 'execute'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:report:' . $this->_params['report_id'], array('action' => 'execute'), true); return true; } diff --git a/fima/lib/ReportGraph.php b/fima/lib/ReportGraph.php index 867307d38..2ca7a540a 100644 --- a/fima/lib/ReportGraph.php +++ b/fima/lib/ReportGraph.php @@ -111,8 +111,7 @@ class Fima_ReportGraph { } /* Log the execution of the report in the history log. */ - $history = &Horde_History::singleton(); - $history->log('fima:reportgraph', array('action' => 'execute'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('fima:reportgraph', array('action' => 'execute'), true); return true; } diff --git a/framework/Auth/lib/Horde/Auth/Kolab.php b/framework/Auth/lib/Horde/Auth/Kolab.php index daf108d09..5060290f8 100644 --- a/framework/Auth/lib/Horde/Auth/Kolab.php +++ b/framework/Auth/lib/Horde/Auth/Kolab.php @@ -69,7 +69,7 @@ class Horde_Auth_Kolab extends Horde_Auth_Base /* if ($session->auth !== true && */ /* class_exists('Horde_History')) { */ -/* $history = Horde_History::singleton(); */ +/* $history = $GLOBALS['injector']->getInstance('Horde_History'); */ /* $history_identifier = "$userId@logins.kolab"; */ /* $history_log = $history->getHistory($history_identifier); */ diff --git a/framework/Core/lib/Horde/Core/Binder/History.php b/framework/Core/lib/Horde/Core/Binder/History.php new file mode 100644 index 000000000..2bc8a0934 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Binder/History.php @@ -0,0 +1,25 @@ +setLogger($injector->getInstance('Horde_Log_Logger')); + + return $ob; + } + + public function equals(Horde_Injector_Binder $binder) + { + return false; + } +} diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index 147e2273f..61941f478 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -238,6 +238,7 @@ class Horde_Registry 'Horde_Cache' => new Horde_Core_Binder_Cache(), 'Horde_Db_Adapter_Base' => new Horde_Core_Binder_Db('reader'), 'Horde_Editor' => new Horde_Core_Binder_Editor(), + 'Horde_History' => new Horde_Core_Binder_History(), 'Horde_Lock' => new Horde_Core_Binder_Lock(), 'Horde_Log_Logger' => new Horde_Core_Binder_Logger(), 'Horde_Memcache' => new Horde_Core_Binder_Memcache(), diff --git a/framework/Core/package.xml b/framework/Core/package.xml index 38d8e4f91..59fd59c75 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -70,6 +70,7 @@ Application Framework. + @@ -216,6 +217,7 @@ Application Framework. + diff --git a/framework/Group/Group.php b/framework/Group/Group.php index 2d7dd3439..4f6f7f621 100644 --- a/framework/Group/Group.php +++ b/framework/Group/Group.php @@ -239,7 +239,7 @@ class Group { } /* Log the addition of the group in the history log. */ - Horde_History::singleton()->log($this->getGUID($group), array('action' => 'add'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log($this->getGUID($group), array('action' => 'add'), true); return $result; } @@ -265,7 +265,7 @@ class Group { $this->_groupCache[$group->getName()] = &$group; /* Log the update of the group users on the history log. */ - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $guid = $this->getGUID($group); foreach ($group->getAuditLog() as $userId => $action) { $history->log($guid, array('action' => $action, 'user' => $userId), true); @@ -299,7 +299,7 @@ class Group { } unset($this->_groupCache[$group->getName()]); - Horde_History::singleton()->log($this->getGUID($group), array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log($this->getGUID($group), array('action' => 'delete'), true); return $this->_datatree->remove($group, $force); } diff --git a/framework/Group/Group/ldap.php b/framework/Group/Group/ldap.php index 4953f2f30..664539fb1 100644 --- a/framework/Group/Group/ldap.php +++ b/framework/Group/Group/ldap.php @@ -351,7 +351,7 @@ class Group_ldap extends Group { @ldap_close($this->_ds); /* Log the update of the group users on the history log. */ - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $guid = $this->getGUID($group); foreach ($group->getAuditLog() as $userId => $action) { $history->log($guid, array('action' => $action, 'user' => $userId), true); diff --git a/framework/Group/Group/sql.php b/framework/Group/Group/sql.php index b700db034..442da7b98 100644 --- a/framework/Group/Group/sql.php +++ b/framework/Group/Group/sql.php @@ -237,8 +237,7 @@ class Group_sql extends Group { } /* Log the addition of the group in the history log. */ - $history = Horde_History::singleton(); - $history->log($this->getGUID($group), array('action' => 'add'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log($this->getGUID($group), array('action' => 'add'), true); return $result; } @@ -282,7 +281,7 @@ class Group_sql extends Group { $this->_groupCache[$group->getName()] = &$group; /* Log the update of the group users on the history log. */ - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $guid = $this->getGUID($group); foreach ($group->getAuditLog() as $userId => $action) { $history->log($guid, array('action' => $action, 'user' => $userId), true); @@ -319,7 +318,7 @@ class Group_sql extends Group { } unset($this->_groupCache[$name]); - Horde_History::singleton()->log($this->getGUID($group), array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log($this->getGUID($group), array('action' => 'delete'), true); $query = 'DELETE FROM horde_groups_members WHERE group_uid = ?'; $result = $this->_write_db->query($query, array($id)); diff --git a/framework/History/lib/Horde/History.php b/framework/History/lib/Horde/History.php index 52957b074..93787fc79 100644 --- a/framework/History/lib/Horde/History.php +++ b/framework/History/lib/Horde/History.php @@ -36,13 +36,6 @@ require_once 'Horde/Autoloader.php'; abstract class Horde_History { /** - * Instance cache. - * - * @var array - */ - static protected $_instances; - - /** * Our log handler. * * @var Horde_Log_Logger @@ -51,49 +44,29 @@ abstract class Horde_History /** * Attempts to return a reference to a concrete History instance. - * It will only create a new instance if no History instance - * currently exists. - * - * This method must be invoked as: $var = History::singleton() * - * @param string $driver The driver to use. + * @param string $driver The driver to use. + * @param array $params Parameters needed for the driver. * * @return Horde_History The concrete Horde_History reference. * @throws Horde_History_Exception */ - static public function singleton($driver = null) + static public function factory($driver, $params = array()) { - global $conf; + $injector = new Horde_Injector(new Horde_Injector_TopLevel()); - if (empty($driver)) { - $driver = 'Sql'; - } + $injector->bindFactory( + __CLASS__, + __CLASS__ . '_Factory', + 'getHistory' + ); - if ($driver == 'Sql') { - if (empty($conf['sql']['phptype']) - || ($conf['sql']['phptype'] == 'none')) { - throw new Horde_History_Exception(_("The History system is disabled.")); - } - $params = $conf['sql']; - } else { - $params = array(); - } - - if (!isset(self::$_instances[$driver])) { - $injector = new Horde_Injector(new Horde_Injector_TopLevel()); - $injector->bindFactory( - __CLASS__, - __CLASS__ . '_Factory', - 'getHistory' - ); - $config = new stdClass; - $config->driver = $driver; - $config->params = $params; - $injector->setInstance(__CLASS__ . '_Config', $config); - self::$_instances[$driver] = $injector->getInstance(__CLASS__); - } + $config = new stdClass; + $config->driver = $driver; + $config->params = $params; + $injector->setInstance(__CLASS__ . '_Config', $config); - return self::$_instances[$driver]; + return $injector->getInstance(__CLASS__); } /** diff --git a/framework/History/lib/Horde/History/Factory.php b/framework/History/lib/Horde/History/Factory.php index 1051f79f1..4667d9a80 100644 --- a/framework/History/lib/Horde/History/Factory.php +++ b/framework/History/lib/Horde/History/Factory.php @@ -75,7 +75,7 @@ class Horde_History_Factory * @param Horde_Injector $injector The environment for creating the * instance. * @param array $params The db connection parameters if the - * environment does not already provide a + * environment does not already provide a * connection. * * @return Horde_History_Sql The new Horde_History_Sql instance. @@ -119,7 +119,7 @@ class Horde_History_Factory * @param Horde_Injector $injector The environment for creating the * instance. * @param array $params The db connection parameters if the - * environment does not already provide a + * environment does not already provide a * connection. * * @return Horde_History_Mock The new Horde_History_Mock instance. @@ -157,4 +157,4 @@ class Horde_History_Factory } return $db; } -} \ No newline at end of file +} diff --git a/framework/History/package.xml b/framework/History/package.xml index b39f27dd4..1e3e9b7ea 100644 --- a/framework/History/package.xml +++ b/framework/History/package.xml @@ -58,7 +58,11 @@ http://pear.php.net/dtd/package-2.0.xsd"> 1.5.4 - History + DB + pear.php.net + + + Exception pear.horde.org diff --git a/framework/History/test/Horde/History/InterfaceTest.php b/framework/History/test/Horde/History/InterfaceTest.php index 2f356fe41..b3dd551dd 100644 --- a/framework/History/test/Horde/History/InterfaceTest.php +++ b/framework/History/test/Horde/History/InterfaceTest.php @@ -177,13 +177,13 @@ EOL; return $this->_histories[$environment]; } - public function testMethodSingletonHasResultHordehistoryWhichIsAlwaysTheSame() + public function testMethodFactoryHasResultHordehistoryWhichIsAlwaysTheSame() { foreach ($this->getEnvironments() as $environment) { $history = $this->getHistory($environment); - $history1 = Horde_History::singleton($environment); + $history1 = Horde_History::factory($environment); $this->assertType('Horde_History', $history1); - $history2 = Horde_History::singleton($environment); + $history2 = Horde_History::factory($environment); $this->assertType('Horde_History', $history2); $this->assertSame($history1, $history2); } @@ -555,4 +555,4 @@ class Dummy_Db extends DB_common $e = new PEAR_Error('Error'); return $e; } -} \ No newline at end of file +} diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data.php index f2575d9d0..104b83b44 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data.php @@ -475,7 +475,7 @@ class Horde_Kolab_Storage_Data /* Log the action on this item in the history log. */ try { - Horde_History::singleton() + $GLOBALS['injector']->getInstance('Horde_History') ->log($app . ':' . $this->_folder->getShareId() . ':' . $object_uid, array('action' => $action, 'ts' => $mod_ts), true); diff --git a/imp/lib/Maillog.php b/imp/lib/Maillog.php index 0517015b1..ed1d49f0e 100644 --- a/imp/lib/Maillog.php +++ b/imp/lib/Maillog.php @@ -26,7 +26,7 @@ class IMP_Maillog */ static public function log($type, $msg_ids, $data = null) { - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); if (!is_array($msg_ids)) { $msg_ids = array($msg_ids); @@ -76,7 +76,7 @@ class IMP_Maillog */ static public function getLog($msg_id) { - return Horde_History::singleton()->getHistory(self::_getUniqueHistoryId($msg_id)); + return $GLOBALS['injector']->getInstance('Horde_History')->getHistory(self::_getUniqueHistoryId($msg_id)); } /** @@ -195,8 +195,7 @@ class IMP_Maillog } $msg_ids = array_map(array('IMP_Maillog', '_getUniqueHistoryId'), $msg_ids); - $history = Horde_History::singleton(); - $history->removeByNames($msg_ids); + $GLOBALS['injector']->getInstance('Horde_History')->removeByNames($msg_ids); } /** diff --git a/kronolith/feed/index.php b/kronolith/feed/index.php index fab022d5c..d605c66a7 100644 --- a/kronolith/feed/index.php +++ b/kronolith/feed/index.php @@ -87,7 +87,7 @@ if (isset($conf['urls']['pretty']) && $conf['urls']['pretty'] == 'rewrite') { $owner = $share->get('owner'); $identity = Horde_Prefs_Identity::factory('none', $owner); -$history = Horde_History::singleton(); +$history = $injector->getInstance('Horde_History'); $now = new Horde_Date(time()); $template = $injector->createInstance('Horde_Template'); diff --git a/kronolith/lib/Api.php b/kronolith/lib/Api.php index 6602a8243..441a4e562 100644 --- a/kronolith/lib/Api.php +++ b/kronolith/lib/Api.php @@ -328,7 +328,7 @@ class Kronolith_Api extends Horde_Registry_Api // the event's history. $created = $modified = null; try { - $log = Horde_History::singleton()->getHistory('kronolith:' . $calendar . ':' . $uid); + $log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('kronolith:' . $calendar . ':' . $uid); foreach ($log as $entry) { switch ($entry['action']) { case 'add': @@ -496,7 +496,7 @@ class Kronolith_Api extends Horde_Registry_Api throw new Horde_Exception_PermissionDenied(); } - $histories = Horde_History::singleton()->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'kronolith:' . $calendar); + $histories = $GLOBALS['injector']->getInstance('Horde_History')->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'kronolith:' . $calendar); // Strip leading kronolith:username:. return preg_replace('/^([^:]*:){2}/', '', array_keys($histories)); @@ -525,7 +525,7 @@ class Kronolith_Api extends Horde_Registry_Api throw new Horde_Exception_PermissionDenied(); } - return Horde_History::singleton()->getActionTimestamp('kronolith:' . $calendar . ':' . $uid, $action); + return $GLOBALS['injector']->getInstance('Horde_History')->getActionTimestamp('kronolith:' . $calendar . ':' . $uid, $action); } /** diff --git a/kronolith/lib/Application.php b/kronolith/lib/Application.php index 92632527c..05af8c4bb 100644 --- a/kronolith/lib/Application.php +++ b/kronolith/lib/Application.php @@ -426,7 +426,7 @@ class Kronolith_Application extends Horde_Registry_Application $result = Kronolith::getDriver()->removeUserData($user); /* Now delete history as well. */ - Horde_History::singleton()->removeByParent('kronolith:' . $user); + $GLOBALS['injector']->getInstance('Horde_History')->removeByParent('kronolith:' . $user); /* Get the user's default share */ try { diff --git a/kronolith/lib/Driver.php b/kronolith/lib/Driver.php index e4b77a9c3..f57461e57 100644 --- a/kronolith/lib/Driver.php +++ b/kronolith/lib/Driver.php @@ -318,7 +318,7 @@ class Kronolith_Driver /* Log the moving of this item in the history log. */ $uid = $event->uid; if ($uid) { - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); try { $history->log('kronolith:' . $event->calendar . ':' . $uid, array('action' => 'delete'), true); $history->log('kronolith:' . $newCalendar . ':' . $uid, array('action' => 'add'), true); diff --git a/kronolith/lib/Driver/Kolab.php b/kronolith/lib/Driver/Kolab.php index cc0ce5f7d..2855c311f 100644 --- a/kronolith/lib/Driver/Kolab.php +++ b/kronolith/lib/Driver/Kolab.php @@ -378,7 +378,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver /* Log the creation/modification of this item in the history log. */ try { - Horde_History::singleton()->log('kronolith:' . $event->calendar . ':' . $event->uid, $action, true); + $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $event->calendar . ':' . $event->uid, $action, true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } @@ -469,7 +469,7 @@ class Kronolith_Driver_Kolab extends Kronolith_Driver /* Log the deletion of this item in the history log. */ try { - Horde_History::singleton()->log('kronolith:' . $event->calendar . ':' . $event->uid, array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $event->calendar . ':' . $event->uid, array('action' => 'delete'), true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index 43428f421..eb25a98b8 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -583,7 +583,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver /* Log the modification of this item in the history log. */ if ($event->uid) { try { - Horde_History::singleton()->log('kronolith:' . $this->calendar . ':' . $event->uid, array('action' => 'modify'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $this->calendar . ':' . $event->uid, array('action' => 'modify'), true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } @@ -651,7 +651,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver /* Log the creation of this item in the history log. */ try { - Horde_History::singleton()->log('kronolith:' . $this->calendar . ':' . $uid, array('action' => 'add'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $this->calendar . ':' . $uid, array('action' => 'add'), true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } @@ -753,7 +753,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver /* Log the deletion of this item in the history log. */ if ($event->uid) { try { - Horde_History::singleton()->log('kronolith:' . $this->calendar . ':' . $event->uid, array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('kronolith:' . $this->calendar . ':' . $event->uid, array('action' => 'delete'), true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index 438d45e40..f465713b0 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -531,7 +531,7 @@ abstract class Kronolith_Event /* Get the event's history. */ $created = $modified = null; try { - $log = Horde_History::singleton()->getHistory('kronolith:' . $this->calendar . ':' . $this->uid); + $log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('kronolith:' . $this->calendar . ':' . $this->uid); foreach ($log as $entry) { switch ($entry['action']) { case 'add': diff --git a/kronolith/lib/View/Event.php b/kronolith/lib/View/Event.php index 6dca48647..3a0d1c8c2 100644 --- a/kronolith/lib/View/Event.php +++ b/kronolith/lib/View/Event.php @@ -52,7 +52,7 @@ class Kronolith_View_Event { if ($this->event->uid) { /* Get the event's history. */ try { - $log = Horde_History::singleton() + $log = $GLOBALS['injector']->getInstance('Horde_History') ->getHistory('kronolith:' . $this->event->calendar . ':' . $this->event->uid); foreach ($log as $entry) { switch ($entry['action']) { diff --git a/mnemo/data.php b/mnemo/data.php index c9e64ac64..76a7f0088 100644 --- a/mnemo/data.php +++ b/mnemo/data.php @@ -164,7 +164,7 @@ if (is_array($next_step)) { /* If we have created or modified dates for the note, set them * correctly in the history log. */ if (!empty($row['created'])) { - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); if (is_array($row['created'])) { $row['created'] = $row['created']['ts']; } @@ -172,7 +172,7 @@ if (is_array($next_step)) { array('action' => 'add', 'ts' => $row['created']), true); } if (!empty($row['modified'])) { - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); if (is_array($row['modified'])) { $row['modified'] = $row['modified']['ts']; } diff --git a/mnemo/lib/Api.php b/mnemo/lib/Api.php index 8f0717c5a..e206c9a75 100644 --- a/mnemo/lib/Api.php +++ b/mnemo/lib/Api.php @@ -127,7 +127,7 @@ function _mnemo_removeUserData($user) } /* Now delete history as well. */ - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); if (method_exists($history, 'removeByParent')) { $histories = $history->removeByParent('mnemo:' . $user); } else { @@ -252,7 +252,7 @@ function _mnemo_listBy($action, $timestamp, $notepad = null) return PEAR::raiseError(_("Permission Denied")); } - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $histories = $history->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'mnemo:' . $notepad); if (is_a($histories, 'PEAR_Error')) { return $histories; @@ -285,7 +285,7 @@ function _mnemo_getActionTimestamp($uid, $action, $notepad = null) return PEAR::raiseError(_("Permission Denied")); } - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); return $history->getActionTimestamp('mnemo:' . $notepad . ':' . $uid, $action); } diff --git a/mnemo/lib/Driver.php b/mnemo/lib/Driver.php index 614593059..4149b24b0 100644 --- a/mnemo/lib/Driver.php +++ b/mnemo/lib/Driver.php @@ -285,7 +285,7 @@ class Mnemo_Driver { } /* Get the note's history. */ - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $log = $history->getHistory('mnemo:' . $memo['memolist_id'] . ':' . $memo['uid']); if ($log && !is_a($log, 'PEAR_Error')) { foreach ($log->getData() as $entry) { diff --git a/mnemo/lib/Driver/kolab.php b/mnemo/lib/Driver/kolab.php index ea83b58a0..a2f2091b2 100644 --- a/mnemo/lib/Driver/kolab.php +++ b/mnemo/lib/Driver/kolab.php @@ -622,7 +622,7 @@ class Mnemo_Driver_kolab_wrapper_new extends Mnemo_Driver_kolab_wrapper { } /* Log the action in the history log. */ - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $history->log('mnemo:' . $this->_notepad . ':' . $this->_uniqueId($note_uid), $action, true); return $this->_uniqueId($note_uid); @@ -696,7 +696,7 @@ class Mnemo_Driver_kolab_wrapper_new extends Mnemo_Driver_kolab_wrapper { return $result; } - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $history->log('mnemo:' . $this->_notepad . ':' . $this->_uniqueId($noteId), array('action' => 'delete'), true); return $result; diff --git a/mnemo/lib/Driver/sql.php b/mnemo/lib/Driver/sql.php index 33203a070..b2ee2b62e 100644 --- a/mnemo/lib/Driver/sql.php +++ b/mnemo/lib/Driver/sql.php @@ -251,7 +251,7 @@ class Mnemo_Driver_sql extends Mnemo_Driver { } /* Log the creation of this item in the history log. */ - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $history->log('mnemo:' . $this->_notepad . ':' . $uid, array('action' => 'add'), true); return $noteId; @@ -303,7 +303,7 @@ class Mnemo_Driver_sql extends Mnemo_Driver { /* Log the modification of this item in the history log. */ $note = $this->get($noteId); if (!empty($note['uid'])) { - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $history->log('mnemo:' . $this->_notepad . ':' . $note['uid'], array('action' => 'modify'), true); } @@ -338,7 +338,7 @@ class Mnemo_Driver_sql extends Mnemo_Driver { /* Log the moving of this item in the history log. */ if (!empty($note['uid'])) { - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $history->log('mnemo:' . $this->_notepad . ':' . $note['uid'], array('action' => 'delete'), true); $history->log('mnemo:' . $newNotepad . ':' . $note['uid'], array('action' => 'add'), true); } @@ -368,7 +368,7 @@ class Mnemo_Driver_sql extends Mnemo_Driver { /* Log the deletion of this item in the history log. */ if (!empty($note['uid'])) { - $history = &Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $history->log('mnemo:' . $this->_notepad . ':' . $note['uid'], array('action' => 'delete'), true); } diff --git a/mnemo/view.php b/mnemo/view.php index eb7ce90d7..5e5b43872 100644 --- a/mnemo/view.php +++ b/mnemo/view.php @@ -64,7 +64,7 @@ $userId = Horde_Auth::getAuth(); $createdby = ''; $modifiedby = ''; if (!empty($memo['uid'])) { - $log = Horde_History::singleton()->getHistory('mnemo:' . $memolist_id . ':' . $memo['uid']); + $log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('mnemo:' . $memolist_id . ':' . $memo['uid']); if ($log && !is_a($log, 'PEAR_Error')) { foreach ($log as $entry) { switch ($entry['action']) { diff --git a/nag/lib/Api.php b/nag/lib/Api.php index ee8b3acb9..38e0a2880 100644 --- a/nag/lib/Api.php +++ b/nag/lib/Api.php @@ -475,7 +475,7 @@ class Nag_Api extends Horde_Registry_Api } // Check if our task is newer then the existing - get // the task's history. - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); $created = $modified = null; try { $log = $history->getHistory('nag:' . $tasklist . ':' . $task->uid); @@ -694,7 +694,7 @@ class Nag_Api extends Horde_Registry_Api return PEAR::raiseError(_("Permission Denied")); } - $histories = Horde_History::singleton()->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'nag:' . $tasklist); + $histories = $GLOBALS['injector']->getInstance('Horde_History')->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'nag:' . $tasklist); // Strip leading nag:username:. return preg_replace('/^([^:]*:){2}/', '', array_keys($histories)); @@ -723,7 +723,7 @@ class Nag_Api extends Horde_Registry_Api return PEAR::raiseError(_("Permission Denied")); } - return Horde_History::singleton()->getActionTimestamp('nag:' . $tasklist . ':' . $uid, $action); + return $GLOBALS['injector']->getInstance('Horde_History')->getActionTimestamp('nag:' . $tasklist . ':' . $uid, $action); } /** diff --git a/nag/lib/Application.php b/nag/lib/Application.php index 8d269335e..b8e72789f 100644 --- a/nag/lib/Application.php +++ b/nag/lib/Application.php @@ -256,7 +256,7 @@ class Nag_Application extends Horde_Registry_Application } /* Now delete history as well. */ - Horde_History::singleton()->removeByParent('nag:' . $user); + $GLOBALS['injector']->getInstance('Horde_History')->removeByParent('nag:' . $user); /* ...and finally, delete the actual share */ if (!empty($share)) { diff --git a/nag/lib/Driver.php b/nag/lib/Driver.php index 30f1b857c..8663ac4b6 100644 --- a/nag/lib/Driver.php +++ b/nag/lib/Driver.php @@ -226,7 +226,7 @@ class Nag_Driver $task = $this->get($taskId); /* Log the creation of this item in the history log. */ - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); try { $history->log('nag:' . $this->_tasklist . ':' . $uid, array('action' => 'add'), true); } catch (Exception $e) { @@ -337,7 +337,7 @@ class Nag_Driver /* Log the moving of this item in the history log. */ if (!empty($task->uid)) { - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); try { $history->log('nag:' . $task->tasklist . ':' . $task->uid, array('action' => 'delete'), true); } catch (Exception $e) { @@ -368,7 +368,7 @@ class Nag_Driver /* Log the modification of this item in the history log. */ if (!empty($task->uid)) { try { - Horde_History::singleton()->log('nag:' . $log_tasklist . ':' . $task->uid, array('action' => 'modify'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('nag:' . $log_tasklist . ':' . $task->uid, array('action' => 'modify'), true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } @@ -381,7 +381,7 @@ class Nag_Driver $attributes['ts'] = 0; } try { - Horde_History::singleton()->log('nag:' . $log_tasklist . ':' . $task->uid, $attributes, true); + $GLOBALS['injector']->getInstance('Horde_History')->log('nag:' . $log_tasklist . ':' . $task->uid, $attributes, true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } @@ -417,7 +417,7 @@ class Nag_Driver /* Log the deletion of this item in the history log. */ if (!empty($task->uid)) { try { - Horde_History::singleton()->log('nag:' . $this->_tasklist . ':' . $task->uid, array('action' => 'delete'), true); + $GLOBALS['injector']->getInstance('Horde_History')->log('nag:' . $this->_tasklist . ':' . $task->uid, array('action' => 'delete'), true); } catch (Exception $e) { Horde::logMessage($e, 'ERR'); } diff --git a/nag/lib/Task.php b/nag/lib/Task.php index 3527412a9..ebc4a4411 100644 --- a/nag/lib/Task.php +++ b/nag/lib/Task.php @@ -853,7 +853,7 @@ class Nag_Task { /* Get the task's history. */ $created = $modified = null; try { - $log = Horde_History::singleton()->getHistory('nag:' . $this->tasklist . ':' . $this->uid); + $log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('nag:' . $this->tasklist . ':' . $this->uid); foreach ($log as $entry) { switch ($entry['action']) { case 'add': diff --git a/nag/scripts/upgrades/create_missing_add_histories_sql.php b/nag/scripts/upgrades/create_missing_add_histories_sql.php index 95c7a190d..ed1f62f97 100755 --- a/nag/scripts/upgrades/create_missing_add_histories_sql.php +++ b/nag/scripts/upgrades/create_missing_add_histories_sql.php @@ -13,7 +13,7 @@ require_once dirname(__FILE__) . '/../../lib/Application.php'; Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true)); -$history = Horde_History::singleton(); +$history = $GLOBALS['injector']->getInstance('Horde_History'); // Run through every tasklist. $tasklists = $nag_shares->listAllShares(); diff --git a/nag/view.php b/nag/view.php index 17f82fa16..7bc48e708 100644 --- a/nag/view.php +++ b/nag/view.php @@ -62,7 +62,7 @@ $createdby = ''; $modifiedby = ''; if (!empty($task->uid)) { try { - $log = Horde_History::singleton()->getHistory('nag:' . $tasklist_id . ':' . $task->uid); + $log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('nag:' . $tasklist_id . ':' . $task->uid); foreach ($log as $entry) { switch ($entry['action']) { case 'add': diff --git a/turba/lib/Api.php b/turba/lib/Api.php index d66d3bd73..b62dce21c 100644 --- a/turba/lib/Api.php +++ b/turba/lib/Api.php @@ -509,7 +509,7 @@ class Turba_Api extends Horde_Registry_Api } $uids = array(); - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); foreach ($sources as $source) { if (empty($source) || !isset($cfgSources[$source])) { throw new Horde_Exception(sprintf(_("Invalid address book: %s"), $source)); @@ -569,7 +569,7 @@ class Turba_Api extends Horde_Registry_Api } $last = 0; - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); foreach ($sources as $source) { if (empty($source) || !isset($cfgSources[$source])) { throw new Horde_Exception(sprintf(_("Invalid address book: %s"), $source)); diff --git a/turba/lib/Driver.php b/turba/lib/Driver.php index 18443e000..f74248e2f 100644 --- a/turba/lib/Driver.php +++ b/turba/lib/Driver.php @@ -784,7 +784,7 @@ class Turba_Driver /* Log the creation of this item in the history log. */ try { - Horde_History::singleton() + $GLOBALS['injector']->getInstance('Horde_History') ->log('turba:' . $this->getName() . ':' . $uid, array('action' => 'add'), true); } catch (Exception $e) { @@ -841,7 +841,7 @@ class Turba_Driver /* Log the deletion of this item in the history log. */ if ($object->getValue('__uid')) { try { - Horde_History::singleton()->log($object->getGuid(), + $GLOBALS['injector']->getInstance('Horde_History')->log($object->getGuid(), array('action' => 'delete'), true); } catch (Exception $e) { @@ -888,7 +888,7 @@ class Turba_Driver /* Log the modification of this item in the history log. */ if ($object->getValue('__uid')) { try { - Horde_History::singleton()->log($object->getGuid(), + $GLOBALS['injector']->getInstance('Horde_History')->log($object->getGuid(), array('action' => 'modify'), true); } catch (Exception $e) { diff --git a/turba/lib/Driver/Sql.php b/turba/lib/Driver/Sql.php index 93ee6152e..6f1425690 100644 --- a/turba/lib/Driver/Sql.php +++ b/turba/lib/Driver/Sql.php @@ -362,7 +362,7 @@ class Turba_Driver_Sql extends Turba_Driver } /* Update Horde_History */ - $history = Horde_History::singleton(); + $history = $GLOBALS['injector']->getInstance('Horde_History'); try { while ($ids->fetchInto($row)) { // This is slightly hackish, but it saves us from having to diff --git a/turba/lib/View/Browse.php b/turba/lib/View/Browse.php index 71831c4ee..bf8e98370 100644 --- a/turba/lib/View/Browse.php +++ b/turba/lib/View/Browse.php @@ -219,7 +219,7 @@ class Turba_View_Browse { * because otherwise the delete log would be after the * add log. */ try { - Horde_History::singleton() + $GLOBALS['injector']->getInstance('Horde_History') ->log('turba:' . $targetDriver->getName() . ':' . $objAttributes['__uid'], array('action' => 'add'), true); diff --git a/turba/lib/View/Contact.php b/turba/lib/View/Contact.php index c3c0aaa39..2dcf22cef 100644 --- a/turba/lib/View/Contact.php +++ b/turba/lib/View/Contact.php @@ -47,7 +47,7 @@ class Turba_View_Contact { /* Get the contact's history. */ if ($this->contact->getValue('__uid')) { try { - $log = Horde_History::singleton()->getHistory($this->contact->getGuid()); + $log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory($this->contact->getGuid()); foreach ($log as $entry) { switch ($entry['action']) { case 'add':