Passed
Push — master ( 565d4a...492cc7 )
by Michael
07:40
created
admin/admin_type_manager.php 2 patches
Indentation   +389 added lines, -389 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
  */
33 33
 $op       = Request::getCmd('op', '');
34 34
 $validOps = [
35
-    'save_type',
36
-    'delete',
37
-    'template',
38
-    'save_template',
39
-    'apply',
40
-    'save_apply',
41
-    'forum',
42
-    'edit_forum',
43
-    'save_forum',
44
-    'add'
35
+	'save_type',
36
+	'delete',
37
+	'template',
38
+	'save_template',
39
+	'apply',
40
+	'save_apply',
41
+	'forum',
42
+	'edit_forum',
43
+	'save_forum',
44
+	'add'
45 45
 ];
46 46
 if (!in_array($op, $validOps, true)) {
47
-    $op = '';
47
+	$op = '';
48 48
 }
49 49
 
50 50
 ///** @var Newbb\TypeHandler $typeHandler */
@@ -52,386 +52,386 @@  discard block
 block discarded – undo
52 52
 $cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
53 53
 
54 54
 switch ($op) {
55
-    case 'save_type':
56
-        $type_names0 = $_POST['type_name'];
57
-        $type_names  = Request::getArray('type_name', null, 'POST');
58
-        $type_del    = [];
59
-        foreach (array_keys($type_names) as $key) {
60
-            if (Request::getBool('isnew', '', 'POST')) {
61
-                $typeObject = $typeHandler->create();
62
-            } elseif (!$typeObject = $typeHandler->get($key)) {
63
-                continue;
64
-            }
65
-
66
-            //            if (Request::getArray("type_del[$key]", '', 'POST')) {
67
-            $temp = Request::getArray('type_del', '', 'POST');
68
-            if ($temp[$key]) {
69
-                $type_del[] = $key;
70
-                continue;
71
-            } else {
72
-                foreach (['type_name', 'type_color', 'type_description'] as $var) {
73
-                    //                    if ($typeObject->getVar($var) != @$_POST[$var][$key]) {
74
-                    //                        $typeObject->setVar($var, @$_POST[$var][$key]);
75
-                    //                    }
76
-                    $temp = Request::getArray($var, '', 'POST');
77
-                    if ($typeObject->getVar($var) != $temp[$key]) {
78
-                        $typeObject->setVar($var, $temp[$key]);
79
-                    }
80
-
81
-                    //                    $typeObject->setVar($var, Request::getArray($var, '', 'POST')[$key]);
82
-                }
83
-                $typeHandler->insert($typeObject);
84
-                unset($typeObject);
85
-            }
86
-        }
87
-        if (count($type_del) > 0) {
88
-            $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', $type_del) . ')', 'IN'));
89
-            xoops_confirm(['op' => 'delete', 'type_del' => serialize($type_del)], xoops_getenv('PHP_SELF'), sprintf(_AM_NEWBB_TODEL_TYPE, implode(', ', array_values($type_list))), '', false);
90
-        } else {
91
-            redirect_header(xoops_getenv('PHP_SELF'), 2, _MD_NEWBB_DBUPDATED);
92
-        }
93
-        break;
94
-
95
-    case 'delete':
96
-        $type_dels = @unserialize(Request::getString('type_del', '', 'POST'));
97
-        foreach ($type_dels as $key) {
98
-            if (!$typeObject = $typeHandler->get($key)) {
99
-                continue;
100
-            }
101
-            $typeHandler->delete($typeObject);
102
-            unset($typeObject);
103
-        }
104
-        redirect_header(xoops_getenv('PHP_SELF'), 2, _MD_NEWBB_DBUPDATED);
105
-        break;
106
-
107
-    case 'template':
108
-        $typesObject = $typeHandler->getAll();
109
-        if (0 === count($typesObject)) {
110
-            redirect_header(xoops_getenv('PHP_SELF'), 2, _AM_NEWBB_TYPE_ADD_ERR);
111
-        }
112
-
113
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
114
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
115
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE_APPLY, 'admin_type_manager.php?op=apply', $icon = 'add');
116
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
117
-        $adminObject->displayButton('left');
118
-        echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_ORDER_DESC . '</legend>';
119
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
120
-        echo "<form name='template' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
121
-        echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
122
-        echo "<tr align='center'>";
123
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
124
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
125
-        echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
126
-        echo '</tr>';
127
-
128
-        if ($templates = $cacheHelper->read('type_template')) {
129
-            arsort($templates);
130
-            foreach ($templates as $order => $key) {
131
-                if (!isset($typesObject[$key])) {
132
-                    continue;
133
-                }
134
-                $typeObject = $typesObject[$key];
135
-                echo "<tr class='even' align='left'>";
136
-                echo "<td><input type='text' name='type_order[{$key}]' value='" . $order . "' size='10' /></td>";
137
-                echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
138
-                echo '<td>' . $typeObject->getVar('type_description') . '</td>';
139
-                echo '</tr>';
140
-                unset($typesObject[$key]);
141
-            }
142
-            echo "<tr><td colspan='3' height='5px'></td></tr>";
143
-        }
144
-        foreach ($typesObject as $key => $typeObject) {
145
-            echo "<tr class='odd' align='left'>";
146
-            echo "<td><input type='text' name='type_order[{$key}]' value='0' size='10' /></td>";
147
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
148
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
149
-            echo '</tr>';
150
-        }
151
-
152
-        echo "<tr><td colspan='3' style='text-align:center;'>";
153
-        echo "<input type='hidden' name='op' value='save_template' />";
154
-        echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
155
-        echo "<input type='reset' value='" . _CANCEL . "' />";
156
-        echo '</td></tr></table>';
157
-        echo '</form>';
158
-        echo '</td></tr></table>';
159
-        break;
160
-
161
-    case 'save_template':
162
-        $templates = array_flip(array_filter(Request::getArray('type_order', [], 'POST')));
163
-        $cacheHelper->write('type_template', $templates);
164
-        redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _MD_NEWBB_DBUPDATED);
165
-        break;
166
-
167
-    case 'apply':
168
-        if (!$templates = $cacheHelper->read('type_template')) {
169
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE_ERR);
170
-        }
171
-
172
-        //        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
173
-        $criteriaCategory = new \CriteriaCompo(new \Criteria('1', 1));
174
-        $criteriaCategory->setSort('cat_order');
175
-        $categories = $categoryHandler->getList($criteriaCategory);
176
-        //        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
177
-        $forums = $forumHandler->getTree(array_keys($categories), 0, 'all');
178
-        foreach (array_keys($forums) as $c) {
179
-            $fm_options[-1 * $c] = '[' . $categories[$c] . ']';
180
-            foreach (array_keys($forums[$c]) as $f) {
181
-                $fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'];
182
-            }
183
-        }
184
-        unset($forums, $categories);
185
-        $fmform    = new \XoopsThemeForm(_AM_NEWBB_TYPE_TEMPLATE_APPLY, 'fmform', xoops_getenv('PHP_SELF'), 'post', true);
186
-        $fm_select = new \XoopsFormSelect(_AM_NEWBB_PERM_FORUMS, 'forums', null, 10, true);
187
-        $fm_select->addOptionArray($fm_options);
188
-        $fmform->addElement($fm_select);
189
-        $tray = new \XoopsFormElementTray('');
190
-        $tray->addElement(new \XoopsFormHidden('op', 'save_apply'));
191
-        $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
192
-        $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
193
-        $fmform->addElement($tray);
194
-
195
-        //loadModuleAdminMenu(11, _AM_NEWBB_TYPE_TEMPLATE_APPLY);
196
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
197
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
198
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE_APPLY, 'admin_type_manager.php?op=apply', $icon = 'add');
199
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
200
-        $adminObject->displayButton('left');
201
-
202
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
203
-        echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
204
-        echo "<tr align='center'>";
205
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
206
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
207
-        echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
208
-        echo '</tr>';
209
-
210
-        $typesObject = $typeHandler->getAll(new \Criteria('type_id', '(' . implode(', ', array_values($templates)) . ')', 'IN'));
211
-        arsort($templates);
212
-        foreach ($templates as $order => $key) {
213
-            if (!isset($typesObject[$key])) {
214
-                continue;
215
-            }
216
-            $typeObject = $typesObject[$key];
217
-            echo "<tr class='even' align='left'>";
218
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
219
-            echo '<td>' . $order . '</td>';
220
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
221
-            echo '</tr>';
222
-            unset($typesObject[$key]);
223
-        }
224
-        echo '</table>';
225
-        echo '</td></tr></table>';
226
-        echo '<br>';
227
-        $fmform->display();
228
-        break;
229
-
230
-    case 'save_apply':
231
-        if (!$templates = $cacheHelper->read('type_template')) {
232
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE);
233
-        }
234
-        foreach (Request::getArray('forums', [], 'POST') as $forum) {
235
-            if ($forum < 1) {
236
-                continue;
237
-            }
238
-            $typeHandler->updateByForum($forum, array_flip($templates));
239
-        }
240
-        redirect_header(xoops_getenv('PHP_SELF'), 2, _MD_NEWBB_DBUPDATED);
241
-        break;
242
-
243
-    case 'forum':
244
-        //        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
245
-        $criteriaCategory = new \CriteriaCompo(new \Criteria('1', 1));
246
-        $criteriaCategory->setSort('cat_order');
247
-        $categories = $categoryHandler->getList($criteriaCategory);
248
-        if (empty($categories)) {
249
-            redirect_header('admin_cat_manager.php', 2, _AM_NEWBB_CREATENEWCATEGORY);
250
-        }
251
-        //        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
252
-        $forums = $forumHandler->getTree(array_keys($categories));
253
-        if (empty($forums)) {
254
-            redirect_header('admin_forum_manager.php', 2, _AM_NEWBB_CREATENEWFORUM);
255
-        }
256
-
257
-        foreach (array_keys($forums) as $c) {
258
-            $fm_options[-1 * $c] = '[' . $categories[$c] . ']';
259
-            foreach (array_keys($forums[$c]) as $f) {
260
-                $fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'];
261
-            }
262
-        }
263
-        unset($forums, $categories);
264
-        $fmform    = new \XoopsThemeForm(_AM_NEWBB_TYPE_FORUM, 'fmform', xoops_getenv('PHP_SELF'), 'post', true);
265
-        $fm_select = new \XoopsFormSelect(_AM_NEWBB_PERM_FORUMS, 'forum', null, 5, false);
266
-        $fm_select->addOptionArray($fm_options);
267
-        $fmform->addElement($fm_select);
268
-        $tray = new \XoopsFormElementTray('');
269
-        $tray->addElement(new \XoopsFormHidden('op', 'edit_forum'));
270
-        $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
271
-        $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
272
-        $fmform->addElement($tray);
273
-
274
-        //loadModuleAdminMenu(11, _AM_NEWBB_TYPE_FORUM);
275
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
276
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
277
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
278
-        $adminObject->displayButton('left');
279
-
280
-        $fmform->display();
281
-        break;
282
-
283
-    case 'edit_forum':
284
-        if (!Request::getInt('forum', 0, 'POST') || Request::getInt('forum', 0, 'POST') < 1) {
285
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
286
-        }
287
-
288
-        //        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
289
-        if (!$forumObject = $forumHandler->get(Request::getInt('forum', 0, 'POST'))) {
290
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
291
-        }
292
-
293
-        $typesObject = $typeHandler->getAll();
294
-        if (0 === count($typesObject)) {
295
-            redirect_header(xoops_getenv('PHP_SELF'), 2, _AM_NEWBB_TYPE_ADD_ERR);
296
-        }
297
-
298
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
299
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
300
-        $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
301
-        $adminObject->displayButton('left');
302
-        echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_ORDER_DESC . '</legend>';
303
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
304
-        echo "<form name='template' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
305
-        echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
306
-        echo "<tr align='center'>";
307
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
308
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
309
-        echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
310
-        echo '</tr>';
311
-
312
-        $types       = $typeHandler->getByForum(Request::getInt('forum', 0, 'POST'));
313
-        $types_order = [];
314
-        foreach ($types as $key => $type) {
315
-            $types_order[] = $type['type_order'];
316
-        }
317
-        array_multisort($types_order, $types);
318
-        foreach ($types as $key => $type) {
319
-            if (!isset($typesObject[$type['type_id']])) {
320
-                continue;
321
-            }
322
-            $typeObject = $typesObject[$type['type_id']];
323
-            echo "<tr class='even' align='left'>";
324
-            echo "<td><input type='text' name='type_order[" . $type['type_id'] . "]' value='" . $type['type_order'] . "' size='10' /></td>";
325
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
326
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
327
-            echo '</tr>';
328
-            unset($typesObject[$type['type_id']]);
329
-        }
330
-        echo "<tr><td colspan='3' height='5px'></td></tr>";
331
-        foreach ($typesObject as $key => $typeObject) {
332
-            echo "<tr class='odd' align='left'>";
333
-            echo "<td><input type='text' name='type_order[{$key}]' value='0' size='10' /></td>";
334
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
335
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
336
-            echo '</tr>';
337
-        }
338
-
339
-        echo "<tr><td colspan='3' style='text-align:center;'>";
340
-        echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_EDITFORUM_DESC . '</legend>';
341
-        echo "<input type='hidden' name='forum' value='" . Request::getInt('forum', 0, 'POST') . "' />";
342
-        echo "<input type='hidden' name='op' value='save_forum' />";
343
-        echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
344
-        echo "<input type='reset' value='" . _CANCEL . "' />";
345
-        echo '</td></tr></table>';
346
-        echo '</form>';
347
-        echo '</td></tr></table>';
348
-        break;
349
-
350
-    case 'save_forum':
351
-        if (!Request::getInt('forum', 0, 'POST') || Request::getInt('forum', 0, 'POST') < 1) {
352
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM);
353
-        }
354
-        $typeHandler->updateByForum(Request::getInt('forum', 0, 'POST'), Request::getArray('type_order', null, 'POST'));
355
-        redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _MD_NEWBB_DBUPDATED);
356
-        break;
357
-
358
-    case 'add':
359
-    default:
360
-        $typesObject = $typeHandler->getAll();
361
-        if (0 === count($typesObject)) {
362
-            $op    = 'add';
363
-            $title = _AM_NEWBB_TYPE_ADD;
364
-        } else {
365
-            $title = _AM_NEWBB_TYPE_LIST;
366
-        }
367
-
368
-        if ('add' !== $op) {
369
-            $adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
370
-            $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
371
-            $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
372
-            $adminObject->displayButton('left');
373
-        }
374
-        echo _AM_NEWBB_TYPE_HELP;
375
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
376
-        echo "<form name='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
377
-        echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
378
-        echo "<tr align='center'>";
379
-        if ('add' !== $op) {
380
-            echo "<th class='bg3' width='5%'>" . _DELETE . '</th>';
381
-        }
382
-        echo "<th align='left' class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
383
-        echo "<th class='bg3' width='15%'>" . _AM_NEWBB_TYPE_COLOR . '</th>';
384
-        echo "<th align='left' class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
385
-        echo '</tr>';
55
+	case 'save_type':
56
+		$type_names0 = $_POST['type_name'];
57
+		$type_names  = Request::getArray('type_name', null, 'POST');
58
+		$type_del    = [];
59
+		foreach (array_keys($type_names) as $key) {
60
+			if (Request::getBool('isnew', '', 'POST')) {
61
+				$typeObject = $typeHandler->create();
62
+			} elseif (!$typeObject = $typeHandler->get($key)) {
63
+				continue;
64
+			}
65
+
66
+			//            if (Request::getArray("type_del[$key]", '', 'POST')) {
67
+			$temp = Request::getArray('type_del', '', 'POST');
68
+			if ($temp[$key]) {
69
+				$type_del[] = $key;
70
+				continue;
71
+			} else {
72
+				foreach (['type_name', 'type_color', 'type_description'] as $var) {
73
+					//                    if ($typeObject->getVar($var) != @$_POST[$var][$key]) {
74
+					//                        $typeObject->setVar($var, @$_POST[$var][$key]);
75
+					//                    }
76
+					$temp = Request::getArray($var, '', 'POST');
77
+					if ($typeObject->getVar($var) != $temp[$key]) {
78
+						$typeObject->setVar($var, $temp[$key]);
79
+					}
80
+
81
+					//                    $typeObject->setVar($var, Request::getArray($var, '', 'POST')[$key]);
82
+				}
83
+				$typeHandler->insert($typeObject);
84
+				unset($typeObject);
85
+			}
86
+		}
87
+		if (count($type_del) > 0) {
88
+			$type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', $type_del) . ')', 'IN'));
89
+			xoops_confirm(['op' => 'delete', 'type_del' => serialize($type_del)], xoops_getenv('PHP_SELF'), sprintf(_AM_NEWBB_TODEL_TYPE, implode(', ', array_values($type_list))), '', false);
90
+		} else {
91
+			redirect_header(xoops_getenv('PHP_SELF'), 2, _MD_NEWBB_DBUPDATED);
92
+		}
93
+		break;
94
+
95
+	case 'delete':
96
+		$type_dels = @unserialize(Request::getString('type_del', '', 'POST'));
97
+		foreach ($type_dels as $key) {
98
+			if (!$typeObject = $typeHandler->get($key)) {
99
+				continue;
100
+			}
101
+			$typeHandler->delete($typeObject);
102
+			unset($typeObject);
103
+		}
104
+		redirect_header(xoops_getenv('PHP_SELF'), 2, _MD_NEWBB_DBUPDATED);
105
+		break;
106
+
107
+	case 'template':
108
+		$typesObject = $typeHandler->getAll();
109
+		if (0 === count($typesObject)) {
110
+			redirect_header(xoops_getenv('PHP_SELF'), 2, _AM_NEWBB_TYPE_ADD_ERR);
111
+		}
112
+
113
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
114
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
115
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE_APPLY, 'admin_type_manager.php?op=apply', $icon = 'add');
116
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
117
+		$adminObject->displayButton('left');
118
+		echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_ORDER_DESC . '</legend>';
119
+		echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
120
+		echo "<form name='template' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
121
+		echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
122
+		echo "<tr align='center'>";
123
+		echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
124
+		echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
125
+		echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
126
+		echo '</tr>';
127
+
128
+		if ($templates = $cacheHelper->read('type_template')) {
129
+			arsort($templates);
130
+			foreach ($templates as $order => $key) {
131
+				if (!isset($typesObject[$key])) {
132
+					continue;
133
+				}
134
+				$typeObject = $typesObject[$key];
135
+				echo "<tr class='even' align='left'>";
136
+				echo "<td><input type='text' name='type_order[{$key}]' value='" . $order . "' size='10' /></td>";
137
+				echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
138
+				echo '<td>' . $typeObject->getVar('type_description') . '</td>';
139
+				echo '</tr>';
140
+				unset($typesObject[$key]);
141
+			}
142
+			echo "<tr><td colspan='3' height='5px'></td></tr>";
143
+		}
144
+		foreach ($typesObject as $key => $typeObject) {
145
+			echo "<tr class='odd' align='left'>";
146
+			echo "<td><input type='text' name='type_order[{$key}]' value='0' size='10' /></td>";
147
+			echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
148
+			echo '<td>' . $typeObject->getVar('type_description') . '</td>';
149
+			echo '</tr>';
150
+		}
151
+
152
+		echo "<tr><td colspan='3' style='text-align:center;'>";
153
+		echo "<input type='hidden' name='op' value='save_template' />";
154
+		echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
155
+		echo "<input type='reset' value='" . _CANCEL . "' />";
156
+		echo '</td></tr></table>';
157
+		echo '</form>';
158
+		echo '</td></tr></table>';
159
+		break;
160
+
161
+	case 'save_template':
162
+		$templates = array_flip(array_filter(Request::getArray('type_order', [], 'POST')));
163
+		$cacheHelper->write('type_template', $templates);
164
+		redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _MD_NEWBB_DBUPDATED);
165
+		break;
166
+
167
+	case 'apply':
168
+		if (!$templates = $cacheHelper->read('type_template')) {
169
+			redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE_ERR);
170
+		}
171
+
172
+		//        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
173
+		$criteriaCategory = new \CriteriaCompo(new \Criteria('1', 1));
174
+		$criteriaCategory->setSort('cat_order');
175
+		$categories = $categoryHandler->getList($criteriaCategory);
176
+		//        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
177
+		$forums = $forumHandler->getTree(array_keys($categories), 0, 'all');
178
+		foreach (array_keys($forums) as $c) {
179
+			$fm_options[-1 * $c] = '[' . $categories[$c] . ']';
180
+			foreach (array_keys($forums[$c]) as $f) {
181
+				$fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'];
182
+			}
183
+		}
184
+		unset($forums, $categories);
185
+		$fmform    = new \XoopsThemeForm(_AM_NEWBB_TYPE_TEMPLATE_APPLY, 'fmform', xoops_getenv('PHP_SELF'), 'post', true);
186
+		$fm_select = new \XoopsFormSelect(_AM_NEWBB_PERM_FORUMS, 'forums', null, 10, true);
187
+		$fm_select->addOptionArray($fm_options);
188
+		$fmform->addElement($fm_select);
189
+		$tray = new \XoopsFormElementTray('');
190
+		$tray->addElement(new \XoopsFormHidden('op', 'save_apply'));
191
+		$tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
192
+		$tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
193
+		$fmform->addElement($tray);
194
+
195
+		//loadModuleAdminMenu(11, _AM_NEWBB_TYPE_TEMPLATE_APPLY);
196
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
197
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
198
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE_APPLY, 'admin_type_manager.php?op=apply', $icon = 'add');
199
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
200
+		$adminObject->displayButton('left');
201
+
202
+		echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
203
+		echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
204
+		echo "<tr align='center'>";
205
+		echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
206
+		echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
207
+		echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
208
+		echo '</tr>';
209
+
210
+		$typesObject = $typeHandler->getAll(new \Criteria('type_id', '(' . implode(', ', array_values($templates)) . ')', 'IN'));
211
+		arsort($templates);
212
+		foreach ($templates as $order => $key) {
213
+			if (!isset($typesObject[$key])) {
214
+				continue;
215
+			}
216
+			$typeObject = $typesObject[$key];
217
+			echo "<tr class='even' align='left'>";
218
+			echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
219
+			echo '<td>' . $order . '</td>';
220
+			echo '<td>' . $typeObject->getVar('type_description') . '</td>';
221
+			echo '</tr>';
222
+			unset($typesObject[$key]);
223
+		}
224
+		echo '</table>';
225
+		echo '</td></tr></table>';
226
+		echo '<br>';
227
+		$fmform->display();
228
+		break;
229
+
230
+	case 'save_apply':
231
+		if (!$templates = $cacheHelper->read('type_template')) {
232
+			redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE);
233
+		}
234
+		foreach (Request::getArray('forums', [], 'POST') as $forum) {
235
+			if ($forum < 1) {
236
+				continue;
237
+			}
238
+			$typeHandler->updateByForum($forum, array_flip($templates));
239
+		}
240
+		redirect_header(xoops_getenv('PHP_SELF'), 2, _MD_NEWBB_DBUPDATED);
241
+		break;
242
+
243
+	case 'forum':
244
+		//        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
245
+		$criteriaCategory = new \CriteriaCompo(new \Criteria('1', 1));
246
+		$criteriaCategory->setSort('cat_order');
247
+		$categories = $categoryHandler->getList($criteriaCategory);
248
+		if (empty($categories)) {
249
+			redirect_header('admin_cat_manager.php', 2, _AM_NEWBB_CREATENEWCATEGORY);
250
+		}
251
+		//        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
252
+		$forums = $forumHandler->getTree(array_keys($categories));
253
+		if (empty($forums)) {
254
+			redirect_header('admin_forum_manager.php', 2, _AM_NEWBB_CREATENEWFORUM);
255
+		}
256
+
257
+		foreach (array_keys($forums) as $c) {
258
+			$fm_options[-1 * $c] = '[' . $categories[$c] . ']';
259
+			foreach (array_keys($forums[$c]) as $f) {
260
+				$fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'];
261
+			}
262
+		}
263
+		unset($forums, $categories);
264
+		$fmform    = new \XoopsThemeForm(_AM_NEWBB_TYPE_FORUM, 'fmform', xoops_getenv('PHP_SELF'), 'post', true);
265
+		$fm_select = new \XoopsFormSelect(_AM_NEWBB_PERM_FORUMS, 'forum', null, 5, false);
266
+		$fm_select->addOptionArray($fm_options);
267
+		$fmform->addElement($fm_select);
268
+		$tray = new \XoopsFormElementTray('');
269
+		$tray->addElement(new \XoopsFormHidden('op', 'edit_forum'));
270
+		$tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
271
+		$tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
272
+		$fmform->addElement($tray);
273
+
274
+		//loadModuleAdminMenu(11, _AM_NEWBB_TYPE_FORUM);
275
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
276
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
277
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
278
+		$adminObject->displayButton('left');
279
+
280
+		$fmform->display();
281
+		break;
282
+
283
+	case 'edit_forum':
284
+		if (!Request::getInt('forum', 0, 'POST') || Request::getInt('forum', 0, 'POST') < 1) {
285
+			redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
286
+		}
287
+
288
+		//        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
289
+		if (!$forumObject = $forumHandler->get(Request::getInt('forum', 0, 'POST'))) {
290
+			redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
291
+		}
292
+
293
+		$typesObject = $typeHandler->getAll();
294
+		if (0 === count($typesObject)) {
295
+			redirect_header(xoops_getenv('PHP_SELF'), 2, _AM_NEWBB_TYPE_ADD_ERR);
296
+		}
297
+
298
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
299
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
300
+		$adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
301
+		$adminObject->displayButton('left');
302
+		echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_ORDER_DESC . '</legend>';
303
+		echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
304
+		echo "<form name='template' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
305
+		echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
306
+		echo "<tr align='center'>";
307
+		echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
308
+		echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
309
+		echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
310
+		echo '</tr>';
311
+
312
+		$types       = $typeHandler->getByForum(Request::getInt('forum', 0, 'POST'));
313
+		$types_order = [];
314
+		foreach ($types as $key => $type) {
315
+			$types_order[] = $type['type_order'];
316
+		}
317
+		array_multisort($types_order, $types);
318
+		foreach ($types as $key => $type) {
319
+			if (!isset($typesObject[$type['type_id']])) {
320
+				continue;
321
+			}
322
+			$typeObject = $typesObject[$type['type_id']];
323
+			echo "<tr class='even' align='left'>";
324
+			echo "<td><input type='text' name='type_order[" . $type['type_id'] . "]' value='" . $type['type_order'] . "' size='10' /></td>";
325
+			echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
326
+			echo '<td>' . $typeObject->getVar('type_description') . '</td>';
327
+			echo '</tr>';
328
+			unset($typesObject[$type['type_id']]);
329
+		}
330
+		echo "<tr><td colspan='3' height='5px'></td></tr>";
331
+		foreach ($typesObject as $key => $typeObject) {
332
+			echo "<tr class='odd' align='left'>";
333
+			echo "<td><input type='text' name='type_order[{$key}]' value='0' size='10' /></td>";
334
+			echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
335
+			echo '<td>' . $typeObject->getVar('type_description') . '</td>';
336
+			echo '</tr>';
337
+		}
338
+
339
+		echo "<tr><td colspan='3' style='text-align:center;'>";
340
+		echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_EDITFORUM_DESC . '</legend>';
341
+		echo "<input type='hidden' name='forum' value='" . Request::getInt('forum', 0, 'POST') . "' />";
342
+		echo "<input type='hidden' name='op' value='save_forum' />";
343
+		echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
344
+		echo "<input type='reset' value='" . _CANCEL . "' />";
345
+		echo '</td></tr></table>';
346
+		echo '</form>';
347
+		echo '</td></tr></table>';
348
+		break;
349
+
350
+	case 'save_forum':
351
+		if (!Request::getInt('forum', 0, 'POST') || Request::getInt('forum', 0, 'POST') < 1) {
352
+			redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM);
353
+		}
354
+		$typeHandler->updateByForum(Request::getInt('forum', 0, 'POST'), Request::getArray('type_order', null, 'POST'));
355
+		redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _MD_NEWBB_DBUPDATED);
356
+		break;
357
+
358
+	case 'add':
359
+	default:
360
+		$typesObject = $typeHandler->getAll();
361
+		if (0 === count($typesObject)) {
362
+			$op    = 'add';
363
+			$title = _AM_NEWBB_TYPE_ADD;
364
+		} else {
365
+			$title = _AM_NEWBB_TYPE_LIST;
366
+		}
367
+
368
+		if ('add' !== $op) {
369
+			$adminObject->addItemButton(_AM_NEWBB_TYPE_ADD, 'admin_type_manager.php?op=add', $icon = 'add');
370
+			$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
371
+			$adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
372
+			$adminObject->displayButton('left');
373
+		}
374
+		echo _AM_NEWBB_TYPE_HELP;
375
+		echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
376
+		echo "<form name='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
377
+		echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
378
+		echo "<tr align='center'>";
379
+		if ('add' !== $op) {
380
+			echo "<th class='bg3' width='5%'>" . _DELETE . '</th>';
381
+		}
382
+		echo "<th align='left' class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
383
+		echo "<th class='bg3' width='15%'>" . _AM_NEWBB_TYPE_COLOR . '</th>';
384
+		echo "<th align='left' class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
385
+		echo '</tr>';
386 386
 
