forked from PayBas/RecentTopics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease_2_0_0.php
170 lines (157 loc) · 4.48 KB
/
release_2_0_0.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
*
* @package Recent Topics Extension
* @copyright (c) 2015 PayBas
* @license GNU General Public License, version 2 (GPL-2.0)
*
* Based on the original NV Recent Topics by Joas Schilling (nickvergessen)
*
*/
namespace paybas\recenttopics\migrations;
class release_2_0_0 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return isset($this->config['rt_version']) && version_compare($this->config['rt_version'], '2.0.0', '>=');
}
public function update_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'forums' => array(
'forum_recent_topics' => array('TINT:1', 1),
),
),
);
}
public function revert_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'forums' => array(
'forum_recent_topics',
),
),
);
}
public function update_data()
{
return array(
// Remove old config if it exists
array('if', array(
(isset($this->config['recenttopics'])),
array('config.remove', array('recenttopics')),
)),
array('if', array(
(isset($this->config['rt_mod_version'])),
array('config.remove', array('rt_mod_version')),
)),
array('if', array(
(isset($this->config['rt_version'])),
array('config.remove', array('rt_version')),
)),
array('if', array(
(isset($this->config['rt_number'])),
array('config.remove', array('rt_number')),
)),
array('if', array(
(isset($this->config['rt_page_number'])),
array('config.remove', array('rt_page_number')),
)),
array('if', array(
(isset($this->config['rt_anti_topics'])),
array('config.remove', array('rt_anti_topics')),
)),
array('if', array(
(isset($this->config['rt_parents'])),
array('config.remove', array('rt_parents')),
)),
array('if', array(
(isset($this->config['rt_index'])),
array('config.remove', array('rt_index')),
)),
// Add new config vars
array('config.add', array('rt_version', '2.0.0')),
array('config.add', array('rt_number', 5)),
array('config.add', array('rt_page_number', 0)),
array('config.add', array('rt_anti_topics', 0)),
array('config.add', array('rt_parents', 1)),
array('config.add', array('rt_unreadonly', 0)),
array('config.add', array('rt_index', 1)),
// Remove old (v1) modules
array('if', array(
array('module.exists', array('acp', 'RECENT_TOPICS_MOD', array(
'module_basename' => 'recenttopics',
'modes' => array('overview'),
),
)),
array('module.remove', array('acp', 'RECENT_TOPICS_MOD', array(
'module_basename' => 'recenttopics',
'modes' => array('overview'),
),
)),
)),
array('if', array(
array('module.exists', array('acp', 'ACP_CAT_DOT_MODS', 'RECENT_TOPICS_MOD')),
array('module.remove', array('acp', 'ACP_CAT_DOT_MODS', 'RECENT_TOPICS_MOD')),
)),
// Remove early beta modules
array('if', array(
array('module.exists', array('acp', 'RECENT_TOPICS_EXT', array(
'module_basename' => '\paybas\recenttopics\acp\recenttopics_module',
'modes' => array('recenttopics_config'),
),
)),
array('module.remove', array('acp', 'RECENT_TOPICS_EXT', array(
'module_basename' => '\paybas\recenttopics\acp\recenttopics_module',
'modes' => array('recenttopics_config'),
),
)),
)),
array('if', array(
array('module.exists', array('acp', 'ACP_CAT_DOT_MODS', 'RECENT_TOPICS_EXT')),
array('module.remove', array('acp', 'ACP_CAT_DOT_MODS', 'RECENT_TOPICS_EXT')),
)),
// Add new modules
array('module.add', array(
'acp',
'ACP_CAT_DOT_MODS',
'RECENT_TOPICS'
)),
array('module.add', array(
'acp',
'RECENT_TOPICS',
array(
'module_basename' => '\paybas\recenttopics\acp\recenttopics_module',
'modes' => array('recenttopics_config'),
),
)),
);
}
public function revert_data()
{
return array(
array('config.remove', array('rt_version')),
array('config.remove', array('rt_number')),
array('config.remove', array('rt_page_number')),
array('config.remove', array('rt_anti_topics')),
array('config.remove', array('rt_parents')),
array('config.remove', array('rt_unreadonly')),
array('config.remove', array('rt_index')),
array('module.remove', array(
'acp',
'RECENT_TOPICS',
array(
'module_basename' => '\paybas\recenttopics\acp\recenttopics_module',
'modes' => array('recenttopics_config'),
),
)),
array('module.remove', array(
'acp',
'ACP_CAT_DOT_MODS',
'RECENT_TOPICS'
)),
);
}
}