1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Upgrader from to 2.4.x to 2.5.0 |
4
|
|
|
* |
5
|
|
|
* You may not change or alter any portion of this comment or credits |
6
|
|
|
* of supporting developers from this source code or any supporting source code |
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
8
|
|
|
* This program is distributed in the hope that it will be useful, |
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
* |
12
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
13
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
14
|
|
|
* @package upgrader |
15
|
|
|
* @since 2.5.0 |
16
|
|
|
* @author Andricq Nicolas (AKA MusS) |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
require_once __DIR__ . '/dbmanager.php'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Class upgrade_250 |
23
|
|
|
*/ |
24
|
|
|
class Upgrade_250 extends XoopsUpgrade |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Check if cpanel config already exists |
28
|
|
|
* |
29
|
|
|
*/ |
30
|
|
|
public function check_config() |
31
|
|
|
{ |
32
|
|
|
$sql = 'SELECT COUNT(*) FROM `' . $GLOBALS['xoopsDB']->prefix('config') . "` WHERE `conf_name` IN ('break1', 'usetips')"; |
33
|
|
|
$result = $GLOBALS['xoopsDB']->queryF($sql); |
34
|
|
|
if (!$GLOBALS['xoopsDB']->isResultSet($result)) { |
35
|
|
|
return false; |
36
|
|
|
} |
37
|
|
|
list($count) = $GLOBALS['xoopsDB']->fetchRow($result); |
38
|
|
|
|
39
|
|
|
return ($count != 0); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
|
|
public function check_templates() |
46
|
|
|
{ |
47
|
|
|
$sql = 'SELECT COUNT(*) FROM `' . $GLOBALS['xoopsDB']->prefix('tplfile') . "` WHERE `tpl_file` IN ('system_header.html', 'system_header.tpl') AND `tpl_type` = 'admin'"; |
48
|
|
|
$result = $GLOBALS['xoopsDB']->queryF($sql); |
49
|
|
|
if (!$GLOBALS['xoopsDB']->isResultSet($result)) { |
50
|
|
|
return false; |
51
|
|
|
} |
52
|
|
|
list($count) = $GLOBALS['xoopsDB']->fetchRow($result); |
53
|
|
|
|
54
|
|
|
return ($count != 0); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return bool |
59
|
|
|
*/ |
60
|
|
|
public function apply_config() |
61
|
|
|
{ |
62
|
|
|
$dbm = new Db_manager(); |
63
|
|
|
|
64
|
|
|
$sql = 'SELECT conf_id FROM `' . $GLOBALS['xoopsDB']->prefix('config') . "` WHERE `conf_name` IN ('cpanel')"; |
65
|
|
|
$result = $GLOBALS['xoopsDB']->queryF($sql); |
66
|
|
|
if (!$GLOBALS['xoopsDB']->isResultSet($result)) { |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
$count = $GLOBALS['xoopsDB']->fetchRow($result); |
70
|
|
|
|
71
|
|
|
$sql = 'UPDATE `' . $GLOBALS['xoopsDB']->prefix('config') . "` SET `conf_value` = 'default' WHERE `conf_id` = " . $count[0]; |
72
|
|
|
if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) { |
|
|
|
|
73
|
|
|
return false; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'break1', '_MI_SYSTEM_PREFERENCE_BREAK_GENERAL', 'head', '', 'line_break', 'textbox', 0)"); |
77
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'usetips', '_MI_SYSTEM_PREFERENCE_TIPS', '1', '_MI_SYSTEM_PREFERENCE_TIPS_DSC', 'yesno', 'int', 10)"); |
78
|
|
|
$icon_id = $dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'typeicons', '_MI_SYSTEM_PREFERENCE_ICONS', 'default', '', 'select', 'text', 20)"); |
79
|
|
|
$bc_id = $dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'typebreadcrumb', '_MI_SYSTEM_PREFERENCE_BREADCRUMB', 'default', '', 'select', 'text', 30)"); |
80
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'break2', '_MI_SYSTEM_PREFERENCE_BREAK_ACTIVE', 'head', '', 'line_break', 'textbox', 40)"); |
81
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_avatars', '_MI_SYSTEM_PREFERENCE_ACTIVE_AVATARS', '1', '', 'yesno', 'int', 50)"); |
82
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_banners', '_MI_SYSTEM_PREFERENCE_ACTIVE_BANNERS', '1', '', 'yesno', 'int', 60)"); |
83
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_blocksadmin', '_MI_SYSTEM_PREFERENCE_ACTIVE_BLOCKSADMIN', '1', '', 'hidden', 'int', 70)"); |
84
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_comments', '_MI_SYSTEM_PREFERENCE_ACTIVE_COMMENTS', '1', '', 'yesno', 'int', 80)"); |
85
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_filemanager', '_MI_SYSTEM_PREFERENCE_ACTIVE_FILEMANAGER', '1', '', 'yesno', 'int', 90)"); |
86
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_groups', '_MI_SYSTEM_PREFERENCE_ACTIVE_GROUPS', '1', '', 'hidden', 'int', 100)"); |
87
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_images', '_MI_SYSTEM_PREFERENCE_ACTIVE_IMAGES', '1', '', 'yesno', 'int', 110)"); |
88
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_mailusers', '_MI_SYSTEM_PREFERENCE_ACTIVE_MAILUSERS', '1', '', 'yesno', 'int', 120)"); |
89
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_modulesadmin', '_MI_SYSTEM_PREFERENCE_ACTIVE_MODULESADMIN', '1', '', 'hidden', 'int', 130)"); |
90
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_maintenance', '_MI_SYSTEM_PREFERENCE_ACTIVE_MAINTENANCE', '1', '', 'yesno', 'int', 140)"); |
91
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_preferences', '_MI_SYSTEM_PREFERENCE_ACTIVE_PREFERENCES', '1', '', 'hidden', 'int', 150)"); |
92
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_smilies', '_MI_SYSTEM_PREFERENCE_ACTIVE_SMILIES', '1', '', 'yesno', 'int', 160)"); |
93
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_tplsets', '_MI_SYSTEM_PREFERENCE_ACTIVE_TPLSETS', '1', '', 'hidden', 'int', 170)"); |
94
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_userrank', '_MI_SYSTEM_PREFERENCE_ACTIVE_USERRANK', '1', '', 'yesno', 'int', 180)"); |
95
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'active_users', '_MI_SYSTEM_PREFERENCE_ACTIVE_USERS', '1', '', 'yesno', 'int', 190)"); |
96
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'break3', '_MI_SYSTEM_PREFERENCE_BREAK_PAGER', 'head', '', 'line_break', 'textbox', 200)"); |
97
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'avatars_pager', '_MI_SYSTEM_PREFERENCE_AVATARS_PAGER', '10', '', 'textbox', 'int', 210)"); |
98
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'banners_pager', '_MI_SYSTEM_PREFERENCE_BANNERS_PAGER', '10', '', 'textbox', 'int', 220)"); |
99
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'comments_pager', '_MI_SYSTEM_PREFERENCE_COMMENTS_PAGER', '20', '', 'textbox', 'int', 230)"); |
100
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'groups_pager', '_MI_SYSTEM_PREFERENCE_GROUPS_PAGER', '15', '', 'textbox', 'int', 240)"); |
101
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'images_pager', '_MI_SYSTEM_PREFERENCE_IMAGES_PAGER', '15', '', 'textbox', 'int', 250)"); |
102
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'smilies_pager', '_MI_SYSTEM_PREFERENCE_SMILIES_PAGER', '20', '', 'textbox', 'int', 260)"); |
103
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'userranks_pager', '_MI_SYSTEM_PREFERENCE_USERRANKS_PAGER', '20', '', 'textbox', 'int', 270)"); |
104
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'users_pager', '_MI_SYSTEM_PREFERENCE_USERS_PAGER', '20', '', 'textbox', 'int', 280)"); |
105
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'break4', '_MI_SYSTEM_PREFERENCE_BREAK_EDITOR', 'head', '', 'line_break', 'textbox', 290)"); |
106
|
|
|
$block_id = $dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'blocks_editor', '_MI_SYSTEM_PREFERENCE_BLOCKS_EDITOR', 'dhtmltextarea', '_MI_SYSTEM_PREFERENCE_BLOCKS_EDITOR_DSC', 'select', 'text', 300)"); |
107
|
|
|
$com_id = $dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'comments_editor', '_MI_SYSTEM_PREFERENCE_COMMENTS_EDITOR', 'dhtmltextarea', '_MI_SYSTEM_PREFERENCE_COMMENTS_EDITOR_DSC', 'select', 'text', 310)"); |
108
|
|
|
$main_id = $dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'general_editor', '_MI_SYSTEM_PREFERENCE_GENERAL_EDITOR', 'dhtmltextarea', '_MI_SYSTEM_PREFERENCE_GENERAL_EDITOR_DSC', 'select', 'text', 320)"); |
109
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'redirect', '_MI_SYSTEM_PREFERENCE_REDIRECT', 'admin.php?fct=preferences', '', 'hidden', 'text', 330)"); |
110
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'com_anonpost', '_MI_SYSTEM_PREFERENCE_ANONPOST', '', '', 'hidden', 'text', 340)"); |
111
|
|
|
$jquery_id = $dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (1, 0, 'jquery_theme', '_MI_SYSTEM_PREFERENCE_JQUERY_THEME', 'base', '', 'select', 'text', 35)"); |
112
|
|
|
|
113
|
|
|
$dbm->insert('config', " (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) VALUES (0, 1, 'redirect_message_ajax', '_MD_AM_CUSTOM_REDIRECT', '1', '_MD_AM_CUSTOM_REDIRECT_DESC', 'yesno', 'int', 12)"); |
114
|
|
|
|
115
|
|
|
require_once __DIR__ . '/../class/xoopslists.php'; |
116
|
|
|
$editors = XoopsLists::getDirListAsArray('../class/xoopseditor'); |
117
|
|
|
foreach ($editors as $dir) { |
118
|
|
|
$dbm->insert('configoption', " (confop_name,confop_value,conf_id) VALUES ('" . $dir . "', '" . $dir . "', $block_id)"); |
119
|
|
|
} |
120
|
|
|
foreach ($editors as $dir) { |
121
|
|
|
$dbm->insert('configoption', " (confop_name,confop_value,conf_id) VALUES ('" . $dir . "', '" . $dir . "', $com_id)"); |
122
|
|
|
} |
123
|
|
|
foreach ($editors as $dir) { |
124
|
|
|
$dbm->insert('configoption', " (confop_name,confop_value,conf_id) VALUES ('" . $dir . "', '" . $dir . "', $main_id)"); |
125
|
|
|
} |
126
|
|
|
$icons = XoopsLists::getDirListAsArray('../modules/system/images/icons'); |
127
|
|
|
foreach ($icons as $dir) { |
128
|
|
|
$dbm->insert('configoption', " (confop_name,confop_value,conf_id) VALUES ('" . $dir . "', '" . $dir . "', $icon_id)"); |
129
|
|
|
} |
130
|
|
|
$breadcrumb = XoopsLists::getDirListAsArray('../modules/system/images/breadcrumb'); |
131
|
|
|
foreach ($breadcrumb as $dir) { |
132
|
|
|
$dbm->insert('configoption', " (confop_name,confop_value,conf_id) VALUES ('" . $dir . "', '" . $dir . "', $bc_id)"); |
133
|
|
|
} |
134
|
|
|
$jqueryui = XoopsLists::getDirListAsArray('../modules/system/css/ui'); |
135
|
|
|
foreach ($jqueryui as $dir) { |
136
|
|
|
$dbm->insert('configoption', " (confop_name,confop_value,conf_id) VALUES ('" . $dir . "', '" . $dir . "', $jquery_id)"); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
return true; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return bool |
144
|
|
|
*/ |
145
|
|
|
public function apply_templates() |
146
|
|
|
{ |
147
|
|
|
include_once __DIR__ . '/../modules/system/xoops_version.php'; |
148
|
|
|
|
149
|
|
|
$dbm = new Db_manager(); |
150
|
|
|
$time = time(); |
151
|
|
|
foreach ($modversion['templates'] as $tplfile) { |
|
|
|
|
152
|
|
|
// Admin templates |
153
|
|
|
if (isset($tplfile['type']) && $tplfile['type'] === 'admin' && $fp = fopen('../modules/system/templates/admin/' . $tplfile['file'], 'r')) { |
154
|
|
|
$newtplid = $dbm->insert('tplfile', " VALUES (0, 1, 'system', 'default', '" . addslashes($tplfile['file']) . "', '" . addslashes($tplfile['description']) . "', " . $time . ', ' . $time . ", 'admin')"); |
155
|
|
|
$tplsource = fread($fp, filesize('../modules/system/templates/admin/' . $tplfile['file'])); |
156
|
|
|
fclose($fp); |
157
|
|
|
$dbm->insert('tplsource', ' (tpl_id, tpl_source) VALUES (' . $newtplid . ", '" . addslashes($tplsource) . "')"); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
return true; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Identify a block mangled in the change from XOOPS 2.4.x to 2.5.0 |
166
|
|
|
* |
167
|
|
|
* The user menu block was element 1 in the old $modversion['blocks'] array, but |
168
|
|
|
* became element 0 in 2.5.0. This results in the old block not being updated with |
169
|
|
|
* new settings. We see it in 2.5.8+ where the theme overrides fail because of the |
170
|
|
|
* extension change from .html to .tpl. |
171
|
|
|
* |
172
|
|
|
* Installs are not a problem, just upgrades. This is the only block affected. |
173
|
|
|
* |
174
|
|
|
* @return CriteriaElement |
175
|
|
|
*/ |
176
|
|
|
private function strayblockCriteria() |
177
|
|
|
{ |
178
|
|
|
$criteria = new CriteriaCompo(new Criteria('mid','1', '=')); |
179
|
|
|
$criteria->add(new Criteria('block_type','S', '=')); |
180
|
|
|
$criteria->add(new Criteria('func_num','1', '=')); |
181
|
|
|
$criteria->add(new Criteria('template','system_block_user.html', '=')); |
182
|
|
|
return $criteria; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return bool |
187
|
|
|
*/ |
188
|
|
|
public function check_strayblock() |
189
|
|
|
{ |
190
|
|
|
$criteria = $this->strayblockCriteria(); |
191
|
|
|
$count = Xmf\Database\TableLoad::countRows('newblocks', $criteria); |
192
|
|
|
|
193
|
|
|
return ($count === 0); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @return bool |
198
|
|
|
*/ |
199
|
|
|
public function apply_strayblock() |
200
|
|
|
{ |
201
|
|
|
$criteria = $this->strayblockCriteria(); |
202
|
|
|
$tables = new Xmf\Database\Tables(); |
203
|
|
|
$tables->useTable('newblocks'); |
204
|
|
|
$tables->update('newblocks', array('func_num' => '0'), $criteria); |
205
|
|
|
|
206
|
|
|
return $tables->executeQueue(true); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
public function __construct() |
210
|
|
|
{ |
211
|
|
|
parent::__construct(basename(__DIR__)); |
212
|
|
|
$this->tasks = array('config', 'templates', 'strayblock'); |
213
|
|
|
} |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
$upg = new Upgrade_250(); |
217
|
|
|
return $upg; |
218
|
|
|
|