387 387
 //        $isColorpicker = require_once $GLOBALS['xoops']->path('class/xoopsform/formcolorpicker.php');
388
-        xoops_load('XoopsFormColorPicker');
389
-
390
-        if ('add' !== $op) {
391
-            foreach ($typesObject as $key => $typeObject) {
392
-                echo "<tr class='odd' align='left'>";
393
-                echo "<td><input type='checkbox' name='type_del[{$key}]' /></td>";
394
-                echo "<td><input type='text' name='type_name[{$key}]' value='" . $typeObject->getVar('type_name') . "' size='10' /></td>";
395
-                if ($isColorpicker) {
396
-                    $form_colorpicker = new \XoopsFormColorPicker('', "type_color[{$key}]", $typeObject->getVar('type_color'));
397
-                    echo '<td>' . $form_colorpicker->render() . '</td>';
398
-                } else {
399
-                    echo "<td><input type='text' name='type_color[{$key}]' value='" . $typeObject->getVar('type_color') . "' size='10' /></td>";
400
-                }
401
-                echo "<td><input type='text' name='type_description[{$key}]' value='" . $typeObject->getVar('type_description') . "' size='30' /></td>";
402
-                echo '</tr>';
403
-            }
404
-            echo "<tr><td colspan='4' style='text-align:center;'>";
405
-        } else {
406
-            $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
407
-            $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
408
-            $adminObject->displayButton('left');
409
-            for ($i = 0; $i < 10; ++$i) {
410
-                echo "<tr class='odd' align='left'>";
411
-                echo "<td><input type='text' name='type_name[{$i}]' value='' size='10' /></td>";
412
-                if ($isColorpicker) {
413
-                    $form_colorpicker = new \XoopsFormColorPicker('', "type_color[{$i}]", '');
414
-                    echo '<td>' . $form_colorpicker->render() . '</td>';
415
-                } else {
416
-                    echo "<td><input type='text' name='type_color[{$i}]' value='' size='10' /></td>";
417
-                }
418
-                echo "<td><input type='text' name='type_description[{$i}]' value='' size='40' /></td>";
419
-                echo '</tr>';
420
-            }
421
-            echo "<tr><td colspan='3' style='text-align:center;'>";
422
-            echo "<input type='hidden' name='isnew' value='1' />";
423
-        }
424
-        echo "<input type='hidden' name='op' value='save_type' />";
425
-        echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
426
-        echo "<input type='reset' value='" . _CANCEL . "' />";
427
-        echo '</td></tr></table>';
428
-        echo '</form>';
429
-        echo '</td></tr></table>';
430
-        echo '<fieldset>';
431
-        echo '<legend>&nbsp;' . _MI_NEWBB_ADMENU_TYPE . '&nbsp;</legend>';
432
-        echo _AM_NEWBB_HELP_TYPE_TAB;
433
-        echo '</fieldset>';
434
-        break;
388
+		xoops_load('XoopsFormColorPicker');
389
+
390
+		if ('add' !== $op) {
391
+			foreach ($typesObject as $key => $typeObject) {
392
+				echo "<tr class='odd' align='left'>";
393
+				echo "<td><input type='checkbox' name='type_del[{$key}]' /></td>";
394
+				echo "<td><input type='text' name='type_name[{$key}]' value='" . $typeObject->getVar('type_name') . "' size='10' /></td>";
395
+				if ($isColorpicker) {
396
+					$form_colorpicker = new \XoopsFormColorPicker('', "type_color[{$key}]", $typeObject->getVar('type_color'));
397
+					echo '<td>' . $form_colorpicker->render() . '</td>';
398
+				} else {
399
+					echo "<td><input type='text' name='type_color[{$key}]' value='" . $typeObject->getVar('type_color') . "' size='10' /></td>";
400
+				}
401
+				echo "<td><input type='text' name='type_description[{$key}]' value='" . $typeObject->getVar('type_description') . "' size='30' /></td>";
402
+				echo '</tr>';
403
+			}
404
+			echo "<tr><td colspan='4' style='text-align:center;'>";
405
+		} else {
406
+			$adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
407
+			$adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
408
+			$adminObject->displayButton('left');
409
+			for ($i = 0; $i < 10; ++$i) {
410
+				echo "<tr class='odd' align='left'>";
411
+				echo "<td><input type='text' name='type_name[{$i}]' value='' size='10' /></td>";
412
+				if ($isColorpicker) {
413
+					$form_colorpicker = new \XoopsFormColorPicker('', "type_color[{$i}]", '');
414
+					echo '<td>' . $form_colorpicker->render() . '</td>';
415
+				} else {
416
+					echo "<td><input type='text' name='type_color[{$i}]' value='' size='10' /></td>";
417
+				}
418
+				echo "<td><input type='text' name='type_description[{$i}]' value='' size='40' /></td>";
419
+				echo '</tr>';
420
+			}
421
+			echo "<tr><td colspan='3' style='text-align:center;'>";
422
+			echo "<input type='hidden' name='isnew' value='1' />";
423
+		}
424
+		echo "<input type='hidden' name='op' value='save_type' />";
425
+		echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
426
+		echo "<input type='reset' value='" . _CANCEL . "' />";
427
+		echo '</td></tr></table>';
428
+		echo '</form>';
429
+		echo '</td></tr></table>';
430
+		echo '<fieldset>';
431
+		echo '<legend>&nbsp;' . _MI_NEWBB_ADMENU_TYPE . '&nbsp;</legend>';
432
+		echo _AM_NEWBB_HELP_TYPE_TAB;
433
+		echo '</fieldset>';
434
+		break;
435 435
 }
436 436
 
437 437
 require_once __DIR__ . '/admin_footer.php';
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 use Xmf\Request;
14 14
 
15
-require_once __DIR__ . '/admin_header.php';
15
+require_once __DIR__.'/admin_header.php';
16 16
 xoops_cp_header();
17 17
 echo '<br>';
18 18
 require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             }
86 86
         }
87 87
         if (count($type_del) > 0) {
88
-            $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', $type_del) . ')', 'IN'));
88
+            $type_list = $typeHandler->getList(new \Criteria('type_id', '('.implode(', ', $type_del).')', 'IN'));
89 89
             xoops_confirm(['op' => 'delete', 'type_del' => serialize($type_del)], xoops_getenv('PHP_SELF'), sprintf(_AM_NEWBB_TODEL_TYPE, implode(', ', array_values($type_list))), '', false);
90 90
         } else {
91 91
             redirect_header(xoops_getenv('PHP_SELF'), 2, _MD_NEWBB_DBUPDATED);
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
         $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE_APPLY, 'admin_type_manager.php?op=apply', $icon = 'add');
116 116
         $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
117 117
         $adminObject->displayButton('left');
118
-        echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_ORDER_DESC . '</legend>';
119
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
120
-        echo "<form name='template' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
118
+        echo '<legend style="font-weight: bold; color: #900;">'._AM_NEWBB_TYPE_ORDER_DESC.'</legend>';
119
+        echo "<table width='100%' border='0' cellspacing='1' class='outer'>"."<tr><td class='odd'>";
120
+        echo "<form name='template' method='post' action='".xoops_getenv('PHP_SELF')."'>";
121 121
         echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
122 122
         echo "<tr align='center'>";
123
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
124
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
125
-        echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
123
+        echo "<th class='bg3' width='20%'>"._AM_NEWBB_TYPE_ORDER.'</th>';
124
+        echo "<th class='bg3' width='20%'>"._AM_NEWBB_TYPE_NAME.'</th>';
125
+        echo "<th class='bg3'>"._AM_NEWBB_TYPE_DESCRIPTION.'</th>';
126 126
         echo '</tr>';
127 127
 
128 128
         if ($templates = $cacheHelper->read('type_template')) {
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
                 }
134 134
                 $typeObject = $typesObject[$key];
135 135
                 echo "<tr class='even' align='left'>";
136
-                echo "<td><input type='text' name='type_order[{$key}]' value='" . $order . "' size='10' /></td>";
137
-                echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
138
-                echo '<td>' . $typeObject->getVar('type_description') . '</td>';
136
+                echo "<td><input type='text' name='type_order[{$key}]' value='".$order."' size='10' /></td>";
137
+                echo "<td><em style='color:".$typeObject->getVar('type_color').";'>".$typeObject->getVar('type_name').'</em></td>';
138
+                echo '<td>'.$typeObject->getVar('type_description').'</td>';
139 139
                 echo '</tr>';
140 140
                 unset($typesObject[$key]);
141 141
             }
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
         foreach ($typesObject as $key => $typeObject) {
145 145
             echo "<tr class='odd' align='left'>";
146 146
             echo "<td><input type='text' name='type_order[{$key}]' value='0' size='10' /></td>";
147
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
148
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
147
+            echo "<td><em style='color:".$typeObject->getVar('type_color').";'>".$typeObject->getVar('type_name').'</em></td>';
148
+            echo '<td>'.$typeObject->getVar('type_description').'</td>';
149 149
             echo '</tr>';
150 150
         }
151 151
 
152 152
         echo "<tr><td colspan='3' style='text-align:center;'>";
153 153
         echo "<input type='hidden' name='op' value='save_template' />";
154
-        echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
155
-        echo "<input type='reset' value='" . _CANCEL . "' />";
154
+        echo "<input type='submit' name='submit' value='"._SUBMIT."' /> ";
155
+        echo "<input type='reset' value='"._CANCEL."' />";
156 156
         echo '</td></tr></table>';
157 157
         echo '</form>';
158 158
         echo '</td></tr></table>';
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
     case 'save_template':
162 162
         $templates = array_flip(array_filter(Request::getArray('type_order', [], 'POST')));
163 163
         $cacheHelper->write('type_template', $templates);
164
-        redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _MD_NEWBB_DBUPDATED);
164
+        redirect_header(xoops_getenv('PHP_SELF').'?op=template', 2, _MD_NEWBB_DBUPDATED);
165 165
         break;
166 166
 
167 167
     case 'apply':
168 168
         if (!$templates = $cacheHelper->read('type_template')) {
169
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE_ERR);
169
+            redirect_header(xoops_getenv('PHP_SELF').'?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE_ERR);
170 170
         }
171 171
 
172 172
         //        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
         //        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
177 177
         $forums = $forumHandler->getTree(array_keys($categories), 0, 'all');
178 178
         foreach (array_keys($forums) as $c) {
179
-            $fm_options[-1 * $c] = '[' . $categories[$c] . ']';
179
+            $fm_options[-1 * $c] = '['.$categories[$c].']';
180 180
             foreach (array_keys($forums[$c]) as $f) {
181
-                $fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'];
181
+                $fm_options[$f] = $forums[$c][$f]['prefix'].$forums[$c][$f]['forum_name'];
182 182
             }
183 183
         }
184 184
         unset($forums, $categories);
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
         $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
200 200
         $adminObject->displayButton('left');
201 201
 
202
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
202
+        echo "<table width='100%' border='0' cellspacing='1' class='outer'>"."<tr><td class='odd'>";
203 203
         echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
204 204
         echo "<tr align='center'>";
205
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
206
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
207
-        echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
205
+        echo "<th class='bg3' width='20%'>"._AM_NEWBB_TYPE_NAME.'</th>';
206
+        echo "<th class='bg3' width='20%'>"._AM_NEWBB_TYPE_ORDER.'</th>';
207
+        echo "<th class='bg3'>"._AM_NEWBB_TYPE_DESCRIPTION.'</th>';
208 208
         echo '</tr>';
209 209
 
210
-        $typesObject = $typeHandler->getAll(new \Criteria('type_id', '(' . implode(', ', array_values($templates)) . ')', 'IN'));
210
+        $typesObject = $typeHandler->getAll(new \Criteria('type_id', '('.implode(', ', array_values($templates)).')', 'IN'));
211 211
         arsort($templates);
212 212
         foreach ($templates as $order => $key) {
213 213
             if (!isset($typesObject[$key])) {
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
             }
216 216
             $typeObject = $typesObject[$key];
217 217
             echo "<tr class='even' align='left'>";
218
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
219
-            echo '<td>' . $order . '</td>';
220
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
218
+            echo "<td><em style='color:".$typeObject->getVar('type_color').";'>".$typeObject->getVar('type_name').'</em></td>';
219
+            echo '<td>'.$order.'</td>';
220
+            echo '<td>'.$typeObject->getVar('type_description').'</td>';
221 221
             echo '</tr>';
222 222
             unset($typesObject[$key]);
223 223
         }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 
230 230
     case 'save_apply':
231 231
         if (!$templates = $cacheHelper->read('type_template')) {
232
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE);
232
+            redirect_header(xoops_getenv('PHP_SELF').'?op=template', 2, _AM_NEWBB_TYPE_TEMPLATE);
233 233
         }
234 234
         foreach (Request::getArray('forums', [], 'POST') as $forum) {
235 235
             if ($forum < 1) {
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
         }
256 256
 
257 257
         foreach (array_keys($forums) as $c) {
258
-            $fm_options[-1 * $c] = '[' . $categories[$c] . ']';
258
+            $fm_options[-1 * $c] = '['.$categories[$c].']';
259 259
             foreach (array_keys($forums[$c]) as $f) {
260
-                $fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'];
260
+                $fm_options[$f] = $forums[$c][$f]['prefix'].$forums[$c][$f]['forum_name'];
261 261
             }
262 262
         }
263 263
         unset($forums, $categories);
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 
283 283
     case 'edit_forum':
284 284
         if (!Request::getInt('forum', 0, 'POST') || Request::getInt('forum', 0, 'POST') < 1) {
285
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
285
+            redirect_header(xoops_getenv('PHP_SELF').'?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
286 286
         }
287 287
 
288 288
         //        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
289 289
         if (!$forumObject = $forumHandler->get(Request::getInt('forum', 0, 'POST'))) {
290
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
290
+            redirect_header(xoops_getenv('PHP_SELF').'?op=forum', 2, _AM_NEWBB_TYPE_FORUM_ERR);
291 291
         }
292 292
 
293 293
         $typesObject = $typeHandler->getAll();
@@ -299,14 +299,14 @@  discard block
 block discarded – undo
299 299
         $adminObject->addItemButton(_AM_NEWBB_TYPE_TEMPLATE, 'admin_type_manager.php?op=template', $icon = 'add');
300 300
         $adminObject->addItemButton(_AM_NEWBB_TYPE_FORUM, 'admin_type_manager.php?op=forum', $icon = 'add');
301 301
         $adminObject->displayButton('left');
302
-        echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_ORDER_DESC . '</legend>';
303
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
304
-        echo "<form name='template' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
302
+        echo '<legend style="font-weight: bold; color: #900;">'._AM_NEWBB_TYPE_ORDER_DESC.'</legend>';
303
+        echo "<table width='100%' border='0' cellspacing='1' class='outer'>"."<tr><td class='odd'>";
304
+        echo "<form name='template' method='post' action='".xoops_getenv('PHP_SELF')."'>";
305 305
         echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
306 306
         echo "<tr align='center'>";
307
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_ORDER . '</th>';
308
-        echo "<th class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
309
-        echo "<th class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
307
+        echo "<th class='bg3' width='20%'>"._AM_NEWBB_TYPE_ORDER.'</th>';
308
+        echo "<th class='bg3' width='20%'>"._AM_NEWBB_TYPE_NAME.'</th>';
309
+        echo "<th class='bg3'>"._AM_NEWBB_TYPE_DESCRIPTION.'</th>';
310 310
         echo '</tr>';
311 311
 
312 312
         $types       = $typeHandler->getByForum(Request::getInt('forum', 0, 'POST'));
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
             }
322 322
             $typeObject = $typesObject[$type['type_id']];
323 323
             echo "<tr class='even' align='left'>";
324
-            echo "<td><input type='text' name='type_order[" . $type['type_id'] . "]' value='" . $type['type_order'] . "' size='10' /></td>";
325
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
326
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
324
+            echo "<td><input type='text' name='type_order[".$type['type_id']."]' value='".$type['type_order']."' size='10' /></td>";
325
+            echo "<td><em style='color:".$typeObject->getVar('type_color').";'>".$typeObject->getVar('type_name').'</em></td>';
326
+            echo '<td>'.$typeObject->getVar('type_description').'</td>';
327 327
             echo '</tr>';
328 328
             unset($typesObject[$type['type_id']]);
329 329
         }
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
         foreach ($typesObject as $key => $typeObject) {
332 332
             echo "<tr class='odd' align='left'>";
333 333
             echo "<td><input type='text' name='type_order[{$key}]' value='0' size='10' /></td>";
334
-            echo "<td><em style='color:" . $typeObject->getVar('type_color') . ";'>" . $typeObject->getVar('type_name') . '</em></td>';
335
-            echo '<td>' . $typeObject->getVar('type_description') . '</td>';
334
+            echo "<td><em style='color:".$typeObject->getVar('type_color').";'>".$typeObject->getVar('type_name').'</em></td>';
335
+            echo '<td>'.$typeObject->getVar('type_description').'</td>';
336 336
             echo '</tr>';
337 337
         }
338 338
 
339 339
         echo "<tr><td colspan='3' style='text-align:center;'>";
340
-        echo '<legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_TYPE_EDITFORUM_DESC . '</legend>';
341
-        echo "<input type='hidden' name='forum' value='" . Request::getInt('forum', 0, 'POST') . "' />";
340
+        echo '<legend style="font-weight: bold; color: #900;">'._AM_NEWBB_TYPE_EDITFORUM_DESC.'</legend>';
341
+        echo "<input type='hidden' name='forum' value='".Request::getInt('forum', 0, 'POST')."' />";
342 342
         echo "<input type='hidden' name='op' value='save_forum' />";
343
-        echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
344
-        echo "<input type='reset' value='" . _CANCEL . "' />";
343
+        echo "<input type='submit' name='submit' value='"._SUBMIT."' /> ";
344
+        echo "<input type='reset' value='"._CANCEL."' />";
345 345
         echo '</td></tr></table>';
346 346
         echo '</form>';
347 347
         echo '</td></tr></table>';
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 
350 350
     case 'save_forum':
351 351
         if (!Request::getInt('forum', 0, 'POST') || Request::getInt('forum', 0, 'POST') < 1) {
352
-            redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _AM_NEWBB_TYPE_FORUM);
352
+            redirect_header(xoops_getenv('PHP_SELF').'?op=forum', 2, _AM_NEWBB_TYPE_FORUM);
353 353
         }
354 354
         $typeHandler->updateByForum(Request::getInt('forum', 0, 'POST'), Request::getArray('type_order', null, 'POST'));
355
-        redirect_header(xoops_getenv('PHP_SELF') . '?op=forum', 2, _MD_NEWBB_DBUPDATED);
355
+        redirect_header(xoops_getenv('PHP_SELF').'?op=forum', 2, _MD_NEWBB_DBUPDATED);
356 356
         break;
357 357
 
358 358
     case 'add':
@@ -372,16 +372,16 @@  discard block
 block discarded – undo
372 372
             $adminObject->displayButton('left');
373 373
         }
374 374
         echo _AM_NEWBB_TYPE_HELP;
375
-        echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'>";
376
-        echo "<form name='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>";
375
+        echo "<table width='100%' border='0' cellspacing='1' class='outer'>"."<tr><td class='odd'>";
376
+        echo "<form name='list' method='post' action='".xoops_getenv('PHP_SELF')."'>";
377 377
         echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
378 378
         echo "<tr align='center'>";
379 379
         if ('add' !== $op) {
380
-            echo "<th class='bg3' width='5%'>" . _DELETE . '</th>';
380
+            echo "<th class='bg3' width='5%'>"._DELETE.'</th>';
381 381
         }
382
-        echo "<th align='left' class='bg3' width='20%'>" . _AM_NEWBB_TYPE_NAME . '</th>';
383
-        echo "<th class='bg3' width='15%'>" . _AM_NEWBB_TYPE_COLOR . '</th>';
384
-        echo "<th align='left' class='bg3'>" . _AM_NEWBB_TYPE_DESCRIPTION . '</th>';
382
+        echo "<th align='left' class='bg3' width='20%'>"._AM_NEWBB_TYPE_NAME.'</th>';
383
+        echo "<th class='bg3' width='15%'>"._AM_NEWBB_TYPE_COLOR.'</th>';
384
+        echo "<th align='left' class='bg3'>"._AM_NEWBB_TYPE_DESCRIPTION.'</th>';
385 385
         echo '</tr>';
386 386
 
387 387
 //        $isColorpicker = require_once $GLOBALS['xoops']->path('class/xoopsform/formcolorpicker.php');
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
             foreach ($typesObject as $key => $typeObject) {
392 392
                 echo "<tr class='odd' align='left'>";
393 393
                 echo "<td><input type='checkbox' name='type_del[{$key}]' /></td>";
394
-                echo "<td><input type='text' name='type_name[{$key}]' value='" . $typeObject->getVar('type_name') . "' size='10' /></td>";
394
+                echo "<td><input type='text' name='type_name[{$key}]' value='".$typeObject->getVar('type_name')."' size='10' /></td>";
395 395
                 if ($isColorpicker) {
396 396
                     $form_colorpicker = new \XoopsFormColorPicker('', "type_color[{$key}]", $typeObject->getVar('type_color'));
397
-                    echo '<td>' . $form_colorpicker->render() . '</td>';
397
+                    echo '<td>'.$form_colorpicker->render().'</td>';
398 398
                 } else {
399
-                    echo "<td><input type='text' name='type_color[{$key}]' value='" . $typeObject->getVar('type_color') . "' size='10' /></td>";
399
+                    echo "<td><input type='text' name='type_color[{$key}]' value='".$typeObject->getVar('type_color')."' size='10' /></td>";
400 400
                 }
401
-                echo "<td><input type='text' name='type_description[{$key}]' value='" . $typeObject->getVar('type_description') . "' size='30' /></td>";
401
+                echo "<td><input type='text' name='type_description[{$key}]' value='".$typeObject->getVar('type_description')."' size='30' /></td>";
402 402
                 echo '</tr>';
403 403
             }
404 404
             echo "<tr><td colspan='4' style='text-align:center;'>";
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
                 echo "<td><input type='text' name='type_name[{$i}]' value='' size='10' /></td>";
412 412
                 if ($isColorpicker) {
413 413
                     $form_colorpicker = new \XoopsFormColorPicker('', "type_color[{$i}]", '');
414
-                    echo '<td>' . $form_colorpicker->render() . '</td>';
414
+                    echo '<td>'.$form_colorpicker->render().'</td>';
415 415
                 } else {
416 416
                     echo "<td><input type='text' name='type_color[{$i}]' value='' size='10' /></td>";
417 417
                 }
@@ -422,16 +422,16 @@  discard block
 block discarded – undo
422 422
             echo "<input type='hidden' name='isnew' value='1' />";
423 423
         }
424 424
         echo "<input type='hidden' name='op' value='save_type' />";
425
-        echo "<input type='submit' name='submit' value='" . _SUBMIT . "' /> ";
426
-        echo "<input type='reset' value='" . _CANCEL . "' />";
425
+        echo "<input type='submit' name='submit' value='"._SUBMIT."' /> ";
426
+        echo "<input type='reset' value='"._CANCEL."' />";
427 427
         echo '</td></tr></table>';
428 428
         echo '</form>';
429 429
         echo '</td></tr></table>';
430 430
         echo '<fieldset>';
431
-        echo '<legend>&nbsp;' . _MI_NEWBB_ADMENU_TYPE . '&nbsp;</legend>';
431
+        echo '<legend>&nbsp;'._MI_NEWBB_ADMENU_TYPE.'&nbsp;</legend>';
432 432
         echo _AM_NEWBB_HELP_TYPE_TAB;
433 433
         echo '</fieldset>';
434 434
         break;
435 435
 }
436 436
 
437
-require_once __DIR__ . '/admin_footer.php';
437
+require_once __DIR__.'/admin_footer.php';
Please login to merge, or discard this patch.
admin/menu.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -39,84 +39,84 @@
 block discarded – undo
39 39
 $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
40 40
 
41 41
 $adminmenu[] = [
42
-    'title' => _MI_NEWBB_ADMENU_INDEX,
43
-    'link'  => 'admin/index.php',
44
-    'icon'  => $pathIcon32 . 'home.png'
42
+	'title' => _MI_NEWBB_ADMENU_INDEX,
43
+	'link'  => 'admin/index.php',
44
+	'icon'  => $pathIcon32 . 'home.png'
45 45
 ];
46 46
 
47 47
 $adminmenu[] = [
48
-    'title' => _MI_NEWBB_ADMENU_CATEGORY,
49
-    'link'  => 'admin/admin_cat_manager.php',
50
-    'icon'  => $pathIcon32 . 'category.png'
48
+	'title' => _MI_NEWBB_ADMENU_CATEGORY,
49
+	'link'  => 'admin/admin_cat_manager.php',
50
+	'icon'  => $pathIcon32 . 'category.png'
51 51
 ];
52 52
 
53 53
 $adminmenu[] = [
54
-    'title' => _MI_NEWBB_ADMENU_FORUM,
55
-    'link'  => 'admin/admin_forum_manager.php',
56
-    'icon'  => $pathIcon32 . 'forums.png'
54
+	'title' => _MI_NEWBB_ADMENU_FORUM,
55
+	'link'  => 'admin/admin_forum_manager.php',
56
+	'icon'  => $pathIcon32 . 'forums.png'
57 57
 ];
58 58
 
59 59
 $adminmenu[] = [
60
-    'title' => _MI_NEWBB_ADMENU_PERMISSION,
61
-    'link'  => 'admin/admin_permissions.php',
62
-    'icon'  => $pathIcon32 . 'permissions.png'
60
+	'title' => _MI_NEWBB_ADMENU_PERMISSION,
61
+	'link'  => 'admin/admin_permissions.php',
62
+	'icon'  => $pathIcon32 . 'permissions.png'
63 63
 ];
64 64
 
65 65
 $adminmenu[] = [
66
-    'title' => _MI_NEWBB_ADMENU_ORDER,
67
-    'link'  => 'admin/admin_forum_reorder.php',
68
-    'icon'  => $pathIcon32 . 'compfile.png'
66
+	'title' => _MI_NEWBB_ADMENU_ORDER,
67
+	'link'  => 'admin/admin_forum_reorder.php',
68
+	'icon'  => $pathIcon32 . 'compfile.png'
69 69
 ];
70 70
 
71 71
 $adminmenu[] = [
72
-    'title' => _MI_NEWBB_ADMENU_PRUNE,
73
-    'link'  => 'admin/admin_forum_prune.php',
74
-    'icon'  => $pathIcon32 . 'update.png'
72
+	'title' => _MI_NEWBB_ADMENU_PRUNE,
73
+	'link'  => 'admin/admin_forum_prune.php',
74
+	'icon'  => $pathIcon32 . 'update.png'
75 75
 ];
76 76
 
77 77
 $adminmenu[] = [
78
-    'title' => _MI_NEWBB_ADMENU_REPORT,
79
-    'link'  => 'admin/admin_report.php',
80
-    'icon'  => $pathIcon32 . 'content.png'
78
+	'title' => _MI_NEWBB_ADMENU_REPORT,
79
+	'link'  => 'admin/admin_report.php',
80
+	'icon'  => $pathIcon32 . 'content.png'
81 81
 ];
82 82
 
83 83
 $adminmenu[] = [
84
-    'title' => _MI_NEWBB_ADMENU_DIGEST,
85
-    'link'  => 'admin/admin_digest.php',
86
-    'icon'  => $pathIcon32 . 'digest.png'
84
+	'title' => _MI_NEWBB_ADMENU_DIGEST,
85
+	'link'  => 'admin/admin_digest.php',
86
+	'icon'  => $pathIcon32 . 'digest.png'
87 87
 ];
88 88
 
89 89
 $adminmenu[] = [
90
-    'title' => _MI_NEWBB_ADMENU_VOTE,
91
-    'link'  => 'admin/admin_votedata.php',
92
-    'icon'  => $pathIcon32 . 'button_ok.png'
90
+	'title' => _MI_NEWBB_ADMENU_VOTE,
91
+	'link'  => 'admin/admin_votedata.php',
92
+	'icon'  => $pathIcon32 . 'button_ok.png'
93 93
 ];
94 94
 
95 95
 $adminmenu[] = [
96
-    'title' => _MI_NEWBB_ADMENU_TYPE,
97
-    'link'  => 'admin/admin_type_manager.php',
98
-    'icon'  => $pathIcon32 . 'type.png'
96
+	'title' => _MI_NEWBB_ADMENU_TYPE,
97
+	'link'  => 'admin/admin_type_manager.php',
98
+	'icon'  => $pathIcon32 . 'type.png'
99 99
 ];
100 100
 
101 101
 $adminmenu[] = [
102
-    'title' => _MI_NEWBB_ADMENU_GROUPMOD,
103
-    'link'  => 'admin/admin_groupmod.php',
104
-    'icon'  => $pathIcon32 . 'groupmod.png'
102
+	'title' => _MI_NEWBB_ADMENU_GROUPMOD,
103
+	'link'  => 'admin/admin_groupmod.php',
104
+	'icon'  => $pathIcon32 . 'groupmod.png'
105 105
 ];
106 106
 
107 107
 $adminmenu[] = [
108
-    'title' => _MI_NEWBB_ADMENU_SYNC,
109
-    'link'  => 'admin/admin_synchronization.php',
110
-    'icon'  => $pathIcon32 . 'synchronized.png'
108
+	'title' => _MI_NEWBB_ADMENU_SYNC,
109
+	'link'  => 'admin/admin_synchronization.php',
110
+	'icon'  => $pathIcon32 . 'synchronized.png'
111 111
 ];
112 112
 
113 113
 $adminmenu[] = [
114
-    'title' => _MI_NEWBB_ADMENU_MIGRATE,
115
-    'link'  => 'admin/migrate.php',
116
-    'icon'  => $pathIcon32 . 'database_go.png'
114
+	'title' => _MI_NEWBB_ADMENU_MIGRATE,
115
+	'link'  => 'admin/migrate.php',
116
+	'icon'  => $pathIcon32 . 'database_go.png'
117 117
 ];
118 118
 $adminmenu[] = [
119
-    'title' => _MI_NEWBB_ADMENU_ABOUT,
120
-    'link'  => 'admin/about.php',
121
-    'icon'  => $pathIcon32 . 'about.png'
119
+	'title' => _MI_NEWBB_ADMENU_ABOUT,
120
+	'link'  => 'admin/about.php',
121
+	'icon'  => $pathIcon32 . 'about.png'
122 122
 ];
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,82 +41,82 @@
 block discarded – undo
41 41
 $adminmenu[] = [
42 42
     'title' => _MI_NEWBB_ADMENU_INDEX,
43 43
     'link'  => 'admin/index.php',
44
-    'icon'  => $pathIcon32 . 'home.png'
44
+    'icon'  => $pathIcon32.'home.png'
45 45
 ];
46 46
 
47 47
 $adminmenu[] = [
48 48
     'title' => _MI_NEWBB_ADMENU_CATEGORY,
49 49
     'link'  => 'admin/admin_cat_manager.php',
50
-    'icon'  => $pathIcon32 . 'category.png'
50
+    'icon'  => $pathIcon32.'category.png'
51 51
 ];
52 52
 
53 53
 $adminmenu[] = [
54 54
     'title' => _MI_NEWBB_ADMENU_FORUM,
55 55
     'link'  => 'admin/admin_forum_manager.php',
56
-    'icon'  => $pathIcon32 . 'forums.png'
56
+    'icon'  => $pathIcon32.'forums.png'
57 57
 ];
58 58
 
59 59
 $adminmenu[] = [
60 60
     'title' => _MI_NEWBB_ADMENU_PERMISSION,
61 61
     'link'  => 'admin/admin_permissions.php',
62
-    'icon'  => $pathIcon32 . 'permissions.png'
62
+    'icon'  => $pathIcon32.'permissions.png'
63 63
 ];
64 64
 
65 65
 $adminmenu[] = [
66 66
     'title' => _MI_NEWBB_ADMENU_ORDER,
67 67
     'link'  => 'admin/admin_forum_reorder.php',
68
-    'icon'  => $pathIcon32 . 'compfile.png'
68
+    'icon'  => $pathIcon32.'compfile.png'
69 69
 ];
70 70
 
71 71
 $adminmenu[] = [
72 72
     'title' => _MI_NEWBB_ADMENU_PRUNE,
73 73
     'link'  => 'admin/admin_forum_prune.php',
74
-    'icon'  => $pathIcon32 . 'update.png'
74
+    'icon'  => $pathIcon32.'update.png'
75 75
 ];
76 76
 
77 77
 $adminmenu[] = [
78 78
     'title' => _MI_NEWBB_ADMENU_REPORT,
79 79
     'link'  => 'admin/admin_report.php',
80
-    'icon'  => $pathIcon32 . 'content.png'
80
+    'icon'  => $pathIcon32.'content.png'
81 81
 ];
82 82
 
83 83
 $adminmenu[] = [
84 84
     'title' => _MI_NEWBB_ADMENU_DIGEST,
85 85
     'link'  => 'admin/admin_digest.php',
86
-    'icon'  => $pathIcon32 . 'digest.png'
86
+    'icon'  => $pathIcon32.'digest.png'
87 87
 ];
88 88
 
89 89
 $adminmenu[] = [
90 90
     'title' => _MI_NEWBB_ADMENU_VOTE,
91 91
     'link'  => 'admin/admin_votedata.php',
92
-    'icon'  => $pathIcon32 . 'button_ok.png'
92
+    'icon'  => $pathIcon32.'button_ok.png'
93 93
 ];
94 94
 
95 95
 $adminmenu[] = [
96 96
     'title' => _MI_NEWBB_ADMENU_TYPE,
97 97
     'link'  => 'admin/admin_type_manager.php',
98
-    'icon'  => $pathIcon32 . 'type.png'
98
+    'icon'  => $pathIcon32.'type.png'
99 99
 ];
100 100
 
101 101
 $adminmenu[] = [
102 102
     'title' => _MI_NEWBB_ADMENU_GROUPMOD,
103 103
     'link'  => 'admin/admin_groupmod.php',
104
-    'icon'  => $pathIcon32 . 'groupmod.png'
104
+    'icon'  => $pathIcon32.'groupmod.png'
105 105
 ];
106 106
 
107 107
 $adminmenu[] = [
108 108
     'title' => _MI_NEWBB_ADMENU_SYNC,
109 109
     'link'  => 'admin/admin_synchronization.php',
110
-    'icon'  => $pathIcon32 . 'synchronized.png'
110
+    'icon'  => $pathIcon32.'synchronized.png'
111 111
 ];
112 112
 
113 113
 $adminmenu[] = [
114 114
     'title' => _MI_NEWBB_ADMENU_MIGRATE,
115 115
     'link'  => 'admin/migrate.php',
116
-    'icon'  => $pathIcon32 . 'database_go.png'
116
+    'icon'  => $pathIcon32.'database_go.png'
117 117
 ];
118 118
 $adminmenu[] = [
119 119
     'title' => _MI_NEWBB_ADMENU_ABOUT,
120 120
     'link'  => 'admin/about.php',
121
-    'icon'  => $pathIcon32 . 'about.png'
121
+    'icon'  => $pathIcon32.'about.png'
122 122
 ];
Please login to merge, or discard this patch.
class/Common/Configurator.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -27,35 +27,35 @@
 block discarded – undo
27 27
  */
28 28
 class Configurator
29 29
 {
30
-    public $name;
31
-    public $paths           = [];
32
-    public $uploadFolders   = [];
33
-    public $copyBlankFiles  = [];
34
-    public $copyTestFolders = [];
35
-    public $templateFolders = [];
36
-    public $oldFiles        = [];
37
-    public $oldFolders      = [];
38
-    public $modCopyright;
30
+	public $name;
31
+	public $paths           = [];
32
+	public $uploadFolders   = [];
33
+	public $copyBlankFiles  = [];
34
+	public $copyTestFolders = [];
35
+	public $templateFolders = [];
36
+	public $oldFiles        = [];
37
+	public $oldFolders      = [];
38
+	public $modCopyright;
39 39
 
40
-    /**
41
-     * Configurator constructor.
42
-     */
43
-    public function __construct()
44
-    {
45
-        $moduleDirName = basename(dirname(dirname(__DIR__)));
46
-        $capsDirName   = strtoupper($moduleDirName);
40
+	/**
41
+	 * Configurator constructor.
42
+	 */
43
+	public function __construct()
44
+	{
45
+		$moduleDirName = basename(dirname(dirname(__DIR__)));
46
+		$capsDirName   = strtoupper($moduleDirName);
47 47
 
48
-        require_once  dirname(dirname(__DIR__)) . '/include/config.php';
49
-        $config = getConfig();
48
+		require_once  dirname(dirname(__DIR__)) . '/include/config.php';
49
+		$config = getConfig();
50 50
 
51
-        $this->name            = $config->name;
52
-        $this->paths           = $config->paths;
53
-        $this->uploadFolders   = $config->uploadFolders;
54
-        $this->copyBlankFiles  = $config->copyBlankFiles;
55
-        $this->copyTestFolders = $config->copyTestFolders;
56
-        $this->templateFolders = $config->templateFolders;
57
-        $this->oldFiles        = $config->oldFiles;
58
-        $this->oldFolders      = $config->oldFolders;
59
-        $this->modCopyright    = $config->modCopyright;
60
-    }
51
+		$this->name            = $config->name;
52
+		$this->paths           = $config->paths;
53
+		$this->uploadFolders   = $config->uploadFolders;
54
+		$this->copyBlankFiles  = $config->copyBlankFiles;
55
+		$this->copyTestFolders = $config->copyTestFolders;
56
+		$this->templateFolders = $config->templateFolders;
57
+		$this->oldFiles        = $config->oldFiles;
58
+		$this->oldFolders      = $config->oldFolders;
59
+		$this->modCopyright    = $config->modCopyright;
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
         $moduleDirName = basename(dirname(dirname(__DIR__)));
46 46
         $capsDirName   = strtoupper($moduleDirName);
47 47
 
48
-        require_once  dirname(dirname(__DIR__)) . '/include/config.php';
48
+        require_once  dirname(dirname(__DIR__)).'/include/config.php';
49 49
         $config = getConfig();
50 50
 
51 51
         $this->name            = $config->name;
Please login to merge, or discard this patch.
class/Common/VersionChecks.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -17,63 +17,63 @@
 block discarded – undo
17 17
  */
18 18
 trait VersionChecks
19 19
 {
20
-    /**
21
-     *
22
-     * Verifies XOOPS version meets minimum requirements for this module
23
-     * @static
24
-     * @param \XoopsModule $module
25
-     *
26
-     * @param null|string  $requiredVer
27
-     * @return bool true if meets requirements, false if not
28
-     */
29
-    public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
30
-    {
31
-        $moduleDirName = basename(dirname(dirname(__DIR__)));
32
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
33
-        if (null === $module) {
34
-            $module = \XoopsModule::getByDirname($moduleDirName);
35
-        }
36
-        xoops_loadLanguage('admin', $moduleDirName);
20
+	/**
21
+	 *
22
+	 * Verifies XOOPS version meets minimum requirements for this module
23
+	 * @static
24
+	 * @param \XoopsModule $module
25
+	 *
26
+	 * @param null|string  $requiredVer
27
+	 * @return bool true if meets requirements, false if not
28
+	 */
29
+	public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
30
+	{
31
+		$moduleDirName = basename(dirname(dirname(__DIR__)));
32
+		$moduleDirNameUpper   = strtoupper($moduleDirName);
33
+		if (null === $module) {
34
+			$module = \XoopsModule::getByDirname($moduleDirName);
35
+		}
36
+		xoops_loadLanguage('admin', $moduleDirName);
37 37
 
38
-        //check for minimum XOOPS version
39
-        $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
40
-        if (null === $requiredVer) {
41
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
42
-        }
43
-        $success = true;
38
+		//check for minimum XOOPS version
39
+		$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
40
+		if (null === $requiredVer) {
41
+			$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
42
+		}
43
+		$success = true;
44 44
 
45
-        if (version_compare($currentVer, $requiredVer, '<')) {
46
-            $success = false;
47
-            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
48
-        }
45
+		if (version_compare($currentVer, $requiredVer, '<')) {
46
+			$success = false;
47
+			$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
48
+		}
49 49
 
50
-        return $success;
51
-    }
50
+		return $success;
51
+	}
52 52
 
53
-    /**
54
-     *
55
-     * Verifies PHP version meets minimum requirements for this module
56
-     * @static
57
-     * @param \XoopsModule $module
58
-     *
59
-     * @return bool true if meets requirements, false if not
60
-     */
61
-    public static function checkVerPhp(\XoopsModule $module)
62
-    {
63
-        $moduleDirName = basename(dirname(dirname(__DIR__)));
64
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
65
-        xoops_loadLanguage('admin', $module->dirname());
66
-        // check for minimum PHP version
67
-        $success = true;
68
-        $verNum  = PHP_VERSION;
69
-        $reqVer  = $module->getInfo('min_php');
70
-        if (false !== $reqVer && '' !== $reqVer) {
71
-            if (version_compare($verNum, $reqVer, '<')) {
72
-                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
73
-                $success = false;
74
-            }
75
-        }
53
+	/**
54
+	 *
55
+	 * Verifies PHP version meets minimum requirements for this module
56
+	 * @static
57
+	 * @param \XoopsModule $module
58
+	 *
59
+	 * @return bool true if meets requirements, false if not
60
+	 */
61
+	public static function checkVerPhp(\XoopsModule $module)
62
+	{
63
+		$moduleDirName = basename(dirname(dirname(__DIR__)));
64
+		$moduleDirNameUpper   = strtoupper($moduleDirName);
65
+		xoops_loadLanguage('admin', $module->dirname());
66
+		// check for minimum PHP version
67
+		$success = true;
68
+		$verNum  = PHP_VERSION;
69
+		$reqVer  = $module->getInfo('min_php');
70
+		if (false !== $reqVer && '' !== $reqVer) {
71
+			if (version_compare($verNum, $reqVer, '<')) {
72
+				$module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
73
+				$success = false;
74
+			}
75
+		}
76 76
 
77
-        return $success;
78
-    }
77
+		return $success;
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
30 30
     {
31 31
         $moduleDirName = basename(dirname(dirname(__DIR__)));
32
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
32
+        $moduleDirNameUpper = strtoupper($moduleDirName);
33 33
         if (null === $module) {
34 34
             $module = \XoopsModule::getByDirname($moduleDirName);
35 35
         }
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
         //check for minimum XOOPS version
39 39
         $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
40 40
         if (null === $requiredVer) {
41
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
41
+            $requiredVer = ''.$module->getInfo('min_xoops'); //making sure it's a string
42 42
         }
43 43
         $success = true;
44 44
 
45 45
         if (version_compare($currentVer, $requiredVer, '<')) {
46 46
             $success = false;
47
-            $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
47
+            $module->setErrors(sprintf(constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_XOOPS'), $requiredVer, $currentVer));
48 48
         }
49 49
 
50 50
         return $success;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     public static function checkVerPhp(\XoopsModule $module)
62 62
     {
63 63
         $moduleDirName = basename(dirname(dirname(__DIR__)));
64
-        $moduleDirNameUpper   = strtoupper($moduleDirName);
64
+        $moduleDirNameUpper = strtoupper($moduleDirName);
65 65
         xoops_loadLanguage('admin', $module->dirname());
66 66
         // check for minimum PHP version
67 67
         $success = true;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $reqVer  = $module->getInfo('min_php');
70 70
         if (false !== $reqVer && '' !== $reqVer) {
71 71
             if (version_compare($verNum, $reqVer, '<')) {
72
-                $module->setErrors(sprintf(constant('CO_' . $moduleDirNameUpper . '_ERROR_BAD_PHP'), $reqVer, $verNum));
72
+                $module->setErrors(sprintf(constant('CO_'.$moduleDirNameUpper.'_ERROR_BAD_PHP'), $reqVer, $verNum));
73 73
                 $success = false;
74 74
             }
75 75
         }
Please login to merge, or discard this patch.
class/Common/Migrate.php 2 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -22,96 +22,96 @@
 block discarded – undo
22 22
  */
23 23
 class Migrate extends \Xmf\Database\Migrate
24 24
 {
25
-    private $renameTables;
25
+	private $renameTables;
26 26
 
27
-    /**
28
-     * Migrate constructor.
29
-     * @throws \RuntimeException
30
-     * @throws \InvalidArgumentException
31
-     */
32
-    public function __construct()
33
-    {   require_once  dirname(dirname(__DIR__)) . '/include/config.php';
34
-        $config = getConfig();
35
-        $this->renameTables            = $config->renameTables;
27
+	/**
28
+	 * Migrate constructor.
29
+	 * @throws \RuntimeException
30
+	 * @throws \InvalidArgumentException
31
+	 */
32
+	public function __construct()
33
+	{   require_once  dirname(dirname(__DIR__)) . '/include/config.php';
34
+		$config = getConfig();
35
+		$this->renameTables            = $config->renameTables;
36 36
 
37
-        $moduleDirName = basename(dirname(dirname(__DIR__)));
38
-        parent::__construct($moduleDirName);
39
-    }
37
+		$moduleDirName = basename(dirname(dirname(__DIR__)));
38
+		parent::__construct($moduleDirName);
39
+	}
40 40
 
41
-    /**
42
-     * change table prefix if needed
43
-     */
44
-    private function changePrefix()
45
-    {
46
-        foreach ($this->renameTables as $oldName => $newName) {
47
-            if ($this->tableHandler->useTable($oldName)) {
48
-                $this->tableHandler->renameTable($oldName, $newName);
49
-            }
50
-        }
51
-    }
41
+	/**
42
+	 * change table prefix if needed
43
+	 */
44
+	private function changePrefix()
45
+	{
46
+		foreach ($this->renameTables as $oldName => $newName) {
47
+			if ($this->tableHandler->useTable($oldName)) {
48
+				$this->tableHandler->renameTable($oldName, $newName);
49
+			}
50
+		}
51
+	}
52 52
 
53
-    /**
54
-     * Change integer IPv4 column to varchar IPv6 capable
55
-     *
56
-     * @param string $tableName  table to convert
57
-     * @param string $columnName column with IP address
58
-     *
59
-     * @return void
60
-     */
61
-    private function convertIPAddresses($tableName, $columnName)
62
-    {
63
-        if ($this->tableHandler->useTable($tableName)) {
64
-            $attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName);
65
-            if (false !== strpos($attributes, ' int(')) {
66
-                if (false === strpos($attributes, 'unsigned')) {
67
-                    $this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL  DEFAULT '0' ");
68
-                    $this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false);
69
-                }
70
-                $this->tableHandler->alterColumn($tableName, $columnName, " varchar(45)  NOT NULL  DEFAULT '' ");
71
-                $this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false);
72
-            }
73
-        }
74
-    }
53
+	/**
54
+	 * Change integer IPv4 column to varchar IPv6 capable
55
+	 *
56
+	 * @param string $tableName  table to convert
57
+	 * @param string $columnName column with IP address
58
+	 *
59
+	 * @return void
60
+	 */
61
+	private function convertIPAddresses($tableName, $columnName)
62
+	{
63
+		if ($this->tableHandler->useTable($tableName)) {
64
+			$attributes = $this->tableHandler->getColumnAttributes($tableName, $columnName);
65
+			if (false !== strpos($attributes, ' int(')) {
66
+				if (false === strpos($attributes, 'unsigned')) {
67
+					$this->tableHandler->alterColumn($tableName, $columnName, " bigint(16) NOT NULL  DEFAULT '0' ");
68
+					$this->tableHandler->update($tableName, [$columnName => "4294967296 + $columnName"], "WHERE $columnName < 0", false);
69
+				}
70
+				$this->tableHandler->alterColumn($tableName, $columnName, " varchar(45)  NOT NULL  DEFAULT '' ");
71
+				$this->tableHandler->update($tableName, [$columnName => "INET_NTOA($columnName)"], '', false);
72
+			}
73
+		}
74
+	}
75 75
 
76
-    /**
77
-     * Move do* columns from newbb_posts to newbb_posts_text table
78
-     *
79
-     * @return void
80
-     */
81
-    private function moveDoColumns()
82
-    {
83
-        $tableName    = 'newbb_posts_text';
84
-        $srcTableName = 'newbb_posts';
85
-        if (false !== $this->tableHandler->useTable($tableName)
86
-            && false !== $this->tableHandler->useTable($srcTableName)) {
87
-            $attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml');
88
-            if (false === $attributes) {
89
-                $this->synchronizeTable($tableName);
90
-                $updateTable = $GLOBALS['xoopsDB']->prefix($tableName);
91
-                $joinTable   = $GLOBALS['xoopsDB']->prefix($srcTableName);
92
-                $sql         = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml,  t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . '  , t1.doimage = t2.doimage, t1.dobr = t2.dobr';
93
-                $this->tableHandler->addToQueue($sql);
94
-            }
95
-        }
96
-    }
76
+	/**
77
+	 * Move do* columns from newbb_posts to newbb_posts_text table
78
+	 *
79
+	 * @return void
80
+	 */
81
+	private function moveDoColumns()
82
+	{
83
+		$tableName    = 'newbb_posts_text';
84
+		$srcTableName = 'newbb_posts';
85
+		if (false !== $this->tableHandler->useTable($tableName)
86
+			&& false !== $this->tableHandler->useTable($srcTableName)) {
87
+			$attributes = $this->tableHandler->getColumnAttributes($tableName, 'dohtml');
88
+			if (false === $attributes) {
89
+				$this->synchronizeTable($tableName);
90
+				$updateTable = $GLOBALS['xoopsDB']->prefix($tableName);
91
+				$joinTable   = $GLOBALS['xoopsDB']->prefix($srcTableName);
92
+				$sql         = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml,  t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . '  , t1.doimage = t2.doimage, t1.dobr = t2.dobr';
93
+				$this->tableHandler->addToQueue($sql);
94
+			}
95
+		}
96
+	}
97 97
 
98
-    /**
99
-     * Perform any upfront actions before synchronizing the schema
100
-     *
101
-     * Some typical uses include
102
-     *   table and column renames
103
-     *   data conversions
104
-     *
105
-     * @return void
106
-     */
107
-    protected function preSyncActions()
108
-    {
109
-        // change 'bb' table prefix to 'newbb'
110
-        $this->changePrefix();
111
-        // columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
112
-        $this->moveDoColumns();
113
-        // Convert IP address columns from int to readable varchar(45) for IPv6
114
-        $this->convertIPAddresses('newbb_posts', 'poster_ip');
115
-        $this->convertIPAddresses('newbb_report', 'reporter_ip');
116
-    }
98
+	/**
99
+	 * Perform any upfront actions before synchronizing the schema
100
+	 *
101
+	 * Some typical uses include
102
+	 *   table and column renames
103
+	 *   data conversions
104
+	 *
105
+	 * @return void
106
+	 */
107
+	protected function preSyncActions()
108
+	{
109
+		// change 'bb' table prefix to 'newbb'
110
+		$this->changePrefix();
111
+		// columns dohtml, dosmiley, doxcode, doimage and dobr moved between tables as some point
112
+		$this->moveDoColumns();
113
+		// Convert IP address columns from int to readable varchar(45) for IPv6
114
+		$this->convertIPAddresses('newbb_posts', 'poster_ip');
115
+		$this->convertIPAddresses('newbb_report', 'reporter_ip');
116
+	}
117 117
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
      * @throws \InvalidArgumentException
31 31
      */
32 32
     public function __construct()
33
-    {   require_once  dirname(dirname(__DIR__)) . '/include/config.php';
33
+    {   require_once  dirname(dirname(__DIR__)).'/include/config.php';
34 34
         $config = getConfig();
35
-        $this->renameTables            = $config->renameTables;
35
+        $this->renameTables = $config->renameTables;
36 36
 
37 37
         $moduleDirName = basename(dirname(dirname(__DIR__)));
38 38
         parent::__construct($moduleDirName);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                 $this->synchronizeTable($tableName);
90 90
                 $updateTable = $GLOBALS['xoopsDB']->prefix($tableName);
91 91
                 $joinTable   = $GLOBALS['xoopsDB']->prefix($srcTableName);
92
-                $sql         = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n" . "SET t1.dohtml = t2.dohtml,  t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n" . '  , t1.doimage = t2.doimage, t1.dobr = t2.dobr';
92
+                $sql         = "UPDATE `$updateTable` t1 INNER JOIN `$joinTable` t2 ON t1.post_id = t2.post_id \n"."SET t1.dohtml = t2.dohtml,  t1.dosmiley = t2.dosmiley, t1.doxcode = t2.doxcode\n".'  , t1.doimage = t2.doimage, t1.dobr = t2.dobr';
93 93
                 $this->tableHandler->addToQueue($sql);
94 94
             }
95 95
         }
Please login to merge, or discard this patch.
class/RateHandler.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -39,32 +39,32 @@
 block discarded – undo
39 39
  */
40 40
 class RateHandler extends \XoopsPersistableObjectHandler
41 41
 {
42
-    /**
43
-     * @param \XoopsDatabase $db
44
-     */
45
-    public function __construct(\XoopsDatabase $db = null)
46
-    {
47
-        parent::__construct($db, 'newbb_votedata', Rate::class, 'ratingid', '');
48
-    }
42
+	/**
43
+	 * @param \XoopsDatabase $db
44
+	 */
45
+	public function __construct(\XoopsDatabase $db = null)
46
+	{
47
+		parent::__construct($db, 'newbb_votedata', Rate::class, 'ratingid', '');
48
+	}
49 49
 
50
-    /**
51
-     *
52
-     */
53
-    public function synchronization()
54
-    {
55
-        //        return;
56
-    }
50
+	/**
51
+	 *
52
+	 */
53
+	public function synchronization()
54
+	{
55
+		//        return;
56
+	}
57 57
 
58
-    /**
59
-     * clean orphan items from database
60
-     *
61
-     * @param  string $table_link
62
-     * @param  string $field_link
63
-     * @param  string $field_object
64
-     * @return bool   true on success
65
-     */
66
-    public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
67
-    {
68
-        return parent::cleanOrphan($this->db->prefix('newbb_topics'), 'topic_id');
69
-    }
58
+	/**
59
+	 * clean orphan items from database
60
+	 *
61
+	 * @param  string $table_link
62
+	 * @param  string $field_link
63
+	 * @param  string $field_object
64
+	 * @return bool   true on success
65
+	 */
66
+	public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
67
+	{
68
+		return parent::cleanOrphan($this->db->prefix('newbb_topics'), 'topic_id');
69
+	}
70 70
 }
Please login to merge, or discard this patch.
class/PostHandler.php 2 patches
Indentation   +545 added lines, -545 removed lines patch added patch discarded remove patch
@@ -41,555 +41,555 @@
 block discarded – undo
41 41
  */
42 42
 class PostHandler extends \XoopsPersistableObjectHandler
43 43
 {
44
-    /**
45
-     * @param \XoopsDatabase $db
46
-     */
47
-    public function __construct(\XoopsDatabase $db = null)
48
-    {
49
-        parent::__construct($db, 'newbb_posts', Post::class, 'post_id', 'subject');
50
-    }
51
-
52
-    /**
53
-     * @param  mixed $id
54
-     * @param  null  $var
55
-     * @return null|\XoopsObject
56
-     */
57
-    public function get($id = null, $var = null) //get($id)
58
-    {
59
-        $id   = (int)$id;
60
-        $post = null;
61
-        $sql  = 'SELECT p.*, t.* FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id;
62
-        if ($array = $this->db->fetchArray($this->db->query($sql))) {
63
-            $post = $this->create(false);
64
-            $post->assignVars($array);
65
-        }
66
-
67
-        return $post;
68
-    }
69
-
70
-    /**
71
-     * @param  int             $limit
72
-     * @param  int             $start
73
-     * @param  \CriteriaElement $criteria
74
-     * @param  null            $fields
75
-     * @param  bool            $asObject
76
-     * @param  int             $topic_id
77
-     * @param  int             $approved
78
-     * @return array
79
-     */
80
-    //    public function getByLimit($topic_id, $limit, $approved = 1)
81
-    public function &getByLimit(
82
-        $limit = 0,
83
-        $start = 0,
84
-        \CriteriaElement $criteria = null,
85
-        $fields = null,
86
-        $asObject = true,
87
-        $topic_id = 0,
88
-        $approved = 1
89
-    ) {
90
-        $sql    = 'SELECT p.*, t.*, tp.topic_status FROM '
91
-                  . $this->db->prefix('newbb_posts')
92
-                  . ' p LEFT JOIN '
93
-                  . $this->db->prefix('newbb_posts_text')
94
-                  . ' t ON p.post_id=t.post_id LEFT JOIN '
95
-                  . $this->db->prefix('newbb_topics')
96
-                  . ' tp ON tp.topic_id=p.topic_id WHERE p.topic_id='
97
-                  . $topic_id
98
-                  . ' AND p.approved ='
99
-                  . $approved
100
-                  . ' ORDER BY p.post_time DESC';
101
-        $result = $this->db->query($sql, $limit, 0);
102
-        $ret    = [];
103
-        while (false !== ($myrow = $this->db->fetchArray($result))) {
104
-            $post = $this->create(false);
105
-            $post->assignVars($myrow);
106
-
107
-            $ret[$myrow['post_id']] = $post;
108
-            unset($post);
109
-        }
110
-
111
-        return $ret;
112
-    }
113
-
114
-    /**
115
-     * @param Post $post
116
-     * @return mixed
117
-     */
118
-    public function getPostForPDF(&$post)
119
-    {
120
-        return $post->getPostBody(true);
121
-    }
122
-
123
-    /**
124
-     * @param Post $post
125
-     * @return mixed
126
-     */
127
-    public function getPostForPrint(&$post)
128
-    {
129
-        return $post->getPostBody();
130
-    }
131
-
132
-    /**
133
-     * @param  int|Post|\XoopsObject $post
134
-     * @param  bool $force
135
-     * @return bool
136
-     */
137
-    public function approve(&$post, $force = false)
138
-    {
139
-        if (empty($post)) {
140
-            return false;
141
-        }
142
-        if (is_numeric($post)) {
143
-            $post = $this->get($post);
144
-        }
145
-
146
-        $wasApproved = $post->getVar('approved');
147
-        // irmtfan approve post if the approved = 0 (pending) or -1 (deleted)
148
-        if (empty($force) && $wasApproved > 0) {
149
-            return true;
150
-        }
151
-        $post->setVar('approved', 1);
152
-        $this->insert($post, true);
153
-
154
-        /** @var Newbb\TopicHandler $topicHandler */
155
-        $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
156
-        $topicObject  = $topicHandler->get($post->getVar('topic_id'));
157
-        if ($topicObject->getVar('topic_last_post_id') < $post->getVar('post_id')) {
158
-            $topicObject->setVar('topic_last_post_id', $post->getVar('post_id'));
159
-        }
160
-        if ($post->isTopic()) {
161
-            $topicObject->setVar('approved', 1);
162
-        } else {
163
-            $topicObject->setVar('topic_replies', $topicObject->getVar('topic_replies') + 1);
164
-        }
165
-        $topicHandler->insert($topicObject, true);
166
-
167
-        /** @var Newbb\ForumHandler $forumHandler */
168
-        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
169
-        $forumObject  = $forumHandler->get($post->getVar('forum_id'));
170
-        if ($forumObject->getVar('forum_last_post_id') < $post->getVar('post_id')) {
171
-            $forumObject->setVar('forum_last_post_id', $post->getVar('post_id'));
172
-        }
173
-        $forumObject->setVar('forum_posts', $forumObject->getVar('forum_posts') + 1);
174
-        if ($post->isTopic()) {
175
-            $forumObject->setVar('forum_topics', $forumObject->getVar('forum_topics') + 1);
176
-        }
177
-        $forumHandler->insert($forumObject, true);
178
-
179
-        // Update user stats
180
-        if ($post->getVar('uid') > 0) {
181
-            /** @var \XoopsMemberHandler $memberHandler */
182
-            $memberHandler = xoops_getHandler('member');
183
-            $poster        = $memberHandler->getUser($post->getVar('uid'));
184
-            if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
185
-                $poster->setVar('posts', $poster->getVar('posts') + 1);
186
-                $res = $memberHandler->insertUser($poster, true);
187
-                unset($poster);
188
-            }
189
-        }
190
-
191
-        // Update forum stats
192
-        /** @var StatsHandler $statsHandler */
193
-        $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats');
194
-        $statsHandler->update($post->getVar('forum_id'), 'post');
195
-        if ($post->isTopic()) {
196
-            $statsHandler->update($post->getVar('forum_id'), 'topic');
197
-        }
198
-
199
-        return true;
200
-    }
201
-
202
-    /**
203
-     * @param \XoopsObject $post
204
-     * @param  bool        $force
205
-     * @return bool
206
-     */
207
-    public function insert(\XoopsObject $post, $force = true) //insert(&$post, $force = true)
208
-    {
209
-        $topicObject = null;
210
-        // Set the post time
211
-        // The time should be "publish" time. To be adjusted later
212
-        if (!$post->getVar('post_time')) {
213
-            $post->setVar('post_time', time());
214
-        }
215
-
216
-        /** @var Newbb\TopicHandler $topicHandler */
217
-        $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
218
-        // Verify the topic ID
219
-        if ($topic_id = $post->getVar('topic_id')) {
220
-            $topicObject = $topicHandler->get($topic_id);
221
-            // Invalid topic OR the topic is no approved and the post is not top post
222
-            if (!$topicObject//    || (!$post->isTopic() && $topicObject->getVar("approved") < 1)
223
-            ) {
224
-                return false;
225
-            }
226
-        }
227
-        if (empty($topic_id)) {
228
-            $post->setVar('topic_id', 0);
229
-            $post->setVar('pid', 0);
230
-            $post->setNew();
231
-            $topicObject = $topicHandler->create();
232
-        }
233
-        $textHandler    = Newbb\Helper::getInstance()->getHandler('Text');
234
-        $post_text_vars = ['post_text', 'post_edit', 'dohtml', 'doxcode', 'dosmiley', 'doimage', 'dobr'];
235
-        if ($post->isNew()) {
236
-            if (!$topic_id = $post->getVar('topic_id')) {
237
-                $topicObject->setVar('topic_title', $post->getVar('subject', 'n'));
238
-                $topicObject->setVar('topic_poster', $post->getVar('uid'));
239
-                $topicObject->setVar('forum_id', $post->getVar('forum_id'));
240
-                $topicObject->setVar('topic_time', $post->getVar('post_time'));
241
-                $topicObject->setVar('poster_name', $post->getVar('poster_name'));
242
-                $topicObject->setVar('approved', $post->getVar('approved'));
243
-
244
-                if (!$topic_id = $topicHandler->insert($topicObject, $force)) {
245
-                    $post->deleteAttachment();
246
-                    $post->setErrors('insert topic error');
247
-
248
-                    //xoops_error($topicObject->getErrors());
249
-                    return false;
250
-                }
251
-                $post->setVar('topic_id', $topic_id);
252
-
253
-                $pid = 0;
254
-                $post->setVar('pid', 0);
255
-            } elseif (!$post->getVar('pid')) {
256
-                $pid = $topicHandler->getTopPostId($topic_id);
257
-                $post->setVar('pid', $pid);
258
-            }
259
-
260
-            $textObject = $textHandler->create();
261
-            foreach ($post_text_vars as $key) {
262
-                $textObject->vars[$key] = $post->vars[$key];
263
-            }
264
-            $post->destroyVars($post_text_vars);
265
-
266
-            //            if (!$post_id = parent::insert($post, $force)) {
267
-            //                return false;
268
-            //            }
269
-
270
-            if (!$post_id = parent::insert($post, $force)) {
271
-                return false;
272
-            } else {
273
-                $post->unsetNew();
274
-            }
275
-
276
-            $textObject->setVar('post_id', $post_id);
277
-            if (!$textHandler->insert($textObject, $force)) {
278
-                $this->delete($post);
279
-                $post->setErrors('post text insert error');
280
-
281
-                //xoops_error($textObject->getErrors());
282
-                return false;
283
-            }
284
-            if ($post->getVar('approved') > 0) {
285
-                $this->approve($post, true);
286
-            }
287
-            $post->setVar('post_id', $post_id);
288
-        } else {
289
-            if ($post->isTopic()) {
290
-                if ($post->getVar('subject') !== $topicObject->getVar('topic_title')) {
291
-                    $topicObject->setVar('topic_title', $post->getVar('subject', 'n'));
292
-                }
293
-                if ($post->getVar('approved') !== $topicObject->getVar('approved')) {
294
-                    $topicObject->setVar('approved', $post->getVar('approved'));
295
-                }
296
-                $topicObject->setDirty();
297
-                if (!$result = $topicHandler->insert($topicObject, $force)) {
298
-                    $post->setErrors('update topic error');
299
-
300
-                    //xoops_error($topicObject->getErrors());
301
-                    return false;
302
-                }
303
-            }
304
-            $textObject = $textHandler->get($post->getVar('post_id'));
305
-            $textObject->setDirty();
306
-            foreach ($post_text_vars as $key) {
307
-                $textObject->vars[$key] = $post->vars[$key];
308
-            }
309
-            $post->destroyVars($post_text_vars);
310
-            if (!$post_id = parent::insert($post, $force)) {
311
-                //xoops_error($post->getErrors());
312
-                return false;
313
-            } else {
314
-                $post->unsetNew();
315
-            }
316
-            if (!$textHandler->insert($textObject, $force)) {
317
-                $post->setErrors('update post text error');
318
-
319
-                //xoops_error($textObject->getErrors());
320
-                return false;
321
-            }
322
-        }
323
-
324
-        return $post->getVar('post_id');
325
-    }
326
-
327
-    /**
328
-     * @param \XoopsObject|Post $post
329
-     * @param  bool        $isDeleteOne
330
-     * @param  bool        $force
331
-     * @return bool
332
-     */
333
-    public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false)
334
-    {
335
-        if (!is_object($post) || 0 == $post->getVar('post_id')) {
336
-            return false;
337
-        }
338
-
339
-        if ($isDeleteOne) {
340
-            if ($post->isTopic()) {
341
-                $criteria = new \CriteriaCompo(new \Criteria('topic_id', $post->getVar('topic_id')));
342
-                $criteria->add(new \Criteria('approved', 1));
343
-                $criteria->add(new \Criteria('pid', 0, '>'));
344
-                if ($this->getPostCount($criteria) > 0) {
345
-                    return false;
346
-                }
347
-            }
348
-
349
-            return $this->myDelete($post, $force);
350
-        } else {
351
-            require_once $GLOBALS['xoops']->path('class/xoopstree.php');
352
-            $mytree = new \XoopsTree($this->db->prefix('newbb_posts'), 'post_id', 'pid');
353
-            $arr    = $mytree->getAllChild($post->getVar('post_id'));
354
-            // irmtfan - delete childs in a reverse order
355
-            for ($i = count($arr) - 1; $i >= 0; $i--) {
356
-                $childpost = $this->create(false);
357
-                $childpost->assignVars($arr[$i]);
358
-                $this->myDelete($childpost, $force);
359
-                unset($childpost);
360
-            }
361
-            $this->myDelete($post, $force);
362
-        }
363
-
364
-        return true;
365
-    }
366
-
367
-    /**
368
-     * @param  Post|\XoopsObject $post
369
-     * @param  bool $force
370
-     * @return bool
371
-     */
372
-    public function myDelete(Post $post, $force = false)
373
-    {
374
-        global $xoopsModule;
375
-
376
-        if (!is_object($post) || 0 == $post->getVar('post_id')) {
377
-            return false;
378
-        }
379
-
380
-        /* Set active post as deleted */
381
-        if ($post->getVar('approved') > 0 && empty($force)) {
382
-            $sql = 'UPDATE ' . $this->db->prefix('newbb_posts') . ' SET approved = -1 WHERE post_id = ' . $post->getVar('post_id');
383
-            if (!$result = $this->db->queryF($sql)) {
384
-            }
385
-            /* delete pending post directly */
386
-        } else {
387
-            $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts'), $post->getVar('post_id'));
388
-            if (!$result = $this->db->queryF($sql)) {
389
-                $post->setErrors('delete post error: ' . $sql);
390
-
391
-                return false;
392
-            }
393
-            $post->deleteAttachment();
394
-
395
-            $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts_text'), $post->getVar('post_id'));
396
-            if (!$result = $this->db->queryF($sql)) {
397
-                $post->setErrors('Could not remove post text: ' . $sql);
398
-
399
-                return false;
400
-            }
401
-        }
402
-
403
-        if ($post->isTopic()) {
404
-            $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
405
-            /** @var Topic $topicObject */
406
-            $topicObject = $topicHandler->get($post->getVar('topic_id'));
407
-            if (is_object($topicObject) && $topicObject->getVar('approved') > 0 && empty($force)) {
408
-                $topiccount_toupdate = 1;
409
-                $topicObject->setVar('approved', -1);
410
-                $topicHandler->insert($topicObject);
411
-                xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
412
-            } else {
413
-                if (is_object($topicObject)) {
414
-                    if ($topicObject->getVar('approved') > 0) {
415
-                        xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
416
-                    }
417
-
418
-                    $poll_id = $topicObject->getVar('poll_id');
419
-                    // START irmtfan poll_module
420
-                    $topicObject->deletePoll($poll_id);
421
-                    // END irmtfan poll_module
422
-                }
423
-
424
-                $sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_topics'), $post->getVar('topic_id'));
425
-                if (!$result = $this->db->queryF($sql)) {
426
-                    //xoops_error($this->db->error());
427
-                }
428
-                $sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_votedata'), $post->getVar('topic_id'));
429
-                if (!$result = $this->db->queryF($sql)) {
430
-                    //xoops_error($this->db->error());
431
-                }
432
-            }
433
-        } else {
434
-            $sql = 'UPDATE ' . $this->db->prefix('newbb_topics') . ' t
44
+	/**
45
+	 * @param \XoopsDatabase $db
46
+	 */
47
+	public function __construct(\XoopsDatabase $db = null)
48
+	{
49
+		parent::__construct($db, 'newbb_posts', Post::class, 'post_id', 'subject');
50
+	}
51
+
52
+	/**
53
+	 * @param  mixed $id
54
+	 * @param  null  $var
55
+	 * @return null|\XoopsObject
56
+	 */
57
+	public function get($id = null, $var = null) //get($id)
58
+	{
59
+		$id   = (int)$id;
60
+		$post = null;
61
+		$sql  = 'SELECT p.*, t.* FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id;
62
+		if ($array = $this->db->fetchArray($this->db->query($sql))) {
63
+			$post = $this->create(false);
64
+			$post->assignVars($array);
65
+		}
66
+
67
+		return $post;
68
+	}
69
+
70
+	/**
71
+	 * @param  int             $limit
72
+	 * @param  int             $start
73
+	 * @param  \CriteriaElement $criteria
74
+	 * @param  null            $fields
75
+	 * @param  bool            $asObject
76
+	 * @param  int             $topic_id
77
+	 * @param  int             $approved
78
+	 * @return array
79
+	 */
80
+	//    public function getByLimit($topic_id, $limit, $approved = 1)
81
+	public function &getByLimit(
82
+		$limit = 0,
83
+		$start = 0,
84
+		\CriteriaElement $criteria = null,
85
+		$fields = null,
86
+		$asObject = true,
87
+		$topic_id = 0,
88
+		$approved = 1
89
+	) {
90
+		$sql    = 'SELECT p.*, t.*, tp.topic_status FROM '
91
+				  . $this->db->prefix('newbb_posts')
92
+				  . ' p LEFT JOIN '
93
+				  . $this->db->prefix('newbb_posts_text')
94
+				  . ' t ON p.post_id=t.post_id LEFT JOIN '
95
+				  . $this->db->prefix('newbb_topics')
96
+				  . ' tp ON tp.topic_id=p.topic_id WHERE p.topic_id='
97
+				  . $topic_id
98
+				  . ' AND p.approved ='
99
+				  . $approved
100
+				  . ' ORDER BY p.post_time DESC';
101
+		$result = $this->db->query($sql, $limit, 0);
102
+		$ret    = [];
103
+		while (false !== ($myrow = $this->db->fetchArray($result))) {
104
+			$post = $this->create(false);
105
+			$post->assignVars($myrow);
106
+
107
+			$ret[$myrow['post_id']] = $post;
108
+			unset($post);
109
+		}
110
+
111
+		return $ret;
112
+	}
113
+
114
+	/**
115
+	 * @param Post $post
116
+	 * @return mixed
117
+	 */
118
+	public function getPostForPDF(&$post)
119
+	{
120
+		return $post->getPostBody(true);
121
+	}
122
+
123
+	/**
124
+	 * @param Post $post
125
+	 * @return mixed
126
+	 */
127
+	public function getPostForPrint(&$post)
128
+	{
129
+		return $post->getPostBody();
130
+	}
131
+
132
+	/**
133
+	 * @param  int|Post|\XoopsObject $post
134
+	 * @param  bool $force
135
+	 * @return bool
136
+	 */
137
+	public function approve(&$post, $force = false)
138
+	{
139
+		if (empty($post)) {
140
+			return false;
141
+		}
142
+		if (is_numeric($post)) {
143
+			$post = $this->get($post);
144
+		}
145
+
146
+		$wasApproved = $post->getVar('approved');
147
+		// irmtfan approve post if the approved = 0 (pending) or -1 (deleted)
148
+		if (empty($force) && $wasApproved > 0) {
149
+			return true;
150
+		}
151
+		$post->setVar('approved', 1);
152
+		$this->insert($post, true);
153
+
154
+		/** @var Newbb\TopicHandler $topicHandler */
155
+		$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
156
+		$topicObject  = $topicHandler->get($post->getVar('topic_id'));
157
+		if ($topicObject->getVar('topic_last_post_id') < $post->getVar('post_id')) {
158
+			$topicObject->setVar('topic_last_post_id', $post->getVar('post_id'));
159
+		}
160
+		if ($post->isTopic()) {
161
+			$topicObject->setVar('approved', 1);
162
+		} else {
163
+			$topicObject->setVar('topic_replies', $topicObject->getVar('topic_replies') + 1);
164
+		}
165
+		$topicHandler->insert($topicObject, true);
166
+
167
+		/** @var Newbb\ForumHandler $forumHandler */
168
+		$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
169
+		$forumObject  = $forumHandler->get($post->getVar('forum_id'));
170
+		if ($forumObject->getVar('forum_last_post_id') < $post->getVar('post_id')) {
171
+			$forumObject->setVar('forum_last_post_id', $post->getVar('post_id'));
172
+		}
173
+		$forumObject->setVar('forum_posts', $forumObject->getVar('forum_posts') + 1);
174
+		if ($post->isTopic()) {
175
+			$forumObject->setVar('forum_topics', $forumObject->getVar('forum_topics') + 1);
176
+		}
177
+		$forumHandler->insert($forumObject, true);
178
+
179
+		// Update user stats
180
+		if ($post->getVar('uid') > 0) {
181
+			/** @var \XoopsMemberHandler $memberHandler */
182
+			$memberHandler = xoops_getHandler('member');
183
+			$poster        = $memberHandler->getUser($post->getVar('uid'));
184
+			if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
185
+				$poster->setVar('posts', $poster->getVar('posts') + 1);
186
+				$res = $memberHandler->insertUser($poster, true);
187
+				unset($poster);
188
+			}
189
+		}
190
+
191
+		// Update forum stats
192
+		/** @var StatsHandler $statsHandler */
193
+		$statsHandler = Newbb\Helper::getInstance()->getHandler('Stats');
194
+		$statsHandler->update($post->getVar('forum_id'), 'post');
195
+		if ($post->isTopic()) {
196
+			$statsHandler->update($post->getVar('forum_id'), 'topic');
197
+		}
198
+
199
+		return true;
200
+	}
201
+
202
+	/**
203
+	 * @param \XoopsObject $post
204
+	 * @param  bool        $force
205
+	 * @return bool
206
+	 */
207
+	public function insert(\XoopsObject $post, $force = true) //insert(&$post, $force = true)
208
+	{
209
+		$topicObject = null;
210
+		// Set the post time
211
+		// The time should be "publish" time. To be adjusted later
212
+		if (!$post->getVar('post_time')) {
213
+			$post->setVar('post_time', time());
214
+		}
215
+
216
+		/** @var Newbb\TopicHandler $topicHandler */
217
+		$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
218
+		// Verify the topic ID
219
+		if ($topic_id = $post->getVar('topic_id')) {
220
+			$topicObject = $topicHandler->get($topic_id);
221
+			// Invalid topic OR the topic is no approved and the post is not top post
222
+			if (!$topicObject//    || (!$post->isTopic() && $topicObject->getVar("approved") < 1)
223
+			) {
224
+				return false;
225
+			}
226
+		}
227
+		if (empty($topic_id)) {
228
+			$post->setVar('topic_id', 0);
229
+			$post->setVar('pid', 0);
230
+			$post->setNew();
231
+			$topicObject = $topicHandler->create();
232
+		}
233
+		$textHandler    = Newbb\Helper::getInstance()->getHandler('Text');
234
+		$post_text_vars = ['post_text', 'post_edit', 'dohtml', 'doxcode', 'dosmiley', 'doimage', 'dobr'];
235
+		if ($post->isNew()) {
236
+			if (!$topic_id = $post->getVar('topic_id')) {
237
+				$topicObject->setVar('topic_title', $post->getVar('subject', 'n'));
238
+				$topicObject->setVar('topic_poster', $post->getVar('uid'));
239
+				$topicObject->setVar('forum_id', $post->getVar('forum_id'));
240
+				$topicObject->setVar('topic_time', $post->getVar('post_time'));
241
+				$topicObject->setVar('poster_name', $post->getVar('poster_name'));
242
+				$topicObject->setVar('approved', $post->getVar('approved'));
243
+
244
+				if (!$topic_id = $topicHandler->insert($topicObject, $force)) {
245
+					$post->deleteAttachment();
246
+					$post->setErrors('insert topic error');
247
+
248
+					//xoops_error($topicObject->getErrors());
249
+					return false;
250
+				}
251
+				$post->setVar('topic_id', $topic_id);
252
+
253
+				$pid = 0;
254
+				$post->setVar('pid', 0);
255
+			} elseif (!$post->getVar('pid')) {
256
+				$pid = $topicHandler->getTopPostId($topic_id);
257
+				$post->setVar('pid', $pid);
258
+			}
259
+
260
+			$textObject = $textHandler->create();
261
+			foreach ($post_text_vars as $key) {
262
+				$textObject->vars[$key] = $post->vars[$key];
263
+			}
264
+			$post->destroyVars($post_text_vars);
265
+
266
+			//            if (!$post_id = parent::insert($post, $force)) {
267
+			//                return false;
268
+			//            }
269
+
270
+			if (!$post_id = parent::insert($post, $force)) {
271
+				return false;
272
+			} else {
273
+				$post->unsetNew();
274
+			}
275
+
276
+			$textObject->setVar('post_id', $post_id);
277
+			if (!$textHandler->insert($textObject, $force)) {
278
+				$this->delete($post);
279
+				$post->setErrors('post text insert error');
280
+
281
+				//xoops_error($textObject->getErrors());
282
+				return false;
283
+			}
284
+			if ($post->getVar('approved') > 0) {
285
+				$this->approve($post, true);
286
+			}
287
+			$post->setVar('post_id', $post_id);
288
+		} else {
289
+			if ($post->isTopic()) {
290
+				if ($post->getVar('subject') !== $topicObject->getVar('topic_title')) {
291
+					$topicObject->setVar('topic_title', $post->getVar('subject', 'n'));
292
+				}
293
+				if ($post->getVar('approved') !== $topicObject->getVar('approved')) {
294
+					$topicObject->setVar('approved', $post->getVar('approved'));
295
+				}
296
+				$topicObject->setDirty();
297
+				if (!$result = $topicHandler->insert($topicObject, $force)) {
298
+					$post->setErrors('update topic error');
299
+
300
+					//xoops_error($topicObject->getErrors());
301
+					return false;
302
+				}
303
+			}
304
+			$textObject = $textHandler->get($post->getVar('post_id'));
305
+			$textObject->setDirty();
306
+			foreach ($post_text_vars as $key) {
307
+				$textObject->vars[$key] = $post->vars[$key];
308
+			}
309
+			$post->destroyVars($post_text_vars);
310
+			if (!$post_id = parent::insert($post, $force)) {
311
+				//xoops_error($post->getErrors());
312
+				return false;
313
+			} else {
314
+				$post->unsetNew();
315
+			}
316
+			if (!$textHandler->insert($textObject, $force)) {
317
+				$post->setErrors('update post text error');
318
+
319
+				//xoops_error($textObject->getErrors());
320
+				return false;
321
+			}
322
+		}
323
+
324
+		return $post->getVar('post_id');
325
+	}
326
+
327
+	/**
328
+	 * @param \XoopsObject|Post $post
329
+	 * @param  bool        $isDeleteOne
330
+	 * @param  bool        $force
331
+	 * @return bool
332
+	 */
333
+	public function delete(\XoopsObject $post, $isDeleteOne = true, $force = false)
334
+	{
335
+		if (!is_object($post) || 0 == $post->getVar('post_id')) {
336
+			return false;
337
+		}
338
+
339
+		if ($isDeleteOne) {
340
+			if ($post->isTopic()) {
341
+				$criteria = new \CriteriaCompo(new \Criteria('topic_id', $post->getVar('topic_id')));
342
+				$criteria->add(new \Criteria('approved', 1));
343
+				$criteria->add(new \Criteria('pid', 0, '>'));
344
+				if ($this->getPostCount($criteria) > 0) {
345
+					return false;
346
+				}
347
+			}
348
+
349
+			return $this->myDelete($post, $force);
350
+		} else {
351
+			require_once $GLOBALS['xoops']->path('class/xoopstree.php');
352
+			$mytree = new \XoopsTree($this->db->prefix('newbb_posts'), 'post_id', 'pid');
353
+			$arr    = $mytree->getAllChild($post->getVar('post_id'));
354
+			// irmtfan - delete childs in a reverse order
355
+			for ($i = count($arr) - 1; $i >= 0; $i--) {
356
+				$childpost = $this->create(false);
357
+				$childpost->assignVars($arr[$i]);
358
+				$this->myDelete($childpost, $force);
359
+				unset($childpost);
360
+			}
361
+			$this->myDelete($post, $force);
362
+		}
363
+
364
+		return true;
365
+	}
366
+
367
+	/**
368
+	 * @param  Post|\XoopsObject $post
369
+	 * @param  bool $force
370
+	 * @return bool
371
+	 */
372
+	public function myDelete(Post $post, $force = false)
373
+	{
374
+		global $xoopsModule;
375
+
376
+		if (!is_object($post) || 0 == $post->getVar('post_id')) {
377
+			return false;
378
+		}
379
+
380
+		/* Set active post as deleted */
381
+		if ($post->getVar('approved') > 0 && empty($force)) {
382
+			$sql = 'UPDATE ' . $this->db->prefix('newbb_posts') . ' SET approved = -1 WHERE post_id = ' . $post->getVar('post_id');
383
+			if (!$result = $this->db->queryF($sql)) {
384
+			}
385
+			/* delete pending post directly */
386
+		} else {
387
+			$sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts'), $post->getVar('post_id'));
388
+			if (!$result = $this->db->queryF($sql)) {
389
+				$post->setErrors('delete post error: ' . $sql);
390
+
391
+				return false;
392
+			}
393
+			$post->deleteAttachment();
394
+
395
+			$sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts_text'), $post->getVar('post_id'));
396
+			if (!$result = $this->db->queryF($sql)) {
397
+				$post->setErrors('Could not remove post text: ' . $sql);
398
+
399
+				return false;
400
+			}
401
+		}
402
+
403
+		if ($post->isTopic()) {
404
+			$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
405
+			/** @var Topic $topicObject */
406
+			$topicObject = $topicHandler->get($post->getVar('topic_id'));
407
+			if (is_object($topicObject) && $topicObject->getVar('approved') > 0 && empty($force)) {
408
+				$topiccount_toupdate = 1;
409
+				$topicObject->setVar('approved', -1);
410
+				$topicHandler->insert($topicObject);
411
+				xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
412
+			} else {
413
+				if (is_object($topicObject)) {
414
+					if ($topicObject->getVar('approved') > 0) {
415
+						xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'thread', $post->getVar('topic_id'));
416
+					}
417
+
418
+					$poll_id = $topicObject->getVar('poll_id');
419
+					// START irmtfan poll_module
420
+					$topicObject->deletePoll($poll_id);
421
+					// END irmtfan poll_module
422
+				}
423
+
424
+				$sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_topics'), $post->getVar('topic_id'));
425
+				if (!$result = $this->db->queryF($sql)) {
426
+					//xoops_error($this->db->error());
427
+				}
428
+				$sql = sprintf('DELETE FROM `%s` WHERE topic_id = %u', $this->db->prefix('newbb_votedata'), $post->getVar('topic_id'));
429
+				if (!$result = $this->db->queryF($sql)) {
430
+					//xoops_error($this->db->error());
431
+				}
432
+			}
433
+		} else {
434
+			$sql = 'UPDATE ' . $this->db->prefix('newbb_topics') . ' t
435 435
                             LEFT JOIN ' . $this->db->prefix('newbb_posts') . ' p ON p.topic_id = t.topic_id
436 436
                             SET t.topic_last_post_id = p.post_id
437 437
                             WHERE t.topic_last_post_id = ' . $post->getVar('post_id') . '
438 438
                                     AND p.post_id = (SELECT MAX(post_id) FROM ' . $this->db->prefix('newbb_posts') . ' WHERE topic_id=t.topic_id)';
439
-            if (!$result = $this->db->queryF($sql)) {
440
-            }
441
-        }
442
-
443
-        $postcount_toupdate = $post->getVar('approved');
444
-
445
-        if ($postcount_toupdate > 0) {
446
-
447
-            // Update user stats
448
-            if ($post->getVar('uid') > 0) {
449
-                /** @var \XoopsMemberHandler $memberHandler */
450
-                $memberHandler = xoops_getHandler('member');
451
-                $poster        = $memberHandler->getUser($post->getVar('uid'));
452
-                if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
453
-                    $poster->setVar('posts', $poster->getVar('posts') - 1);
454
-                    $res = $memberHandler->insertUser($poster, true);
455
-                    unset($poster);
456
-                }
457
-            }
458
-            // irmtfan - just update the pid for approved posts when the post is not topic (pid=0)
459
-            if (!$post->isTopic()) {
460
-                $sql = 'UPDATE ' . $this->db->prefix('newbb_posts') . ' SET pid = ' . $post->getVar('pid') . ' WHERE approved=1 AND pid=' . $post->getVar('post_id');
461
-                if (!$result = $this->db->queryF($sql)) {
462
-                    //xoops_error($this->db->error());
463
-                }
464
-            }
465
-        }
466
-
467
-        return true;
468
-    }
469
-
470
-    // START irmtfan enhance getPostCount when there is join (read_mode = 2)
471
-
472
-    /**
473
-     * @param  null $criteria
474
-     * @param  null $join
475
-     * @return int|null
476
-     */
477
-    public function getPostCount($criteria = null, $join = null)
478
-    {
479
-        // if not join get the count from XOOPS/class/model/stats as before
480
-        if (empty($join)) {
481
-            return parent::getCount($criteria);
482
-        }
483
-
484
-        $sql = 'SELECT COUNT(*) as count' . ' FROM ' . $this->db->prefix('newbb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' AS t ON t.post_id = p.post_id';
485
-        // LEFT JOIN
486
-        $sql .= $join;
487
-        // WHERE
488
-        if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
489
-            $sql .= ' ' . $criteria->renderWhere();
490
-        }
491
-        if (!$result = $this->db->query($sql)) {
492
-            //xoops_error($this->db->error().'<br>'.$sql);
493
-            return null;
494
-        }
495
-        $myrow = $this->db->fetchArray($result);
496
-        $count = $myrow['count'];
497
-
498
-        return $count;
499
-    }
500
-    // END irmtfan enhance getPostCount when there is join (read_mode = 2)
501
-    /*
439
+			if (!$result = $this->db->queryF($sql)) {
440
+			}
441
+		}
442
+
443
+		$postcount_toupdate = $post->getVar('approved');
444
+
445
+		if ($postcount_toupdate > 0) {
446
+
447
+			// Update user stats
448
+			if ($post->getVar('uid') > 0) {
449
+				/** @var \XoopsMemberHandler $memberHandler */
450
+				$memberHandler = xoops_getHandler('member');
451
+				$poster        = $memberHandler->getUser($post->getVar('uid'));
452
+				if (is_object($poster) && $post->getVar('uid') == $poster->getVar('uid')) {
453
+					$poster->setVar('posts', $poster->getVar('posts') - 1);
454
+					$res = $memberHandler->insertUser($poster, true);
455
+					unset($poster);
456
+				}
457
+			}
458
+			// irmtfan - just update the pid for approved posts when the post is not topic (pid=0)
459
+			if (!$post->isTopic()) {
460
+				$sql = 'UPDATE ' . $this->db->prefix('newbb_posts') . ' SET pid = ' . $post->getVar('pid') . ' WHERE approved=1 AND pid=' . $post->getVar('post_id');
461
+				if (!$result = $this->db->queryF($sql)) {
462
+					//xoops_error($this->db->error());
463
+				}
464
+			}
465
+		}
466
+
467
+		return true;
468
+	}
469
+
470
+	// START irmtfan enhance getPostCount when there is join (read_mode = 2)
471
+
472
+	/**
473
+	 * @param  null $criteria
474
+	 * @param  null $join
475
+	 * @return int|null
476
+	 */
477
+	public function getPostCount($criteria = null, $join = null)
478
+	{
479
+		// if not join get the count from XOOPS/class/model/stats as before
480
+		if (empty($join)) {
481
+			return parent::getCount($criteria);
482
+		}
483
+
484
+		$sql = 'SELECT COUNT(*) as count' . ' FROM ' . $this->db->prefix('newbb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' AS t ON t.post_id = p.post_id';
485
+		// LEFT JOIN
486
+		$sql .= $join;
487
+		// WHERE
488
+		if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
489
+			$sql .= ' ' . $criteria->renderWhere();
490
+		}
491
+		if (!$result = $this->db->query($sql)) {
492
+			//xoops_error($this->db->error().'<br>'.$sql);
493
+			return null;
494
+		}
495
+		$myrow = $this->db->fetchArray($result);
496
+		$count = $myrow['count'];
497
+
498
+		return $count;
499
+	}
500
+	// END irmtfan enhance getPostCount when there is join (read_mode = 2)
501
+	/*
502 502
      * TODO: combining viewtopic.php
503 503
      */
504
-    /**
505
-     * @param  null $criteria
506
-     * @param  int  $limit
507
-     * @param  int  $start
508
-     * @param  null $join
509
-     * @return array
510
-     */
511
-    public function getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join = null)
512
-    {
513
-        $ret = [];
514
-        $sql = 'SELECT p.*, t.* ' . ' FROM ' . $this->db->prefix('newbb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' AS t ON t.post_id = p.post_id';
515
-        if (!empty($join)) {
516
-            $sql .= $join;
517
-        }
518
-        if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
519
-            $sql .= ' ' . $criteria->renderWhere();
520
-            if ('' !== $criteria->getSort()) {
521
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
522
-            }
523
-        }
524
-        $result = $this->db->query($sql, (int)$limit, (int)$start);
525
-        if (!$result) {
526
-            //xoops_error($this->db->error());
527
-            return $ret;
528
-        }
529
-        while (false !== ($myrow = $this->db->fetchArray($result))) {
530
-            $post = $this->create(false);
531
-            $post->assignVars($myrow);
532
-            $ret[$myrow['post_id']] = $post;
533
-            unset($post);
534
-        }
535
-
536
-        return $ret;
537
-    }
538
-
539
-    /**
540
-     * @return bool
541
-     */
542
-    public function synchronization()
543
-    {
544
-        //$this->cleanOrphan();
545
-        return true;
546
-    }
547
-
548
-    /**
549
-     * clean orphan items from database
550
-     *
551
-     * @param  string $table_link
552
-     * @param  string $field_link
553
-     * @param  string $field_object
554
-     * @return bool   true on success
555
-     */
556
-    public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
557
-    {
558
-        $this->deleteAll(new \Criteria('post_time', 0), true, true);
559
-        parent::cleanOrphan($this->db->prefix('newbb_topics'), 'topic_id');
560
-        parent::cleanOrphan($this->db->prefix('newbb_posts_text'), 'post_id');
561
-
562
-        $sql = 'DELETE FROM ' . $this->db->prefix('newbb_posts_text') . ' WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM ' . $this->table . ') )';
563
-        if (!$result = $this->db->queryF($sql)) {
564
-            //xoops_error($this->db->error());
565
-            return false;
566
-        }
567
-
568
-        return true;
569
-    }
570
-
571
-    /**
572
-     * clean expired objects from database
573
-     *
574
-     * @param  int $expire time limit for expiration
575
-     * @return bool true on success
576
-     */
577
-    public function cleanExpires($expire = 0)
578
-    {
579
-        // irmtfan if 0 no cleanup look include/plugin.php
580
-        if (!func_num_args()) {
581
-            $newbbConfig = newbbLoadConfig();
582
-            $expire      = isset($newbbConfig['pending_expire']) ? (int)$newbbConfig['pending_expire'] : 7;
583
-            $expire      = $expire * 24 * 3600; // days to seconds
584
-        }
585
-        if (empty($expire)) {
586
-            return false;
587
-        }
588
-        $crit_expire = new \CriteriaCompo(new \Criteria('approved', 0, '<='));
589
-        //if (!empty($expire)) {
590
-        $crit_expire->add(new \Criteria('post_time', time() - (int)$expire, '<'));
591
-
592
-        //}
593
-        return $this->deleteAll($crit_expire, true/*, true*/);
594
-    }
504
+	/**
505
+	 * @param  null $criteria
506
+	 * @param  int  $limit
507
+	 * @param  int  $start
508
+	 * @param  null $join
509
+	 * @return array
510
+	 */
511
+	public function getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join = null)
512
+	{
513
+		$ret = [];
514
+		$sql = 'SELECT p.*, t.* ' . ' FROM ' . $this->db->prefix('newbb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' AS t ON t.post_id = p.post_id';
515
+		if (!empty($join)) {
516
+			$sql .= $join;
517
+		}
518
+		if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
519
+			$sql .= ' ' . $criteria->renderWhere();
520
+			if ('' !== $criteria->getSort()) {
521
+				$sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
522
+			}
523
+		}
524
+		$result = $this->db->query($sql, (int)$limit, (int)$start);
525
+		if (!$result) {
526
+			//xoops_error($this->db->error());
527
+			return $ret;
528
+		}
529
+		while (false !== ($myrow = $this->db->fetchArray($result))) {
530
+			$post = $this->create(false);
531
+			$post->assignVars($myrow);
532
+			$ret[$myrow['post_id']] = $post;
533
+			unset($post);
534
+		}
535
+
536
+		return $ret;
537
+	}
538
+
539
+	/**
540
+	 * @return bool
541
+	 */
542
+	public function synchronization()
543
+	{
544
+		//$this->cleanOrphan();
545
+		return true;
546
+	}
547
+
548
+	/**
549
+	 * clean orphan items from database
550
+	 *
551
+	 * @param  string $table_link
552
+	 * @param  string $field_link
553
+	 * @param  string $field_object
554
+	 * @return bool   true on success
555
+	 */
556
+	public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
557
+	{
558
+		$this->deleteAll(new \Criteria('post_time', 0), true, true);
559
+		parent::cleanOrphan($this->db->prefix('newbb_topics'), 'topic_id');
560
+		parent::cleanOrphan($this->db->prefix('newbb_posts_text'), 'post_id');
561
+
562
+		$sql = 'DELETE FROM ' . $this->db->prefix('newbb_posts_text') . ' WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM ' . $this->table . ') )';
563
+		if (!$result = $this->db->queryF($sql)) {
564
+			//xoops_error($this->db->error());
565
+			return false;
566
+		}
567
+
568
+		return true;
569
+	}
570
+
571
+	/**
572
+	 * clean expired objects from database
573
+	 *
574
+	 * @param  int $expire time limit for expiration
575
+	 * @return bool true on success
576
+	 */
577
+	public function cleanExpires($expire = 0)
578
+	{
579
+		// irmtfan if 0 no cleanup look include/plugin.php
580
+		if (!func_num_args()) {
581
+			$newbbConfig = newbbLoadConfig();
582
+			$expire      = isset($newbbConfig['pending_expire']) ? (int)$newbbConfig['pending_expire'] : 7;
583
+			$expire      = $expire * 24 * 3600; // days to seconds
584
+		}
585
+		if (empty($expire)) {
586
+			return false;
587
+		}
588
+		$crit_expire = new \CriteriaCompo(new \Criteria('approved', 0, '<='));
589
+		//if (!empty($expire)) {
590
+		$crit_expire->add(new \Criteria('post_time', time() - (int)$expire, '<'));
591
+
592
+		//}
593
+		return $this->deleteAll($crit_expire, true/*, true*/);
594
+	}
595 595
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $id   = (int)$id;
60 60
         $post = null;
61
-        $sql  = 'SELECT p.*, t.* FROM ' . $this->db->prefix('newbb_posts') . ' p LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' t ON p.post_id=t.post_id WHERE p.post_id=' . $id;
61
+        $sql  = 'SELECT p.*, t.* FROM '.$this->db->prefix('newbb_posts').' p LEFT JOIN '.$this->db->prefix('newbb_posts_text').' t ON p.post_id=t.post_id WHERE p.post_id='.$id;
62 62
         if ($array = $this->db->fetchArray($this->db->query($sql))) {
63 63
             $post = $this->create(false);
64 64
             $post->assignVars($array);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $topic_id = 0,
88 88
         $approved = 1
89 89
     ) {
90
-        $sql    = 'SELECT p.*, t.*, tp.topic_status FROM '
90
+        $sql = 'SELECT p.*, t.*, tp.topic_status FROM '
91 91
                   . $this->db->prefix('newbb_posts')
92 92
                   . ' p LEFT JOIN '
93 93
                   . $this->db->prefix('newbb_posts_text')
@@ -379,14 +379,14 @@  discard block
 block discarded – undo
379 379
 
380 380
         /* Set active post as deleted */
381 381
         if ($post->getVar('approved') > 0 && empty($force)) {
382
-            $sql = 'UPDATE ' . $this->db->prefix('newbb_posts') . ' SET approved = -1 WHERE post_id = ' . $post->getVar('post_id');
382
+            $sql = 'UPDATE '.$this->db->prefix('newbb_posts').' SET approved = -1 WHERE post_id = '.$post->getVar('post_id');
383 383
             if (!$result = $this->db->queryF($sql)) {
384 384
             }
385 385
             /* delete pending post directly */
386 386
         } else {
387 387
             $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts'), $post->getVar('post_id'));
388 388
             if (!$result = $this->db->queryF($sql)) {
389
-                $post->setErrors('delete post error: ' . $sql);
389
+                $post->setErrors('delete post error: '.$sql);
390 390
 
391 391
                 return false;
392 392
             }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 
395 395
             $sql = sprintf('DELETE FROM `%s` WHERE post_id = %u', $this->db->prefix('newbb_posts_text'), $post->getVar('post_id'));
396 396
             if (!$result = $this->db->queryF($sql)) {
397
-                $post->setErrors('Could not remove post text: ' . $sql);
397
+                $post->setErrors('Could not remove post text: '.$sql);
398 398
 
399 399
                 return false;
400 400
             }
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
                 }
432 432
             }
