-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmethod.upgrade.php
88 lines (67 loc) · 2.57 KB
/
method.upgrade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
#-------------------------------------------------------------------------
#
# Author: Ben Malen, <[email protected]>
# Co-Maintainer: Simon Radford, <[email protected]>
# Web: www.conceptfactory.com.au
#
#-------------------------------------------------------------------------
#
# Maintainer since 2011: Jonathan Schmid, <[email protected]>
# Web: www.jonathanschmid.de
#
#-------------------------------------------------------------------------
#
# ListIt is a CMS Made Simple module that enables the web developer to create
# multiple lists throughout a site. It can be duplicated and given friendly
# names for easier client maintenance.
#
#-------------------------------------------------------------------------
if (!is_object(cmsms())) exit;
$taboptarray = array('mysql' => 'TYPE=MyISAM');
$dict = NewDataDictionary($db);
if( version_compare($oldversion, '1.2') < 0 ) {
// Instance tables
$fields = '
module_id I KEY AUTO,
module_name C(160)
';
$sqlarray = $dict->CreateTableSQL(cms_db_prefix() . 'module_listit2_instances', $fields, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
} // end of 1.1 -> 1.2 upgrade
if( version_compare($oldversion, '1.3') < 0 ) {
// Fielddef tables
$fields = '
type C(255) KEY,
originator C(255),
path C(255),
active I4,
disabled I4
';
$sqlarray = $dict->CreateTableSQL(cms_db_prefix() . 'module_listit2_fielddefs', $fields, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
// Events
$this->AddEventHandler('Core', 'ModuleInstalled', false);
$this->AddEventHandler('Core', 'ModuleUninstalled', false);
$this->AddEventHandler('Core', 'ModuleUpgraded', false);
// Preferences
$this->SetPreference('allow_autoscan', 0);
$this->SetPreference('allow_autoinstall', 1);
// Create instance from original
$mod_name = $this->GetName() . 'Original';
$duplicator = new ListIt2Duplicator();
$duplicator->SetModule($mod_name);
$duplicator->SetDestination(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $mod_name);
$duplicator->Run();
// Fix files for this spesific upgrade
$duplicator->SetSource(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'upgrade_support' . DIRECTORY_SEPARATOR . '1.3');
$duplicator->Run();
} // end of 1.2.2 -> 1.3 upgrade
if( version_compare($oldversion, '1.4-beta2') < 0 ) {
// Smarty plugins
$this->RegisterSmartyPlugin('ListIt2Loader','function', array('ListIt2Smarty', 'loader'));
} // end of 1.3 -> 1.4-beta2 upgrade
if( version_compare($oldversion, '1.4.1') < 0 ) {
// Events
$this->AddEventHandler('Core', 'ContentPostCompile', false);
} // end of 1.4 -> 1.4.1 upgrade