--- /dev/null
+<?php
+/**
+ * Utility methods to upgrade Horde 3 preference values.
+ *
+ * Copyright 2011 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>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Core
+ */
+class Horde_Core_Prefs_Storage_Upgrade
+{
+ /**
+ * Upgrades the given preferences from the old H3 way of storing
+ * serialized data.
+ * OLD method: convert charset, serialize, store.
+ * NEW method: serialize, convert charset, store.
+ *
+ * @param Horde_Prefs $prefs_ob The preferences object.
+ * @param array $names The list of names to upgrade.
+ */
+ public function upgradeSerialized($prefs_ob, array $names)
+ {
+ /* Only do upgrade for SQL driver. */
+ $storage = $prefs_ob->getStorage();
+ if (!($storage instanceof Horde_Prefs_Storage_Sql)) {
+ return;
+ }
+
+ /* Only do upgrade if charset is not UTF-8. */
+ $params = $storage->getParams();
+ $charset = isset($params['charset'])
+ ? $params['charset']
+ : 'UTF-8';
+
+ if (strcasecmp($charset, 'UTF-8') === 0) {
+ return;
+ }
+
+ foreach ($names as $name) {
+ if (!$prefs_ob->isDefault($name)) {
+ $data = $prefs_ob->getValue($name);
+
+ /* Need to convert only if unserialize fails. If it succeeds,
+ * the data has already been converted or there is no need
+ * to convert. */
+ if (@unserialize($data) === false) {
+ /* Re-convert to original charset. */
+ $data = Horde_String::convertCharset($data, 'UTF-8', $charset);
+
+ /* Unserialize. If we fail here, remove the value
+ * outright since it is invalid and can not be fixed. */
+ if (($data = @unserialize($data)) !== false) {
+ $data = Horde_String::convertCharset($data, $charset);
+
+ /* Re-save in the prefs backend in the new format. */
+ $prefs_ob->setValue($name, $data);
+ }
+ }
+ }
+ }
+ }
+
+}
<email>slusarz@horde.org</email>
<active>yes</active>
</developer>
- <date>2010-12-21</date>
- <time>23:03:16</time>
+ <date>2011-01-24</date>
+ <time>23:13:57</time>
<version>
<release>0.1.0</release>
<api>0.1.0</api>
<dir name="Storage">
<file name="Configuration.php" role="php" />
<file name="Hooks.php" role="php" />
+ <file name="Upgrade.php" role="php" />
</dir> <!-- /lib/Horde/Core/Prefs/Storage -->
<dir name="Ui">
<file name="Widgets.php" role="php" />
<install as="Horde/Core/Prefs/Cache/Session.php" name="lib/Horde/Core/Prefs/Cache/Session.php" />
<install as="Horde/Core/Prefs/Storage/Configuration.php" name="lib/Horde/Core/Prefs/Storage/Configuration.php" />
<install as="Horde/Core/Prefs/Storage/Hooks.php" name="lib/Horde/Core/Prefs/Storage/Hooks.php" />
+ <install as="Horde/Core/Prefs/Storage/Upgrade.php" name="lib/Horde/Core/Prefs/Storage/Upgrade.php" />
<install as="Horde/Core/Prefs/Ui/Widgets.php" name="lib/Horde/Core/Prefs/Ui/Widgets.php" />
<install as="Horde/Core/Share/Driver.php" name="lib/Horde/Core/Share/Driver.php" />
<install as="Horde/Core/Share/FactoryCallback.php" name="lib/Horde/Core/Share/FactoryCallback.php" />
<release>beta</release>
<api>beta</api>
</stability>
- <date>2010-12-21</date>
+ <date>2011-01-24</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
* Add cache support for themes.
--- /dev/null
+<?php
+/**
+ * Login system task for automated upgrade tasks from Hermes 1.
+ *
+ * Copyright 2011 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (BSD). If you
+ * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.horde.org/licenses/bsdl.php BSD
+ * @package Hermes
+ */
+class Hermes_LoginTasks_SystemTask_UpgradeFromHermes1 extends Horde_LoginTasks_SystemTask
+{
+ /**
+ * The interval at which to run the task.
+ *
+ * @var integer
+ */
+ public $interval = Horde_LoginTasks::ONCE;
+
+ /**
+ * Perform all functions for this task.
+ */
+ public function execute()
+ {
+ $this->_upgradePrefs();
+ }
+
+ /**
+ * Upgrade to the new preferences storage format.
+ */
+ protected function _upgradePrefs()
+ {
+ $upgrade_prefs = array(
+ 'running_timers'
+ );
+
+ $GLOBALS['injector']->getInstance('Horde_Core_Prefs_Storage_Upgrade')->upgradeSerialized($GLOBALS['prefs'], $upgrade_prefs);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Login system task for automated upgrade tasks from Horde 3.
+ *
+ * Copyright 2011 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>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Horde
+ */
+class Horde_LoginTasks_SystemTask_UpgradeFromHorde3 extends Horde_LoginTasks_SystemTask
+{
+ /**
+ * The interval at which to run the task.
+ *
+ * @var integer
+ */
+ public $interval = Horde_LoginTasks::ONCE;
+
+ /**
+ * Perform all functions for this task.
+ */
+ public function execute()
+ {
+ $this->_upgradePrefs();
+ }
+
+ /**
+ * Upgrade to the new preferences storage format.
+ */
+ protected function _upgradePrefs()
+ {
+ $upgrade_prefs = array(
+ 'identities'
+ );
+
+ $GLOBALS['injector']->getInstance('Horde_Core_Prefs_Storage_Upgrade')->upgradeSerialized($GLOBALS['prefs'], $upgrade_prefs);
+ }
+
+}
$this->_upgradeLoginTasksPrefs();
$this->_upgradeMsgDisplayPrefs();
$this->_upgradeSortPrefs();
+ $this->_upgradeStationery();
$this->_upgradeVirtualFolders();
}
}
/**
+ * Upgrade stationery preference.
+ */
+ protected function _upgradeStationery()
+ {
+ $upgrade_prefs = array(
+ 'stationery'
+ );
+
+ $GLOBALS['injector']->getInstance('Horde_Core_Prefs_Storage_Upgrade')->upgradeSerialized($GLOBALS['prefs'], $upgrade_prefs);
+ }
+
+ /**
* Upgrade IMP 4 style virtual folders.
*/
protected function _upgradeVirtualFolders()
--- /dev/null
+<?php
+/**
+ * Login system task for automated upgrade tasks from Ingo 1.
+ *
+ * Copyright 2011 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (ASL). If you
+ * did not receive this file, see http://www.horde.org/licenses/asl.php.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.horde.org/licenses/asl.php ASL
+ * @package Ingo
+ */
+class Ingo_LoginTasks_SystemTask_UpgradeFromIngo1 extends Horde_LoginTasks_SystemTask
+{
+ /**
+ * The interval at which to run the task.
+ *
+ * @var integer
+ */
+ public $interval = Horde_LoginTasks::ONCE;
+
+ /**
+ * Perform all functions for this task.
+ */
+ public function execute()
+ {
+ $this->_upgradePrefs();
+ }
+
+ /**
+ * Upgrade to the new preferences storage format.
+ */
+ protected function _upgradePrefs()
+ {
+ $upgrade_prefs = array(
+ 'rules'
+ );
+
+ $GLOBALS['injector']->getInstance('Horde_Core_Prefs_Storage_Upgrade')->upgradeSerialized($GLOBALS['prefs'], $upgrade_prefs);
+ }
+
+}