433 433
         } else {
434
-            $sql = 'UPDATE ' . $this->db->prefix('newbb_topics') . ' t
435
-                            LEFT JOIN ' . $this->db->prefix('newbb_posts') . ' p ON p.topic_id = t.topic_id
434
+            $sql = 'UPDATE '.$this->db->prefix('newbb_topics').' t
435
+                            LEFT JOIN ' . $this->db->prefix('newbb_posts').' p ON p.topic_id = t.topic_id
436 436
                             SET t.topic_last_post_id = p.post_id
437
-                            WHERE t.topic_last_post_id = ' . $post->getVar('post_id') . '
438
-                                    AND p.post_id = (SELECT MAX(post_id) FROM ' . $this->db->prefix('newbb_posts') . ' WHERE topic_id=t.topic_id)';
437
+                            WHERE t.topic_last_post_id = ' . $post->getVar('post_id').'
438
+                                    AND p.post_id = (SELECT MAX(post_id) FROM ' . $this->db->prefix('newbb_posts').' WHERE topic_id=t.topic_id)';
439 439
             if (!$result = $this->db->queryF($sql)) {
440 440
             }
441 441
         }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             }
458 458
             // irmtfan - just update the pid for approved posts when the post is not topic (pid=0)
459 459
             if (!$post->isTopic()) {
460
-                $sql = 'UPDATE ' . $this->db->prefix('newbb_posts') . ' SET pid = ' . $post->getVar('pid') . ' WHERE approved=1 AND pid=' . $post->getVar('post_id');
460
+                $sql = 'UPDATE '.$this->db->prefix('newbb_posts').' SET pid = '.$post->getVar('pid').' WHERE approved=1 AND pid='.$post->getVar('post_id');
461 461
                 if (!$result = $this->db->queryF($sql)) {
462 462
                     //xoops_error($this->db->error());
463 463
                 }
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
             return parent::getCount($criteria);
482 482
         }
483 483
 
484
-        $sql = 'SELECT COUNT(*) as count' . ' FROM ' . $this->db->prefix('newbb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' AS t ON t.post_id = p.post_id';
484
+        $sql = 'SELECT COUNT(*) as count'.' FROM '.$this->db->prefix('newbb_posts').' AS p'.' LEFT JOIN '.$this->db->prefix('newbb_posts_text').' AS t ON t.post_id = p.post_id';
485 485
         // LEFT JOIN
486 486
         $sql .= $join;
487 487
         // WHERE
488 488
         if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
489
-            $sql .= ' ' . $criteria->renderWhere();
489
+            $sql .= ' '.$criteria->renderWhere();
490 490
         }
491 491
         if (!$result = $this->db->query($sql)) {
492 492
             //xoops_error($this->db->error().'<br>'.$sql);
@@ -511,14 +511,14 @@  discard block
 block discarded – undo
511 511
     public function getPostsByLimit($criteria = null, $limit = 1, $start = 0, $join = null)
512 512
     {
513 513
         $ret = [];
514
-        $sql = 'SELECT p.*, t.* ' . ' FROM ' . $this->db->prefix('newbb_posts') . ' AS p' . ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' AS t ON t.post_id = p.post_id';
514
+        $sql = 'SELECT p.*, t.* '.' FROM '.$this->db->prefix('newbb_posts').' AS p'.' LEFT JOIN '.$this->db->prefix('newbb_posts_text').' AS t ON t.post_id = p.post_id';
515 515
         if (!empty($join)) {
516 516
             $sql .= $join;
517 517
         }
518 518
         if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
519
-            $sql .= ' ' . $criteria->renderWhere();
519
+            $sql .= ' '.$criteria->renderWhere();
520 520
             if ('' !== $criteria->getSort()) {
521
-                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
521
+                $sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
522 522
             }
523 523
         }
524 524
         $result = $this->db->query($sql, (int)$limit, (int)$start);
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
         parent::cleanOrphan($this->db->prefix('newbb_topics'), 'topic_id');
560 560
         parent::cleanOrphan($this->db->prefix('newbb_posts_text'), 'post_id');
561 561
 
562
-        $sql = 'DELETE FROM ' . $this->db->prefix('newbb_posts_text') . ' WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM ' . $this->table . ') )';
562
+        $sql = 'DELETE FROM '.$this->db->prefix('newbb_posts_text').' WHERE (post_id NOT IN ( SELECT DISTINCT post_id FROM '.$this->table.') )';
563 563
         if (!$result = $this->db->queryF($sql)) {
564 564
             //xoops_error($this->db->error());
565 565
             return false;
Please login to merge, or discard this patch.
class/TextHandler.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,24 +19,24 @@
 block discarded – undo
19 19
  */
20 20
 class TextHandler extends \XoopsPersistableObjectHandler
21 21
 {
22
-    /**
23
-     * @param \XoopsDatabase $db
24
-     */
25
-    public function __construct(\XoopsDatabase $db = null)
26
-    {
27
-        parent::__construct($db, 'newbb_posts_text', Text::class, 'post_id', '');
28
-    }
22
+	/**
23
+	 * @param \XoopsDatabase $db
24
+	 */
25
+	public function __construct(\XoopsDatabase $db = null)
26
+	{
27
+		parent::__construct($db, 'newbb_posts_text', Text::class, 'post_id', '');
28
+	}
29 29
 
30
-    /**
31
-     * clean orphan items from database
32
-     *
33
-     * @param  string $table_link
34
-     * @param  string $field_link
35
-     * @param  string $field_object
36
-     * @return bool   true on success
37
-     */
38
-    public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
39
-    {
40
-        return parent::cleanOrphan($this->db->prefix('newbb_posts'), 'post_id');
41
-    }
30
+	/**
31
+	 * clean orphan items from database
32
+	 *
33
+	 * @param  string $table_link
34
+	 * @param  string $field_link
35
+	 * @param  string $field_object
36
+	 * @return bool   true on success
37
+	 */
38
+	public function cleanOrphan($table_link = '', $field_link = '', $field_object = '') //cleanOrphan()
39
+	{
40
+		return parent::cleanOrphan($this->db->prefix('newbb_posts'), 'post_id');
41
+	}
42 42
 }
Please login to merge, or discard this patch.
include/functions.config.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -17,37 +17,37 @@
 block discarded – undo
17 17
 define('NEWBB_FUNCTIONS_CONFIG_LOADED', true);
18 18
 
19 19
 if (!defined('NEWBB_FUNCTIONS_CONFIG')) {
20
-    define('NEWBB_FUNCTIONS_CONFIG', 1);
21
-
22
-    /**
23
-     * @return array
24
-     * @internal param string $category
25
-     * @internal param string $dirname
26
-     */
27
-    function newbbLoadConfig()
28
-    {
20
+	define('NEWBB_FUNCTIONS_CONFIG', 1);
21
+
22
+	/**
23
+	 * @return array
24
+	 * @internal param string $category
25
+	 * @internal param string $dirname
26
+	 */
27
+	function newbbLoadConfig()
28
+	{
29 29
 //        require_once dirname(__DIR__) . '/class/Helper.php';
30
-        //$helper = NewBB::getInstance();
31
-        /** @var \XoopsModules\Newbb\Helper $helper */
32
-        $helper = \XoopsModules\Newbb\Helper::getInstance();
33
-        static $configs = null;
34
-
35
-        if (null !== $configs) {
36
-            return $configs;
37
-        }
38
-
39
-        $configs = is_object($helper) ? $helper->getConfig() : [];
40
-        $plugins = require __DIR__   . '/plugin.php';
41
-        if (is_array($configs) && is_array($plugins)) {
42
-            $configs = array_merge($configs, $plugins);
43
-        }
44
-        if (!isset($GLOBALS['xoopsModuleConfig'])) {
45
-            $GLOBALS['xoopsModuleConfig'] = [];
46
-        }
47
-        if (is_array($configs)) {
48
-            $GLOBALS['xoopsModuleConfig'] = array_merge($GLOBALS['xoopsModuleConfig'], $configs);
49
-        }
50
-
51
-        return $configs;
52
-    }
30
+		//$helper = NewBB::getInstance();
31
+		/** @var \XoopsModules\Newbb\Helper $helper */
32
+		$helper = \XoopsModules\Newbb\Helper::getInstance();
33
+		static $configs = null;
34
+
35
+		if (null !== $configs) {
36
+			return $configs;
37
+		}
38
+
39
+		$configs = is_object($helper) ? $helper->getConfig() : [];
40
+		$plugins = require __DIR__   . '/plugin.php';
41
+		if (is_array($configs) && is_array($plugins)) {
42
+			$configs = array_merge($configs, $plugins);
43
+		}
44
+		if (!isset($GLOBALS['xoopsModuleConfig'])) {
45
+			$GLOBALS['xoopsModuleConfig'] = [];
46
+		}
47
+		if (is_array($configs)) {
48
+			$GLOBALS['xoopsModuleConfig'] = array_merge($GLOBALS['xoopsModuleConfig'], $configs);
49
+		}
50
+
51
+		return $configs;
52
+	}
53 53
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 use XoopsModules\Newbb;
15 15
 
16
-defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
16
+defined('NEWBB_FUNCTIONS_INI') || require __DIR__.'/functions.ini.php';
17 17
 define('NEWBB_FUNCTIONS_CONFIG_LOADED', true);
18 18
 
19 19
 if (!defined('NEWBB_FUNCTIONS_CONFIG')) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         }
38 38
 
39 39
         $configs = is_object($helper) ? $helper->getConfig() : [];
40
-        $plugins = require __DIR__   . '/plugin.php';
40
+        $plugins = require __DIR__.'/plugin.php';
41 41
         if (is_array($configs) && is_array($plugins)) {
42 42
             $configs = array_merge($configs, $plugins);
43 43
         }
Please login to merge, or discard this patch.