1: <?php
2: /**
3: * Login system task for automated upgrade tasks.
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 Horde
14: */
15: class Horde_LoginTasks_SystemTask_Upgrade extends Horde_Core_LoginTasks_SystemTask_Upgrade
16: {
17: /**
18: */
19: protected $_versions = array(
20: '4.0',
21: '4.0.12'
22: );
23:
24: /**
25: */
26: protected function _upgrade($version)
27: {
28: switch ($version) {
29: case '4.0':
30: $this->_upgradePortal();
31: $this->_upgradePrefs();
32: break;
33:
34: case '4.0.12':
35: $this->_replaceWeatherBlock();
36: break;
37: }
38: }
39:
40: /**
41: * Upgrade portal preferences.
42: */
43: protected function _upgradePortal()
44: {
45: $bu = new Horde_Core_Block_Upgrade();
46: $bu->upgrade('portal_layout');
47: }
48:
49: /**
50: * Upgrade to the new preferences storage format.
51: */
52: protected function _upgradePrefs()
53: {
54: $upgrade_prefs = array(
55: 'identities'
56: );
57:
58: $GLOBALS['injector']->getInstance('Horde_Core_Prefs_Storage_Upgrade')->upgradeSerialized($GLOBALS['prefs'], $upgrade_prefs);
59: }
60:
61: protected function _replaceWeatherBlock()
62: {
63: $col = $GLOBALS['injector']
64: ->getInstance('Horde_Core_Factory_BlockCollection')
65: ->create(array('horde'));
66: $m = $col->getLayoutManager();
67: $layout = $col->getLayout();
68: foreach ($layout as $r => $cur_row) {
69: foreach ($cur_row as $c => &$cur_col) {
70: if (isset($cur_col['app']) &&
71: $cur_col['app'] == 'horde' &&
72: is_array($cur_col['params']) &&
73: Horde_String::lower($cur_col['params']['type2']) == 'horde_block_weatherdotcom') {
74:
75: $m->handle('removeBlock', $r, $c);
76: }
77: }
78: }
79: if ($m->updated()) {
80: $GLOBALS['prefs']->setValue('portal_layout', $m->serialize());
81: }
82: }
83:
84: }
85: