1: <?php
2: /**
3: * Login system task for automated upgrade tasks.
4: *
5: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file LICENSE for license information (ASL). If you
8: * did not receive this file, see http://www.horde.org/licenses/apache.
9: *
10: * @author Michael J. Rubinsky <mrubinsk@horde.org>
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/apache ASL
14: * @package Turba
15: */
16: class Turba_LoginTasks_SystemTask_Upgrade extends Horde_Core_LoginTasks_SystemTask_Upgrade
17: {
18: /**
19: */
20: protected $_app = 'turba';
21:
22: /**
23: */
24: protected $_versions = array(
25: '3.0'
26: );
27:
28: /**
29: */
30: protected function _upgrade($version)
31: {
32: switch ($version) {
33: case '3.0':
34: $this->_upgradeAbookPrefs();
35: break;
36: }
37: }
38:
39: /**
40: * Upgrade to the new addressbook preferences.
41: */
42: protected function _upgradeAbookPrefs()
43: {
44: global $prefs;
45:
46: if (!$prefs->isDefault('addressbooks')) {
47: $abooks = $prefs->getValue('addressbooks');
48: if (!is_array(json_decode($abooks))) {
49: $abooks = @explode("\n", $abooks);
50: if (empty($abooks)) {
51: $abooks = array();
52: }
53:
54: return $prefs->setValue('addressbooks', json_encode($abooks));
55: }
56: }
57: }
58:
59: }
60: