1: <?php
2: /**
3: * This class allows upgrading portal config preferences from H3 -> H4 format.
4: *
5: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (LGPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
9: *
10: * @author Michael Slusarz <slusarz@horde.org>
11: * @category Horde
12: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
13: * @package Core
14: */
15: class Horde_Core_Block_Upgrade
16: {
17: /**
18: * Upgrades the given preference to H4 format.
19: *
20: * @param string $name The preference name.
21: */
22: public function upgrade($name)
23: {
24: global $prefs;
25:
26: $layout = @unserialize($prefs->getValue($name));
27: if (is_array($layout)) {
28: $upgrade = false;
29: } else {
30: $layout = array();
31: $upgrade = true;
32: }
33:
34: foreach (array_keys($layout) as $key) {
35: foreach (array_keys($layout[$key]) as $key2) {
36: if (isset($layout[$key][$key2]['params']['type'])) {
37: $layout[$key][$key2]['params']['type2'] = $layout[$key][$key2]['app'] . '_Block_' . Horde_String::ucfirst($layout[$key][$key2]['params']['type']);
38: unset($layout[$key][$key2]['params']['type']);
39:
40: $upgrade = true;
41: }
42: }
43: }
44:
45: if ($upgrade) {
46: $prefs->setValue($name, serialize($layout));
47: }
48: }
49:
50: }
51: