Passed
Push — master ( 565d4a...492cc7 )
by Michael
07:40
created
viewtopic.php 2 patches
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -44,54 +44,54 @@  discard block
 block discarded – undo
44 44
 $query_vars  = ['post_id', 'topic_id', 'status', 'order', 'start', 'move', 'mode'];
45 45
 $query_array = [];
46 46
 foreach ($query_vars as $var) {
47
-    if (Request::getString($var, '', 'GET')) {
48
-        $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
49
-    }
47
+	if (Request::getString($var, '', 'GET')) {
48
+		$query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
49
+	}
50 50
 }
51 51
 $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
52 52
 unset($query_array);
53 53
 
54 54
 $forum_id = Request::getInt('forum', 0, 'GET');
55 55
 $read     = (Request::getString('read', '', 'GET')
56
-             && 'new' === Request::getString('read', '', 'GET')) ? Request::getString('read', '', 'GET') : '';
56
+			 && 'new' === Request::getString('read', '', 'GET')) ? Request::getString('read', '', 'GET') : '';
57 57
 $topic_id = Request::getInt('topic_id', 0, 'GET'); // isset($_GET['topic_id']) ? (int)($_GET['topic_id']) : 0;
58 58
 $post_id  = Request::getInt('post_id', 0, 'GET'); // !empty($_GET['post_id']) ? (int)($_GET['post_id']) : 0;
59 59
 $move     = strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move']) ? strtolower($_GET['move']) : '';
60 60
 $start    = Request::getInt('start', 0, 'GET'); // !empty($_GET['start']) ? (int)($_GET['start']) : 0;
61 61
 $status   = (Request::getString('status', '', 'GET')
62
-             && in_array(Request::getString('status', '', 'GET'), ['active', 'pending', 'deleted'], true)) ? Request::getString('status', '', 'GET') : '';
62
+			 && in_array(Request::getString('status', '', 'GET'), ['active', 'pending', 'deleted'], true)) ? Request::getString('status', '', 'GET') : '';
63 63
 $mode     = Request::getInt('mode', (!empty($status) ? 2 : 0), 'GET'); // !empty($_GET['mode']) ? (int)($_GET['mode']) : (!empty($status) ? 2 : 0);
64 64
 $order    = (Request::getString('order', '', 'GET')
65
-             && in_array(Request::getString('order', '', 'GET'), ['ASC', 'DESC'], true)) ? Request::getString('order', '', 'GET') : '';
65
+			 && in_array(Request::getString('order', '', 'GET'), ['ASC', 'DESC'], true)) ? Request::getString('order', '', 'GET') : '';
66 66
 
67 67
 if ('' === $order) {
68
-    if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) {
69
-        $order = (1 == $GLOBALS['xoopsUser']->getVar('uorder')) ? 'DESC' : 'ASC';
70
-    } else {
71
-        $order = (1 == $GLOBALS['xoopsConfig']['com_order']) ? 'DESC' : 'ASC';
72
-    }
68
+	if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) {
69
+		$order = (1 == $GLOBALS['xoopsUser']->getVar('uorder')) ? 'DESC' : 'ASC';
70
+	} else {
71
+		$order = (1 == $GLOBALS['xoopsConfig']['com_order']) ? 'DESC' : 'ASC';
72
+	}
73 73
 }
74 74
 
75 75
 if (!$topic_id && !$post_id) {
76
-    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
77
-    redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
76
+	$redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
77
+	redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
78 78
 }
79 79
 
80 80
 ///** @var Newbb\TopicHandler $topicHandler */
81 81
 //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
82 82
 if (!empty($post_id)) {
83
-    $topicObject = $topicHandler->getByPost($post_id);
84
-    $topic_id    = $topicObject->getVar('topic_id');
83
+	$topicObject = $topicHandler->getByPost($post_id);
84
+	$topic_id    = $topicObject->getVar('topic_id');
85 85
 } elseif (!empty($move)) {
86
-    $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id);
87
-    $topic_id    = $topicObject->getVar('topic_id');
86
+	$topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id);
87
+	$topic_id    = $topicObject->getVar('topic_id');
88 88
 } else {
89
-    $topicObject = $topicHandler->get($topic_id);
89
+	$topicObject = $topicHandler->get($topic_id);
90 90
 }
91 91
 
92 92
 if (!is_object($topicObject) || !$topic_id = $topicObject->getVar('topic_id')) {
93
-    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
94
-    redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
93
+	$redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
94
+	redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
95 95
 }
96 96
 $forum_id = $topicObject->getVar('forum_id');
97 97
 ///** @var Newbb\ForumHandler $forumHandler */
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 $isAdmin = newbbIsAdmin($forumObject);
102 102
 
103 103
 if ((!$isAdmin && $topicObject->getVar('approved') < 0) || (!$forumHandler->getPermission($forumObject))
104
-    || (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view'))) {
105
-    redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
104
+	|| (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view'))) {
105
+	redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
106 106
 }
107 107
 
108 108
 // START irmtfan - find if topic is read or unread - for all users (member and anon)
@@ -118,32 +118,32 @@  discard block
 block discarded – undo
118 118
 */
119 119
 $topic_last_post_time_or_id_read = newbbGetRead('topic', $topic_id);
120 120
 if (!empty($topic_last_post_time_or_id_read)) {
121
-    if (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
122
-        //        $postHandler     = Newbb\Helper::getInstance()->getHandler('Post');
123
-        $postObject      = $postHandler->get($topicObject->getVar('topic_last_post_id'));
124
-        $topic_is_unread = ($topic_last_post_time_or_id_read < $postObject->getVar('post_time'));
125
-    }
126
-    if (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
127
-        $topic_is_unread = ($topic_last_post_time_or_id_read < $topicObject->getVar('topic_last_post_id'));
128
-        // hack jump to last post read if post_id is empty - is there any better way?
129
-        if (empty($post_id) && $topic_is_unread
130
-            && !empty($GLOBALS['xoopsModuleConfig']['jump_to_topic_last_post_read_enabled'])) {
131
-            header('Location: ' . Request::getString('REQUEST_URI', '', 'SERVER') . '&post_id=' . $topic_last_post_time_or_id_read);
132
-        }
133
-    }
121
+	if (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
122
+		//        $postHandler     = Newbb\Helper::getInstance()->getHandler('Post');
123
+		$postObject      = $postHandler->get($topicObject->getVar('topic_last_post_id'));
124
+		$topic_is_unread = ($topic_last_post_time_or_id_read < $postObject->getVar('post_time'));
125
+	}
126
+	if (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
127
+		$topic_is_unread = ($topic_last_post_time_or_id_read < $topicObject->getVar('topic_last_post_id'));
128
+		// hack jump to last post read if post_id is empty - is there any better way?
129
+		if (empty($post_id) && $topic_is_unread
130
+			&& !empty($GLOBALS['xoopsModuleConfig']['jump_to_topic_last_post_read_enabled'])) {
131
+			header('Location: ' . Request::getString('REQUEST_URI', '', 'SERVER') . '&post_id=' . $topic_last_post_time_or_id_read);
132
+		}
133
+	}
134 134
 }
135 135
 // END irmtfan - find if topic is read or unread - for all users (member and anon)
136 136
 
137 137
 /* Only admin has access to admin mode */
138 138
 if (!$isAdmin) {
139
-    $status = '';
140
-    $mode   = 0;
139
+	$status = '';
140
+	$mode   = 0;
141 141
 }
142 142
 
143 143
 if (!empty($GLOBALS['xoopsModuleConfig']['enable_karma'])) {
144
-    //    /** @var Newbb\KarmaHandler $karmaHandler */
145
-    //    $karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma');
146
-    $user_karma = $karmaHandler->getUserKarma();
144
+	//    /** @var Newbb\KarmaHandler $karmaHandler */
145
+	//    $karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma');
146
+	$user_karma = $karmaHandler->getUserKarma();
147 147
 }
148 148
 
149 149
 //$viewmode = "flat";
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
 //irmtfan - increment topic_views only if the topic is unread
156 156
 if ($topic_is_unread) {
157
-    $topicObject->incrementCounter();
157
+	$topicObject->incrementCounter();
158 158
 }
159 159
 newbbSetRead('topic', $topic_id, $topicObject->getVar('topic_last_post_id'));
160 160
 
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 //$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
167 167
 // irmtfan new method
168 168
 if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
169
-    $xoopsTpl->assign('xoops_module_header', '
169
+	$xoopsTpl->assign('xoops_module_header', '
170 170
     <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forumObject->getVar('forum_id') . '" />
171 171
     ' . @$xoopsTpl->get_template_vars('xoops_module_header'));
172 172
 }
173 173
 
174 174
 if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
175
-    /** @var Newbb\OnlineHandler $onlineHandler */
176
-    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
177
-    $onlineHandler->init($forumObject, $topicObject);
178
-    $xoopsTpl->assign('online', $onlineHandler->showOnline());
175
+	/** @var Newbb\OnlineHandler $onlineHandler */
176
+	$onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
177
+	$onlineHandler->init($forumObject, $topicObject);
178
+	$xoopsTpl->assign('online', $onlineHandler->showOnline());
179 179
 }
180 180
 $xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject));
181 181
 // irmtfan - remove icon_path and use newbbDisplayImage
@@ -189,32 +189,32 @@  discard block
 block discarded – undo
189 189
 $iconHandler = newbbGetIconHandler(); // can be use in the follwing codes in this file
190 190
 
191 191
 if ($infobox['show'] > 0) {
192
-    // irmtfan - remove icon_path and use newbbDisplayImage
193
-    $infobox['icon'] = [
194
-        'expand'   => $iconHandler->getImageSource('less'),
195
-        'collapse' => $iconHandler->getImageSource('more')
196
-    ];
197
-    if (1 == $infobox['show']) {
198
-        $infobox['style'] = 'none';        //irmtfan move semicolon
199
-        $infobox['alt']   = _MD_NEWBB_SEEUSERDATA;
200
-        $infobox['src']   = 'more';
201
-    } else {
202
-        $infobox['style'] = 'block';        //irmtfan move semicolon
203
-        $infobox['alt']   = _MD_NEWBB_HIDEUSERDATA;
204
-        $infobox['src']   = 'less';
205
-    }
206
-    $infobox['displayImage'] = newbbDisplayImage($infobox['src'], $infobox['alt']);
192
+	// irmtfan - remove icon_path and use newbbDisplayImage
193
+	$infobox['icon'] = [
194
+		'expand'   => $iconHandler->getImageSource('less'),
195
+		'collapse' => $iconHandler->getImageSource('more')
196
+	];
197
+	if (1 == $infobox['show']) {
198
+		$infobox['style'] = 'none';        //irmtfan move semicolon
199
+		$infobox['alt']   = _MD_NEWBB_SEEUSERDATA;
200
+		$infobox['src']   = 'more';
201
+	} else {
202
+		$infobox['style'] = 'block';        //irmtfan move semicolon
203
+		$infobox['alt']   = _MD_NEWBB_HIDEUSERDATA;
204
+		$infobox['src']   = 'less';
205
+	}
206
+	$infobox['displayImage'] = newbbDisplayImage($infobox['src'], $infobox['alt']);
207 207
 }
208 208
 $xoopsTpl->assign('infobox', $infobox);
209 209
 // END irmtfan improve infobox
210 210
 
211 211
 $xoopsTpl->assign([
212
-                      'topic_title'    => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?topic_id=' . $topic_id . '">' . $topicObject->getFullTitle() . '</a>',
213
-                      'forum_name'     => $forumObject->getVar('forum_name'),
214
-                      'lang_nexttopic' => _MD_NEWBB_NEXTTOPIC,
215
-                      'lang_prevtopic' => _MD_NEWBB_PREVTOPIC,
216
-                      'topic_status'   => $topicObject->getVar('topic_status')
217
-                  ]);
212
+					  'topic_title'    => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?topic_id=' . $topic_id . '">' . $topicObject->getFullTitle() . '</a>',
213
+					  'forum_name'     => $forumObject->getVar('forum_name'),
214
+					  'lang_nexttopic' => _MD_NEWBB_NEXTTOPIC,
215
+					  'lang_prevtopic' => _MD_NEWBB_PREVTOPIC,
216
+					  'topic_status'   => $topicObject->getVar('topic_status')
217
+				  ]);
218 218
 
219 219
 //$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category');
220 220
 $categoryObject = $categoryHandler->get($forumObject->getVar('cat_id'), ['cat_title']);
@@ -231,149 +231,149 @@  discard block
 block discarded – undo
231 231
 $t_reply = newbbDisplayImage('t_reply', _MD_NEWBB_REPLY);
232 232
 // irmtfan show topic status if show reg is 0 and revise forum_post_or_register
233 233
 if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'post')) {
234
-    $xoopsTpl->assign('forum_post', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/newtopic.php?forum=' . $forum_id . '"> ' . $t_new . '</a>');
234
+	$xoopsTpl->assign('forum_post', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/newtopic.php?forum=' . $forum_id . '"> ' . $t_new . '</a>');
235 235
 } else {
236
-    if ($topicObject->getVar('topic_status')) {
237
-        $xoopsTpl->assign('topic_lock', _MD_NEWBB_TOPICLOCKED);
238
-    }
239
-    if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) {
240
-        $xoopsTpl->assign('forum_register', '<a href="' . XOOPS_URL . '/user.php?xoops_redirect=' . htmlspecialchars($xoopsRequestUri, ENT_QUOTES | ENT_HTML5) . '">' . _MD_NEWBB_REGTOPOST . '</a>');
241
-    }
236
+	if ($topicObject->getVar('topic_status')) {
237
+		$xoopsTpl->assign('topic_lock', _MD_NEWBB_TOPICLOCKED);
238
+	}
239
+	if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) {
240
+		$xoopsTpl->assign('forum_register', '<a href="' . XOOPS_URL . '/user.php?xoops_redirect=' . htmlspecialchars($xoopsRequestUri, ENT_QUOTES | ENT_HTML5) . '">' . _MD_NEWBB_REGTOPOST . '</a>');
241
+	}
242 242
 }
243 243
 // irmtfan for backward compatibility assign forum_post_or_register smarty again.
244 244
 $xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post') . @$xoopsTpl->get_template_vars('forum_register') . @$xoopsTpl->get_template_vars('topic_lock'));
245 245
 
246 246
 if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')) {
247
-    $xoopsTpl->assign('forum_reply', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/reply.php?topic_id=' . $topic_id . '"> ' . $t_reply . '</a>');
247
+	$xoopsTpl->assign('forum_reply', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/reply.php?topic_id=' . $topic_id . '"> ' . $t_reply . '</a>');
248 248
 }
249 249
 
250 250
 $poster_array  = [];
251 251
 $require_reply = false;
252 252
 /** @var Post $eachpost */
253 253
 foreach ($postsArray as $eachpost) {
254
-    if ($eachpost->getVar('uid') > 0) {
255
-        $poster_array[$eachpost->getVar('uid')] = 1;
256
-    }
257
-    if ($eachpost->getVar('require_reply') > 0) {
258
-        $require_reply = true;
259
-    }
254
+	if ($eachpost->getVar('uid') > 0) {
255
+		$poster_array[$eachpost->getVar('uid')] = 1;
256
+	}
257
+	if ($eachpost->getVar('require_reply') > 0) {
258
+		$require_reply = true;
259
+	}
260 260
 }
261 261
 
262 262
 $userid_array = [];
263 263
 $online       = [];
264 264
 if (is_array($poster_array) && count($poster_array) > 0) {
265
-    /** @var \XoopsMemberHandler $memberHandler */
266
-    $memberHandler = xoops_getHandler('member');
267
-    $userid_array  = array_keys($poster_array);
268
-    $user_criteria = '(' . implode(',', $userid_array) . ')';
269
-    $users         = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true);
265
+	/** @var \XoopsMemberHandler $memberHandler */
266
+	$memberHandler = xoops_getHandler('member');
267
+	$userid_array  = array_keys($poster_array);
268
+	$user_criteria = '(' . implode(',', $userid_array) . ')';
269
+	$users         = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true);
270 270
 } else {
271
-    $users = [];
271
+	$users = [];
272 272
 }
273 273
 
274 274
 $viewtopic_users = [];
275 275
 if (is_array($userid_array) && count($userid_array) > 0) {
276 276
 //    require_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php');
277
-    $userHandler         = new Newbb\UserHandler($GLOBALS['xoopsModuleConfig']['groupbar_enabled'], $GLOBALS['xoopsModuleConfig']['wol_enabled']);
278
-    $userHandler->users  = $users;
279
-    $userHandler->online = $online;
280
-    $viewtopic_users     = $userHandler->getUsers();
277
+	$userHandler         = new Newbb\UserHandler($GLOBALS['xoopsModuleConfig']['groupbar_enabled'], $GLOBALS['xoopsModuleConfig']['wol_enabled']);
278
+	$userHandler->users  = $users;
279
+	$userHandler->online = $online;
280
+	$viewtopic_users     = $userHandler->getUsers();
281 281
 }
282 282
 unset($users);
283 283
 
284 284
 if ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $require_reply) {
285
-    if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) {
286
-        $viewtopic_posters = newbbGetSession('t' . $topic_id, true);
287
-        if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) {
288
-            $viewtopic_posters = $topicHandler->getAllPosters($topicObject);
289
-            newbbSetSession('t' . $topic_id, $viewtopic_posters);
290
-        }
291
-    } else {
292
-        $viewtopic_posters = $topicHandler->getAllPosters($topicObject);
293
-    }
285
+	if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) {
286
+		$viewtopic_posters = newbbGetSession('t' . $topic_id, true);
287
+		if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) {
288
+			$viewtopic_posters = $topicHandler->getAllPosters($topicObject);
289
+			newbbSetSession('t' . $topic_id, $viewtopic_posters);
290
+		}
291
+	} else {
292
+		$viewtopic_posters = $topicHandler->getAllPosters($topicObject);
293
+	}
294 294
 } else {
295
-    $viewtopic_posters = [];
295
+	$viewtopic_posters = [];
296 296
 }
297 297
 
298 298
 if ($GLOBALS['xoopsModuleConfig']['show_advertising']) {
299
-    $post_werbung = [
300
-        'post_id'         => 0,
301
-        'post_parent_id'  => 0,
302
-        'post_date'       => 0,
303
-        'post_image'      => '',
304
-        'post_title'      => '',
305
-        'post_text'       => '<div style="text-align: center;vertical-align: middle;"><br>' . xoops_getbanner() . '</div>',
306
-        'post_attachment' => '',
307
-        'post_edit'       => 0,
308
-        'post_no'         => 0,
309
-        'post_signature'  => _MD_NEWBB_ADVERTISING_BLOCK,
310
-        'poster_ip'       => '',
311
-        'thread_action'   => '',
312
-        'thread_buttons'  => '',
313
-        'mod_buttons'     => '',
314
-        'poster'          => [
315
-            'uid'        => -1,
316
-            'link'       => _MD_NEWBB_ADVERTISING_USER,
317
-            'avatar'     => 'avatars/blank.gif',
318
-            'regdate'    => 0,
319
-            'last_login' => 0,
320
-            'rank'       => ['title' => '']
321
-        ],
322
-        // irmtfan add last_login
323
-        'post_permalink'  => ''
324
-    ];
299
+	$post_werbung = [
300
+		'post_id'         => 0,
301
+		'post_parent_id'  => 0,
302
+		'post_date'       => 0,
303
+		'post_image'      => '',
304
+		'post_title'      => '',
305
+		'post_text'       => '<div style="text-align: center;vertical-align: middle;"><br>' . xoops_getbanner() . '</div>',
306
+		'post_attachment' => '',
307
+		'post_edit'       => 0,
308
+		'post_no'         => 0,
309
+		'post_signature'  => _MD_NEWBB_ADVERTISING_BLOCK,
310
+		'poster_ip'       => '',
311
+		'thread_action'   => '',
312
+		'thread_buttons'  => '',
313
+		'mod_buttons'     => '',
314
+		'poster'          => [
315
+			'uid'        => -1,
316
+			'link'       => _MD_NEWBB_ADVERTISING_USER,
317
+			'avatar'     => 'avatars/blank.gif',
318
+			'regdate'    => 0,
319
+			'last_login' => 0,
320
+			'rank'       => ['title' => '']
321
+		],
322
+		// irmtfan add last_login
323
+		'post_permalink'  => ''
324
+	];
325 325
 }
326 326
 
327 327
 $i = 0;
328 328
 /** @var Post $eachpost */
329 329
 foreach ($postsArray as $eachpost) {
330
-    if ($GLOBALS['xoopsModuleConfig']['show_advertising']) {
331
-        if (2 === $i) {
332
-            $xoopsTpl->append('topic_posts', $post_werbung);
333
-        }
334
-        ++$i;
335
-    }
336
-    $xoopsTpl->append('topic_posts', $eachpost->showPost($isAdmin));
330
+	if ($GLOBALS['xoopsModuleConfig']['show_advertising']) {
331
+		if (2 === $i) {
332
+			$xoopsTpl->append('topic_posts', $post_werbung);
333
+		}
334
+		++$i;
335
+	}
336
+	$xoopsTpl->append('topic_posts', $eachpost->showPost($isAdmin));
337 337
 }
338 338
 
339 339
 if ($total_posts > $GLOBALS['xoopsModuleConfig']['posts_per_page']) {
340
-    require_once $GLOBALS['xoops']->path('class/pagenav.php');
341
-
342
-    $nav = new \XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&amp;order=' . $order . '&amp;status=' . $status . '&amp;mode=' . $mode);
343
-    //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite']) && $GLOBALS['xoopsModuleConfig']['do_rewrite'] === 1) $nav->url = XOOPS_URL . $nav->url;
344
-    if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
345
-        $navi = $nav->renderSelect();
346
-    } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
347
-        $navi = $nav->renderImageNav(4);
348
-    } else {
349
-        $navi = $nav->renderNav(4);
350
-    }
351
-    $xoopsTpl->assign('forum_page_nav', $navi);
340
+	require_once $GLOBALS['xoops']->path('class/pagenav.php');
341
+
342
+	$nav = new \XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&amp;order=' . $order . '&amp;status=' . $status . '&amp;mode=' . $mode);
343
+	//if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite']) && $GLOBALS['xoopsModuleConfig']['do_rewrite'] === 1) $nav->url = XOOPS_URL . $nav->url;
344
+	if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
345
+		$navi = $nav->renderSelect();
346
+	} elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
347
+		$navi = $nav->renderImageNav(4);
348
+	} else {
349
+		$navi = $nav->renderNav(4);
350
+	}
351
+	$xoopsTpl->assign('forum_page_nav', $navi);
352 352
 } else {
353
-    $xoopsTpl->assign('forum_page_nav', '');
353
+	$xoopsTpl->assign('forum_page_nav', '');
354 354
 }
355 355
 
356 356
 if (empty($post_id)) {
357
-    $first   = array_keys($postsArray);
358
-    $post_id = !empty($first[0]) ? $first[0] : 0;
357
+	$first   = array_keys($postsArray);
358
+	$post_id = !empty($first[0]) ? $first[0] : 0;
359 359
 }
360 360
 
361 361
 if (!empty($postsArray[$post_id])) {
362
-    $xoops_pagetitle = $postsArray[$post_id]->getVar('subject') . ' [' . $forumObject->getVar('forum_name') . ']';
363
-    $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
364
-    $xoopsOption['xoops_pagetitle'] = $xoops_pagetitle;
365
-    $kw                             = array_unique(explode(' ', strip_tags($postsArray[$post_id]->getVar('post_text')), 150));
366
-    asort($kw);
367
-    $kwort = '';
368
-    $z     = 0;
369
-    foreach ($kw as $k) {
370
-        if ($z < 30 && strlen(trim($k)) > 5) {
371
-            $kwort .= trim($k) . ' ';
372
-            ++$z;
373
-        }
374
-    }
375
-    $xoTheme->addMeta('meta', 'keywords', $kwort);
376
-    $xoTheme->addMeta('meta', 'description', substr(strip_tags($postsArray[$post_id]->getVar('post_text')), 0, 120));
362
+	$xoops_pagetitle = $postsArray[$post_id]->getVar('subject') . ' [' . $forumObject->getVar('forum_name') . ']';
363
+	$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
364
+	$xoopsOption['xoops_pagetitle'] = $xoops_pagetitle;
365
+	$kw                             = array_unique(explode(' ', strip_tags($postsArray[$post_id]->getVar('post_text')), 150));
366
+	asort($kw);
367
+	$kwort = '';
368
+	$z     = 0;
369
+	foreach ($kw as $k) {
370
+		if ($z < 30 && strlen(trim($k)) > 5) {
371
+			$kwort .= trim($k) . ' ';
372
+			++$z;
373
+		}
374
+	}
375
+	$xoTheme->addMeta('meta', 'keywords', $kwort);
376
+	$xoTheme->addMeta('meta', 'description', substr(strip_tags($postsArray[$post_id]->getVar('post_text')), 0, 120));
377 377
 }
378 378
 unset($postsArray);
379 379
 
@@ -395,67 +395,67 @@  discard block
 block discarded – undo
395 395
 // START irmtfan add restore to viewtopic
396 396
 // if the topic is active
397 397
 if ($topicObject->getVar('approved') > 0) {
398
-    $admin_actions['merge']  = [
399
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=merge&amp;topic_id=' . $topic_id,
400
-        'name'  => _MD_NEWBB_MERGETOPIC,
401
-        'image' => $ad_merge
402
-    ];
403
-    $admin_actions['move']   = [
404
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=move&amp;topic_id=' . $topic_id,
405
-        'name'  => _MD_NEWBB_MOVETOPIC,
406
-        'image' => $ad_move
407
-    ];
408
-    $admin_actions['delete'] = [
409
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=delete&amp;topic_id=' . $topic_id,
410
-        'name'  => _MD_NEWBB_DELETETOPIC,
411
-        'image' => $ad_delete
412
-    ];
413
-    if (!$topicObject->getVar('topic_status')) {
414
-        $admin_actions['lock'] = [
415
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=lock&amp;topic_id=' . $topic_id,
416
-            'image' => $ad_lock,
417
-            'name'  => _MD_NEWBB_LOCKTOPIC
418
-        ];
419
-    } else {
420
-        $admin_actions['unlock'] = [
421
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unlock&amp;topic_id=' . $topic_id,
422
-            'image' => $ad_unlock,
423
-            'name'  => _MD_NEWBB_UNLOCKTOPIC
424
-        ];
425
-    }
426
-    if (!$topicObject->getVar('topic_sticky')) {
427
-        $admin_actions['sticky'] = [
428
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=sticky&amp;topic_id=' . $topic_id,
429
-            'image' => $ad_sticky,
430
-            'name'  => _MD_NEWBB_STICKYTOPIC
431
-        ];
432
-    } else {
433
-        $admin_actions['unsticky'] = [
434
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unsticky&amp;topic_id=' . $topic_id,
435
-            'image' => $ad_unsticky,
436
-            'name'  => _MD_NEWBB_UNSTICKYTOPIC
437
-        ];
438
-    }
439
-    if (!$topicObject->getVar('topic_digest')) {
440
-        $admin_actions['digest'] = [
441
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=digest&amp;topic_id=' . $topic_id,
442
-            'image' => $ad_digest,
443
-            'name'  => _MD_NEWBB_DIGESTTOPIC
444
-        ];
445
-    } else {
446
-        $admin_actions['undigest'] = [
447
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=undigest&amp;topic_id=' . $topic_id,
448
-            'image' => $ad_undigest,
449
-            'name'  => _MD_NEWBB_UNDIGESTTOPIC
450
-        ];
451
-    }
452
-    // if the topic is pending/deleted then restore/approve
398
+	$admin_actions['merge']  = [
399
+		'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=merge&amp;topic_id=' . $topic_id,
400
+		'name'  => _MD_NEWBB_MERGETOPIC,
401
+		'image' => $ad_merge
402
+	];
403
+	$admin_actions['move']   = [
404
+		'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=move&amp;topic_id=' . $topic_id,
405
+		'name'  => _MD_NEWBB_MOVETOPIC,
406
+		'image' => $ad_move
407
+	];
408
+	$admin_actions['delete'] = [
409
+		'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=delete&amp;topic_id=' . $topic_id,
410
+		'name'  => _MD_NEWBB_DELETETOPIC,
411
+		'image' => $ad_delete
412
+	];
413
+	if (!$topicObject->getVar('topic_status')) {
414
+		$admin_actions['lock'] = [
415
+			'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=lock&amp;topic_id=' . $topic_id,
416
+			'image' => $ad_lock,
417
+			'name'  => _MD_NEWBB_LOCKTOPIC
418
+		];
419
+	} else {
420
+		$admin_actions['unlock'] = [
421
+			'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unlock&amp;topic_id=' . $topic_id,
422
+			'image' => $ad_unlock,
423
+			'name'  => _MD_NEWBB_UNLOCKTOPIC
424
+		];
425
+	}
426
+	if (!$topicObject->getVar('topic_sticky')) {
427
+		$admin_actions['sticky'] = [
428
+			'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=sticky&amp;topic_id=' . $topic_id,
429
+			'image' => $ad_sticky,
430
+			'name'  => _MD_NEWBB_STICKYTOPIC
431
+		];
432
+	} else {
433
+		$admin_actions['unsticky'] = [
434
+			'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unsticky&amp;topic_id=' . $topic_id,
435
+			'image' => $ad_unsticky,
436
+			'name'  => _MD_NEWBB_UNSTICKYTOPIC
437
+		];
438
+	}
439
+	if (!$topicObject->getVar('topic_digest')) {
440
+		$admin_actions['digest'] = [
441
+			'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=digest&amp;topic_id=' . $topic_id,
442
+			'image' => $ad_digest,
443
+			'name'  => _MD_NEWBB_DIGESTTOPIC
444
+		];
445
+	} else {
446
+		$admin_actions['undigest'] = [
447
+			'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=undigest&amp;topic_id=' . $topic_id,
448
+			'image' => $ad_undigest,
449
+			'name'  => _MD_NEWBB_UNDIGESTTOPIC
450
+		];
451
+	}
452
+	// if the topic is pending/deleted then restore/approve
453 453
 } else {
454
-    $admin_actions['restore'] = [
455
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=restore&amp;topic_id=' . $topic_id,
456
-        'name'  => _MD_NEWBB_RESTORETOPIC,
457
-        'image' => $ad_restore
458
-    ];
454
+	$admin_actions['restore'] = [
455
+		'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=restore&amp;topic_id=' . $topic_id,
456
+		'name'  => _MD_NEWBB_RESTORETOPIC,
457
+		'image' => $ad_restore
458
+	];
459 459
 }
460 460
 // END irmtfan add restore to viewtopic
461 461
 
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
 $xoopsTpl->assign('viewer_level', (int)($isAdmin ? 2 : is_object($GLOBALS['xoopsUser'])));
464 464
 
465 465
 if ($GLOBALS['xoopsModuleConfig']['show_permissiontable']) {
466
-    //    /** var Newbb\PermissionHandler $permHandler */
467
-    //    $permHandler      = Newbb\Helper::getInstance()->getHandler('Permission');
468
-    $permission_table = $permHandler->getPermissionTable($forumObject, $topicObject->getVar('topic_status'), $isAdmin);
469
-    $xoopsTpl->assign_by_ref('permission_table', $permission_table);
466
+	//    /** var Newbb\PermissionHandler $permHandler */
467
+	//    $permHandler      = Newbb\Helper::getInstance()->getHandler('Permission');
468
+	$permission_table = $permHandler->getPermissionTable($forumObject, $topicObject->getVar('topic_status'), $isAdmin);
469
+	$xoopsTpl->assign_by_ref('permission_table', $permission_table);
470 470
 }
471 471
 
472 472
 ///////////////////////////////
@@ -489,167 +489,167 @@  discard block
 block discarded – undo
489 489
 //irmtfan remove
490 490
 $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
491 491
 if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) {
492
-    $poll_id = $topicObject->getVar('poll_id');
493
-    // can vote in poll
494
-    $pollVote = ($topicObject->getVar('topic_haspoll') && $poll_id > 0
495
-                 && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'vote'));
496
-    // can add poll
497
-    $pollAdd = $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll');
498
-    if ($pollVote || $pollAdd) {
499
-        $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
500
-        // new xoopspoll module
501
-        if ($pollModuleHandler->getVar('version') >= 140) {
492
+	$poll_id = $topicObject->getVar('poll_id');
493
+	// can vote in poll
494
+	$pollVote = ($topicObject->getVar('topic_haspoll') && $poll_id > 0
495
+				 && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'vote'));
496
+	// can add poll
497
+	$pollAdd = $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll');
498
+	if ($pollVote || $pollAdd) {
499
+		$pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
500
+		// new xoopspoll module
501
+		if ($pollModuleHandler->getVar('version') >= 140) {
502 502
 //            xoops_load('renderer', $GLOBALS['xoopsModuleConfig']['poll_module']);
503
-            xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']);
504
-        // old xoopspoll or umfrage or any clone from them
505
-        } else {
506
-            $classPoll = $topicObject->loadOldPoll();
507
-        }
508
-    }
509
-    // START can vote in poll
510
-    if ($pollVote) {
511
-        $xoopsTpl->assign('topic_poll', 1);
512
-        $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
513
-        // new xoopspoll module
514
-        if ($pollModuleHandler->getVar('version') >= 140) {
515
-            $xpollHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Poll');
516
-            /** @var \XoopsPoll $pollObject */
517
-            $pollObject = $xpollHandler->get($poll_id);
518
-            if (is_object($pollObject)) {
519
-
520
-                /* check to see if user has rights to view the results */
521
-                $vis_return = $pollObject->isResultVisible();
522
-                $isVisible  = $vis_return;
523
-                $visibleMsg = $isVisible ? '' : $vis_return;
524
-
525
-                /* setup the module config handler */
526
-                /** @var \XoopsConfigHandler $configHandler */
527
-                $configHandler = xoops_getHandler('config');
528
-                $xp_config     = $configHandler->getConfigsByCat(0, $pollModuleHandler->getVar('mid'));
529
-
530
-                $GLOBALS['xoopsTpl']->assign([
531
-                                                 'is_visible'      => $isVisible,
532
-                                                 'visible_message' => $visibleMsg,
533
-                                                 'disp_votes'      => $xp_config['disp_vote_nums'],
534
-                                                 'lang_vote'       => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE'),
535
-                                                 'lang_results'    => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_RESULTS'),
536
-                                                 'back_link'       => ''
537
-                                             ]);
538
-                $classRenderer = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Renderer';
539
-                /** @var \XoopsModules\Xoopspoll\Renderer $renderer */
540
-                $renderer = new $classRenderer($pollObject);
541
-                // check to see if user has voted, show form if not, otherwise get results for form
542
-
543
-                /** @var \XoopsModules\Xoopspoll\LogHandler $logHandler */
544
-                $logHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Log');
545
-                if ($pollObject->isAllowedToVote()
546
-                    && (!$logHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $uid))) {
547
-                    $myTpl = new \XoopsTpl();
548
-                    $renderer->assignForm($myTpl);
549
-                    $myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&amp;poll_id={$poll_id}"));
550
-                    $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/templates/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '_view.tpl'));
551
-                    $GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform);
552
-                } else {
553
-                    $GLOBALS['xoopsTpl']->assign('can_vote', false);
554
-                    $xoopsTpl->assign('topic_pollresult', 1);
555
-                    $GLOBALS['xoopsTpl']->assign('topic_resultform', $renderer->renderResults());
556
-                }
557
-            }
558
-            // old xoopspoll or umfrage or any clone from them
559
-        } else {
560
-            $pollObject    = new $classPoll($poll_id);
561
-            $classRenderer = $classPoll . 'Renderer';
562
-            $renderer      = new $classRenderer($pollObject);
563
-            $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2);
564
-            $xoopsTpl->assign('has_ended', $pollObject->getVar('end_time') < time() ? 1 : 0);
565
-            // umfrage has polltype
566
-            $polltype = $pollObject->getVar('polltype');
567
-            if (!empty($polltype)) {
568
-                $xoopsTpl->assign('polltype', $polltype);
569
-                switch ($polltype) {
570
-                    case 1:
571
-                        $xoopsTpl->assign('polltypecomment', '');
572
-                        break;
573
-                    case 2:
574
-                        $xoopsTpl->assign('polltypecomment', _PL_FULLBLIND);
575
-                        break;
576
-                    case 3:
577
-                        $xoopsTpl->assign('polltypecomment', _PL_HALFBLIND);
578
-                        break;
579
-
580
-                }
581
-            }
582
-            $classLog = $classPoll . 'Log';
583
-            $hasvoted = 0;
584
-            if ($GLOBALS['xoopsUser']) {
585
-                if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $uid)) {
586
-                    $hasvoted = 1;
587
-                }
588
-            } else {
589
-                $hasvoted = 1;
590
-            }
591
-            $xoopsTpl->assign('hasVoted', $hasvoted);
592
-            $xoopsTpl->assign('lang_vote', _PL_VOTE);
593
-            $xoopsTpl->assign('lang_results', $pollObject->getVar('end_time') < time() ? _PL_RESULTS : _PL_STANDINGS);
594
-            // irmtfan - if the poll is expired show the result
595
-            if ($hasvoted || $pollObject->hasExpired()) {
596
-                $renderer->assignResults($xoopsTpl);
597
-                $xoopsTpl->assign('topic_pollresult', 1);
598
-                setcookie('newbb_polls[' . $poll_id . ']', 1);
599
-            } else {
600
-                $renderer->assignForm($xoopsTpl);
601
-                $xoopsTpl->assign('lang_vote', _PL_VOTE);
602
-                $xoopsTpl->assign('lang_results', _PL_RESULTS);
603
-                setcookie('newbb_polls[' . $poll_id . ']', 1);
604
-            }
605
-        }
606
-    }
607
-    // END can vote in poll
608
-    // START can add poll
609
-    if ($pollAdd) {
610
-        if (!$topicObject->getVar('topic_haspoll')) {
611
-            if (is_object($GLOBALS['xoopsUser'])
612
-                && $GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster')) {
613
-                $t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL);
614
-                $xoopsTpl->assign('forum_addpoll', '<a href=\'' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=add&amp;topic_id=' . $topic_id . '\'>' . $t_poll . '</a>');
615
-            }
616
-        } elseif ($isAdmin
617
-                  || (is_object($pollObject) && is_object($GLOBALS['xoopsUser'])
618
-                      && $GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) {
619
-            $poll_edit    = '';
620
-            $poll_delete  = '';
621
-            $poll_restart = '';
622
-            $poll_log     = '';
623
-
624
-            $adminpoll_actions                = [];
625
-            $adminpoll_actions['editpoll']    = [
626
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
627
-                'image' => $poll_edit,
628
-                'name'  => _MD_NEWBB_EDITPOLL
629
-            ];
630
-            $adminpoll_actions['deletepoll']  = [
631
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
632
-                'image' => $poll_delete,
633
-                'name'  => _MD_NEWBB_DELETEPOLL
634
-            ];
635
-            $adminpoll_actions['restartpoll'] = [
636
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
637
-                'image' => $poll_restart,
638
-                'name'  => _MD_NEWBB_RESTARTPOLL
639
-            ];
640
-            $adminpoll_actions['logpoll']     = [
641
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=log&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
642
-                'image' => $poll_log,
643
-                'name'  => _MD_NEWBB_POLL_VIEWLOG
644
-            ];
645
-
646
-            $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions);
647
-        }
648
-    }
649
-    // END can add poll
503
+			xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']);
504
+		// old xoopspoll or umfrage or any clone from them
505
+		} else {
506
+			$classPoll = $topicObject->loadOldPoll();
507
+		}
508
+	}
509
+	// START can vote in poll
510
+	if ($pollVote) {
511
+		$xoopsTpl->assign('topic_poll', 1);
512
+		$uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
513
+		// new xoopspoll module
514
+		if ($pollModuleHandler->getVar('version') >= 140) {
515
+			$xpollHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Poll');
516
+			/** @var \XoopsPoll $pollObject */
517
+			$pollObject = $xpollHandler->get($poll_id);
518
+			if (is_object($pollObject)) {
519
+
520
+				/* check to see if user has rights to view the results */
521
+				$vis_return = $pollObject->isResultVisible();
522
+				$isVisible  = $vis_return;
523
+				$visibleMsg = $isVisible ? '' : $vis_return;
524
+
525
+				/* setup the module config handler */
526
+				/** @var \XoopsConfigHandler $configHandler */
527
+				$configHandler = xoops_getHandler('config');
528
+				$xp_config     = $configHandler->getConfigsByCat(0, $pollModuleHandler->getVar('mid'));
529
+
530
+				$GLOBALS['xoopsTpl']->assign([
531
+												 'is_visible'      => $isVisible,
532
+												 'visible_message' => $visibleMsg,
533
+												 'disp_votes'      => $xp_config['disp_vote_nums'],
534
+												 'lang_vote'       => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE'),
535
+												 'lang_results'    => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_RESULTS'),
536
+												 'back_link'       => ''
537
+											 ]);
538
+				$classRenderer = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Renderer';
539
+				/** @var \XoopsModules\Xoopspoll\Renderer $renderer */
540
+				$renderer = new $classRenderer($pollObject);
541
+				// check to see if user has voted, show form if not, otherwise get results for form
542
+
543
+				/** @var \XoopsModules\Xoopspoll\LogHandler $logHandler */
544
+				$logHandler = \XoopsModules\Xoopspoll\Helper::getInstance()->getHandler('Log');
545
+				if ($pollObject->isAllowedToVote()
546
+					&& (!$logHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $uid))) {
547
+					$myTpl = new \XoopsTpl();
548
+					$renderer->assignForm($myTpl);
549
+					$myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&amp;poll_id={$poll_id}"));
550
+					$topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/templates/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '_view.tpl'));
551
+					$GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform);
552
+				} else {
553
+					$GLOBALS['xoopsTpl']->assign('can_vote', false);
554
+					$xoopsTpl->assign('topic_pollresult', 1);
555
+					$GLOBALS['xoopsTpl']->assign('topic_resultform', $renderer->renderResults());
556
+				}
557
+			}
558
+			// old xoopspoll or umfrage or any clone from them
559
+		} else {
560
+			$pollObject    = new $classPoll($poll_id);
561
+			$classRenderer = $classPoll . 'Renderer';
562
+			$renderer      = new $classRenderer($pollObject);
563
+			$xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2);
564
+			$xoopsTpl->assign('has_ended', $pollObject->getVar('end_time') < time() ? 1 : 0);
565
+			// umfrage has polltype
566
+			$polltype = $pollObject->getVar('polltype');
567
+			if (!empty($polltype)) {
568
+				$xoopsTpl->assign('polltype', $polltype);
569
+				switch ($polltype) {
570
+					case 1:
571
+						$xoopsTpl->assign('polltypecomment', '');
572
+						break;
573
+					case 2:
574
+						$xoopsTpl->assign('polltypecomment', _PL_FULLBLIND);
575
+						break;
576
+					case 3:
577
+						$xoopsTpl->assign('polltypecomment', _PL_HALFBLIND);
578
+						break;
579
+
580
+				}
581
+			}
582
+			$classLog = $classPoll . 'Log';
583
+			$hasvoted = 0;
584
+			if ($GLOBALS['xoopsUser']) {
585
+				if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $uid)) {
586
+					$hasvoted = 1;
587
+				}
588
+			} else {
589
+				$hasvoted = 1;
590
+			}
591
+			$xoopsTpl->assign('hasVoted', $hasvoted);
592
+			$xoopsTpl->assign('lang_vote', _PL_VOTE);
593
+			$xoopsTpl->assign('lang_results', $pollObject->getVar('end_time') < time() ? _PL_RESULTS : _PL_STANDINGS);
594
+			// irmtfan - if the poll is expired show the result
595
+			if ($hasvoted || $pollObject->hasExpired()) {
596
+				$renderer->assignResults($xoopsTpl);
597
+				$xoopsTpl->assign('topic_pollresult', 1);
598
+				setcookie('newbb_polls[' . $poll_id . ']', 1);
599
+			} else {
600
+				$renderer->assignForm($xoopsTpl);
601
+				$xoopsTpl->assign('lang_vote', _PL_VOTE);
602
+				$xoopsTpl->assign('lang_results', _PL_RESULTS);
603
+				setcookie('newbb_polls[' . $poll_id . ']', 1);
604
+			}
605
+		}
606
+	}
607
+	// END can vote in poll
608
+	// START can add poll
609
+	if ($pollAdd) {
610
+		if (!$topicObject->getVar('topic_haspoll')) {
611
+			if (is_object($GLOBALS['xoopsUser'])
612
+				&& $GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster')) {
613
+				$t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL);
614
+				$xoopsTpl->assign('forum_addpoll', '<a href=\'' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=add&amp;topic_id=' . $topic_id . '\'>' . $t_poll . '</a>');
615
+			}
616
+		} elseif ($isAdmin
617
+				  || (is_object($pollObject) && is_object($GLOBALS['xoopsUser'])
618
+					  && $GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) {
619
+			$poll_edit    = '';
620
+			$poll_delete  = '';
621
+			$poll_restart = '';
622
+			$poll_log     = '';
623
+
624
+			$adminpoll_actions                = [];
625
+			$adminpoll_actions['editpoll']    = [
626
+				'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
627
+				'image' => $poll_edit,
628
+				'name'  => _MD_NEWBB_EDITPOLL
629
+			];
630
+			$adminpoll_actions['deletepoll']  = [
631
+				'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
632
+				'image' => $poll_delete,
633
+				'name'  => _MD_NEWBB_DELETEPOLL
634
+			];
635
+			$adminpoll_actions['restartpoll'] = [
636
+				'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
637
+				'image' => $poll_restart,
638
+				'name'  => _MD_NEWBB_RESTARTPOLL
639
+			];
640
+			$adminpoll_actions['logpoll']     = [
641
+				'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=log&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
642
+				'image' => $poll_log,
643
+				'name'  => _MD_NEWBB_POLL_VIEWLOG
644
+			];
645
+
646
+			$xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions);
647
+		}
648
+	}
649
+	// END can add poll
650 650
 }
651 651
 if (isset($pollObject)) {
652
-    unset($pollObject);
652
+	unset($pollObject);
653 653
 }
654 654
 // END irmtfan poll_module
655 655
 
@@ -664,68 +664,68 @@  discard block
 block discarded – undo
664 664
 $xoopsTpl->assign('post_content', newbbDisplayImage('post'));
665 665
 
666 666
 if (!empty($GLOBALS['xoopsModuleConfig']['rating_enabled'])) {
667
-    $xoopsTpl->assign('votes', $topicObject->getVar('votes'));
668
-    $rating = number_format($topicObject->getVar('rating') / 2, 0);
669
-    if ($rating < 1) {
670
-        $rating_img = newbbDisplayImage('blank');
671
-    } else {
672
-        // irmtfan - add alt key for rating
673
-        $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating));
674
-    }
675
-    $xoopsTpl->assign('rating_img', $rating_img);
676
-    $xoopsTpl->assign('rate1', newbbDisplayImage('rate1', _MD_NEWBB_RATE1));
677
-    $xoopsTpl->assign('rate2', newbbDisplayImage('rate2', _MD_NEWBB_RATE2));
678
-    $xoopsTpl->assign('rate3', newbbDisplayImage('rate3', _MD_NEWBB_RATE3));
679
-    $xoopsTpl->assign('rate4', newbbDisplayImage('rate4', _MD_NEWBB_RATE4));
680
-    $xoopsTpl->assign('rate5', newbbDisplayImage('rate5', _MD_NEWBB_RATE5));
667
+	$xoopsTpl->assign('votes', $topicObject->getVar('votes'));
668
+	$rating = number_format($topicObject->getVar('rating') / 2, 0);
669
+	if ($rating < 1) {
670
+		$rating_img = newbbDisplayImage('blank');
671
+	} else {
672
+		// irmtfan - add alt key for rating
673
+		$rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating));
674
+	}
675
+	$xoopsTpl->assign('rating_img', $rating_img);
676
+	$xoopsTpl->assign('rate1', newbbDisplayImage('rate1', _MD_NEWBB_RATE1));
677
+	$xoopsTpl->assign('rate2', newbbDisplayImage('rate2', _MD_NEWBB_RATE2));
678
+	$xoopsTpl->assign('rate3', newbbDisplayImage('rate3', _MD_NEWBB_RATE3));
679
+	$xoopsTpl->assign('rate4', newbbDisplayImage('rate4', _MD_NEWBB_RATE4));
680
+	$xoopsTpl->assign('rate5', newbbDisplayImage('rate5', _MD_NEWBB_RATE5));
681 681
 }
682 682
 
683 683
 // create jump box
684 684
 if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) {
685
-    require_once __DIR__ . '/include/functions.forum.php';
686
-    $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id));
685
+	require_once __DIR__ . '/include/functions.forum.php';
686
+	$xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id));
687 687
 }
688 688
 
689 689
 $xoopsTpl->assign([
690
-                      'lang_forum_index' => sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
691
-                      'lang_from'        => _MD_NEWBB_FROM,
692
-                      'lang_joined'      => _MD_NEWBB_JOINED,
693
-                      'lang_posts'       => _MD_NEWBB_POSTS,
694
-                      'lang_poster'      => _MD_NEWBB_POSTER,
695
-                      'lang_thread'      => _MD_NEWBB_THREAD,
696
-                      'lang_edit'        => _EDIT,
697
-                      'lang_delete'      => _DELETE,
698
-                      'lang_reply'       => _REPLY,
699
-                      'lang_postedon'    => _MD_NEWBB_POSTEDON,
700
-                      'lang_groups'      => _MD_NEWBB_GROUPS
701
-                  ]);
690
+					  'lang_forum_index' => sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
691
+					  'lang_from'        => _MD_NEWBB_FROM,
692
+					  'lang_joined'      => _MD_NEWBB_JOINED,
693
+					  'lang_posts'       => _MD_NEWBB_POSTS,
694
+					  'lang_poster'      => _MD_NEWBB_POSTER,
695
+					  'lang_thread'      => _MD_NEWBB_THREAD,
696
+					  'lang_edit'        => _EDIT,
697
+					  'lang_delete'      => _DELETE,
698
+					  'lang_reply'       => _REPLY,
699
+					  'lang_postedon'    => _MD_NEWBB_POSTEDON,
700
+					  'lang_groups'      => _MD_NEWBB_GROUPS
701
+				  ]);
702 702
 
703 703
 $viewmode_options = [];
704 704
 if ('DESC' === $order) {
705
-    $viewmode_options[] = [
706
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=ASC&amp;status=$status&amp;topic_id=' . $topic_id,
707
-        'title' => _OLDESTFIRST
708
-    ];
705
+	$viewmode_options[] = [
706
+		'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=ASC&amp;status=$status&amp;topic_id=' . $topic_id,
707
+		'title' => _OLDESTFIRST
708
+	];
709 709
 } else {
710
-    $viewmode_options[] = [
711
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=DESC&amp;status=$status&amp;topic_id=' . $topic_id,
712
-        'title' => _NEWESTFIRST
713
-    ];
710
+	$viewmode_options[] = [
711
+		'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=DESC&amp;status=$status&amp;topic_id=' . $topic_id,
712
+		'title' => _NEWESTFIRST
713
+	];
714 714
 }
715 715
 
716 716
 switch ($status) {
717
-    case 'active':
718
-        $current_status = '[' . _MD_NEWBB_TYPE_ADMIN . ']';
719
-        break;
720
-    case 'pending':
721
-        $current_status = '[' . _MD_NEWBB_TYPE_PENDING . ']';
722
-        break;
723
-    case 'deleted':
724
-        $current_status = '[' . _MD_NEWBB_TYPE_DELETED . ']';
725
-        break;
726
-    default:
727
-        $current_status = '';
728
-        break;
717
+	case 'active':
718
+		$current_status = '[' . _MD_NEWBB_TYPE_ADMIN . ']';
719
+		break;
720
+	case 'pending':
721
+		$current_status = '[' . _MD_NEWBB_TYPE_PENDING . ']';
722
+		break;
723
+	case 'deleted':
724
+		$current_status = '[' . _MD_NEWBB_TYPE_DELETED . ']';
725
+		break;
726
+	default:
727
+		$current_status = '';
728
+		break;
729 729
 }
730 730
 $xoopsTpl->assign('topicstatus', $current_status);
731 731
 
@@ -741,91 +741,91 @@  discard block
 block discarded – undo
741 741
 //check banning
742 742
 //$moderateHandler = Newbb\Helper::getInstance()->getHandler('Moderate');
743 743
 if (!empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled'])
744
-    && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')
745
-    && $moderateHandler->verifyUser(-1, '', $forumObject->getVar('forum_id'))) {
746
-    // END irmtfan add verifyUser to quick reply
747
-    $forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php', 'post', true);
748
-    if (!is_object($GLOBALS['xoopsUser'])) {
749
-        //$configHandler = xoops_getHandler('config');
750
-        $user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT);
751
-        $user_tray->addElement(new \XoopsFormText(_MD_NEWBB_NAME, 'uname', 26, 255));
752
-        $user_tray->addElement(new \XoopsFormPassword(_MD_NEWBB_PASSWORD, 'pass', 10, 32));
753
-        $login_checkbox = new \XoopsFormCheckBox('', 'login', 1);
754
-        $login_checkbox->addOption(1, _MD_NEWBB_LOGIN);
755
-        $user_tray->addElement($login_checkbox);
756
-        $forum_form->addElement($user_tray);
757
-        $captcha = new \XoopsFormCaptcha('', "topic_{$topic_id}_{$start}");
758
-        $captcha->setConfig('mode', 'text');
759
-        $forum_form->addElement($captcha);
760
-    }
761
-
762
-    //$quickform = ( !empty($GLOBALS['xoopsModuleConfig']["editor_default"]) ) ? $GLOBALS['xoopsModuleConfig']["editor_default"] : "textarea";
763
-    $quickform               = !empty($GLOBALS['xoopsModuleConfig']['editor_quick_default']) ? $GLOBALS['xoopsModuleConfig']['editor_quick_default'] : 'textarea';
764
-    $editor_configs          = [];
765
-    $editor_configs ['name'] = 'message';
766
-    //$editor_configs [ "value" ]     = $message ;
767
-    $editor_configs ['rows']   = empty($GLOBALS['xoopsModuleConfig'] ['editor_rows']) ? 10 : $GLOBALS['xoopsModuleConfig'] ['editor_rows'];
768
-    $editor_configs ['cols']   = empty($GLOBALS['xoopsModuleConfig'] ['editor_cols']) ? 30 : $GLOBALS['xoopsModuleConfig'] ['editor_cols'];
769
-    $editor_configs ['width']  = empty($GLOBALS['xoopsModuleConfig'] ['editor_width']) ? '100%' : $GLOBALS['xoopsModuleConfig'] ['editor_width'];
770
-    $editor_configs ['height'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_height']) ? '400px' : $GLOBALS['xoopsModuleConfig'] ['editor_height'];
771
-    $_editor                   = new \XoopsFormEditor(_MD_NEWBB_MESSAGEC, $quickform, $editor_configs, true);
772
-    $forum_form->addElement($_editor, true);
773
-
774
-    $forum_form->addElement(new \XoopsFormHidden('dohtml', 0));
775
-    $forum_form->addElement(new \XoopsFormHidden('dosmiley', 1));
776
-    $forum_form->addElement(new \XoopsFormHidden('doxcode', 1));
777
-    $forum_form->addElement(new \XoopsFormHidden('dobr', 1));
778
-    $forum_form->addElement(new \XoopsFormHidden('attachsig', 1));
779
-
780
-    $forum_form->addElement(new \XoopsFormHidden('isreply', 1));
781
-
782
-    $forum_form->addElement(new \XoopsFormHidden('subject', _MD_NEWBB_RE . ': ' . $topicObject->getVar('topic_title', 'e')));
783
-    $forum_form->addElement(new \XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id));
784
-    $forum_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
785
-    $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id));
786
-    //$forum_form->addElement(new \XoopsFormHidden('viewmode', $viewmode));
787
-    $forum_form->addElement(new \XoopsFormHidden('order', $order));
788
-    $forum_form->addElement(new \XoopsFormHidden('start', $start));
789
-
790
-    $forum_form->addElement(new \XoopsFormHidden('notify', -1));
791
-    $forum_form->addElement(new \XoopsFormHidden('contents_submit', 1));
792
-
793
-    $submit_button = new \XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit');
794
-    $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value === \'RE\' || document.forms.quick_reply.message.value === \'\') { alert(\'' . _MD_NEWBB_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"');
795
-    $forum_form->addElement($submit_button);
796
-
797
-    $toggles = newbbGetCookie('G', true);
798
-    // START irmtfan improve quickreply smarty variable - add alt key to quick reply button - change $display to $style for more comprehension - add toggle $quickreply['expand']
799
-    $quickreply           = [];
800
-    $qr_collapse          = 't_qr';
801
-    $qr_expand            = 't_qr_expand'; // change this
802
-    $quickreply['icon']   = [
803
-        'expand'   => $iconHandler->getImageSource($qr_expand),
804
-        'collapse' => $iconHandler->getImageSource($qr_collapse)
805
-    ];
806
-    $quickreply['show']   = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled']
807
-    $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles, true) ? false : true) : true;
808
-    if ($quickreply['expand']) {
809
-        $quickreply['style']     = 'block';        //irmtfan move semicolon
810
-        $quickreply_icon_display = $qr_expand;
811
-        $quickreply_alt          = _MD_NEWBB_HIDE . ' ' . _MD_NEWBB_QUICKREPLY;
812
-    } else {
813
-        $quickreply['style']     = 'none';        //irmtfan move semicolon
814
-        $quickreply_icon_display = $qr_collapse;
815
-        $quickreply_alt          = _MD_NEWBB_SEE . ' ' . _MD_NEWBB_QUICKREPLY;
816
-    }
817
-    $quickreply['displayImage'] = newbbDisplayImage($quickreply_icon_display, $quickreply_alt);
818
-    $quickreply['form']         = $forum_form->render();
819
-    $xoopsTpl->assign('quickreply', $quickreply);
820
-    // END irmtfan improve quickreply smarty variable
821
-    unset($forum_form);
744
+	&& $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')
745
+	&& $moderateHandler->verifyUser(-1, '', $forumObject->getVar('forum_id'))) {
746
+	// END irmtfan add verifyUser to quick reply
747
+	$forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php', 'post', true);
748
+	if (!is_object($GLOBALS['xoopsUser'])) {
749
+		//$configHandler = xoops_getHandler('config');
750
+		$user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT);
751
+		$user_tray->addElement(new \XoopsFormText(_MD_NEWBB_NAME, 'uname', 26, 255));
752
+		$user_tray->addElement(new \XoopsFormPassword(_MD_NEWBB_PASSWORD, 'pass', 10, 32));
753
+		$login_checkbox = new \XoopsFormCheckBox('', 'login', 1);
754
+		$login_checkbox->addOption(1, _MD_NEWBB_LOGIN);
755
+		$user_tray->addElement($login_checkbox);
756
+		$forum_form->addElement($user_tray);
757
+		$captcha = new \XoopsFormCaptcha('', "topic_{$topic_id}_{$start}");
758
+		$captcha->setConfig('mode', 'text');
759
+		$forum_form->addElement($captcha);
760
+	}
761
+
762
+	//$quickform = ( !empty($GLOBALS['xoopsModuleConfig']["editor_default"]) ) ? $GLOBALS['xoopsModuleConfig']["editor_default"] : "textarea";
763
+	$quickform               = !empty($GLOBALS['xoopsModuleConfig']['editor_quick_default']) ? $GLOBALS['xoopsModuleConfig']['editor_quick_default'] : 'textarea';
764
+	$editor_configs          = [];
765
+	$editor_configs ['name'] = 'message';
766
+	//$editor_configs [ "value" ]     = $message ;
767
+	$editor_configs ['rows']   = empty($GLOBALS['xoopsModuleConfig'] ['editor_rows']) ? 10 : $GLOBALS['xoopsModuleConfig'] ['editor_rows'];
768
+	$editor_configs ['cols']   = empty($GLOBALS['xoopsModuleConfig'] ['editor_cols']) ? 30 : $GLOBALS['xoopsModuleConfig'] ['editor_cols'];
769
+	$editor_configs ['width']  = empty($GLOBALS['xoopsModuleConfig'] ['editor_width']) ? '100%' : $GLOBALS['xoopsModuleConfig'] ['editor_width'];
770
+	$editor_configs ['height'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_height']) ? '400px' : $GLOBALS['xoopsModuleConfig'] ['editor_height'];
771
+	$_editor                   = new \XoopsFormEditor(_MD_NEWBB_MESSAGEC, $quickform, $editor_configs, true);
772
+	$forum_form->addElement($_editor, true);
773
+
774
+	$forum_form->addElement(new \XoopsFormHidden('dohtml', 0));
775
+	$forum_form->addElement(new \XoopsFormHidden('dosmiley', 1));
776
+	$forum_form->addElement(new \XoopsFormHidden('doxcode', 1));
777
+	$forum_form->addElement(new \XoopsFormHidden('dobr', 1));
778
+	$forum_form->addElement(new \XoopsFormHidden('attachsig', 1));
779
+
780
+	$forum_form->addElement(new \XoopsFormHidden('isreply', 1));
781
+
782
+	$forum_form->addElement(new \XoopsFormHidden('subject', _MD_NEWBB_RE . ': ' . $topicObject->getVar('topic_title', 'e')));
783
+	$forum_form->addElement(new \XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id));
784
+	$forum_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
785
+	$forum_form->addElement(new \XoopsFormHidden('forum', $forum_id));
786
+	//$forum_form->addElement(new \XoopsFormHidden('viewmode', $viewmode));
787
+	$forum_form->addElement(new \XoopsFormHidden('order', $order));
788
+	$forum_form->addElement(new \XoopsFormHidden('start', $start));
789
+
790
+	$forum_form->addElement(new \XoopsFormHidden('notify', -1));
791
+	$forum_form->addElement(new \XoopsFormHidden('contents_submit', 1));
792
+
793
+	$submit_button = new \XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit');
794
+	$submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value === \'RE\' || document.forms.quick_reply.message.value === \'\') { alert(\'' . _MD_NEWBB_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"');
795
+	$forum_form->addElement($submit_button);
796
+
797
+	$toggles = newbbGetCookie('G', true);
798
+	// START irmtfan improve quickreply smarty variable - add alt key to quick reply button - change $display to $style for more comprehension - add toggle $quickreply['expand']
799
+	$quickreply           = [];
800
+	$qr_collapse          = 't_qr';
801
+	$qr_expand            = 't_qr_expand'; // change this
802
+	$quickreply['icon']   = [
803
+		'expand'   => $iconHandler->getImageSource($qr_expand),
804
+		'collapse' => $iconHandler->getImageSource($qr_collapse)
805
+	];
806
+	$quickreply['show']   = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled']
807
+	$quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles, true) ? false : true) : true;
808
+	if ($quickreply['expand']) {
809
+		$quickreply['style']     = 'block';        //irmtfan move semicolon
810
+		$quickreply_icon_display = $qr_expand;
811
+		$quickreply_alt          = _MD_NEWBB_HIDE . ' ' . _MD_NEWBB_QUICKREPLY;
812
+	} else {
813
+		$quickreply['style']     = 'none';        //irmtfan move semicolon
814
+		$quickreply_icon_display = $qr_collapse;
815
+		$quickreply_alt          = _MD_NEWBB_SEE . ' ' . _MD_NEWBB_QUICKREPLY;
816
+	}
817
+	$quickreply['displayImage'] = newbbDisplayImage($quickreply_icon_display, $quickreply_alt);
818
+	$quickreply['form']         = $forum_form->render();
819
+	$xoopsTpl->assign('quickreply', $quickreply);
820
+	// END irmtfan improve quickreply smarty variable
821
+	unset($forum_form);
822 822
 } else {
823
-    $xoopsTpl->assign('quickreply', ['show' => 0]);
823
+	$xoopsTpl->assign('quickreply', ['show' => 0]);
824 824
 }
825 825
 
826 826
 if ($GLOBALS['xoopsModuleConfig']['do_tag']
827
-    && @require_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php')) {
828
-    $xoopsTpl->assign('tagbar', tagBar($topicObject->getVar('topic_tags', 'n')));
827
+	&& @require_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php')) {
828
+	$xoopsTpl->assign('tagbar', tagBar($topicObject->getVar('topic_tags', 'n')));
829 829
 }
830 830
 // irmtfan move to footer.php
831 831
 require_once __DIR__ . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 use XoopsModules\Newbb;
35 35
 use XoopsModules\Xoopspoll;
36 36
 
37
-require_once __DIR__ . '/header.php';
37
+require_once __DIR__.'/header.php';
38 38
 $xoopsLogger->startTime('newBB_viewtopic');
39
-require_once __DIR__ . '/include/functions.read.php';
40
-require_once __DIR__ . '/include/functions.render.php';
39
+require_once __DIR__.'/include/functions.read.php';
40
+require_once __DIR__.'/include/functions.render.php';
41 41
 xoops_loadLanguage('user');
42 42
 
43 43
 /*Build the page query*/
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 $query_array = [];
46 46
 foreach ($query_vars as $var) {
47 47
     if (Request::getString($var, '', 'GET')) {
48
-        $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
48
+        $query_array[$var] = "{$var}=".Request::getString($var, '', 'GET');
49 49
     }
50 50
 }
51 51
 $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 }
74 74
 
75 75
 if (!$topic_id && !$post_id) {
76
-    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
76
+    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/'.$xoopsModule->getVar('dirname').'/index.php' : XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/viewforum.php?forum={$forum_id}";
77 77
     redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
78 78
 }
79 79
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 }
91 91
 
92 92
 if (!is_object($topicObject) || !$topic_id = $topicObject->getVar('topic_id')) {
93
-    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}";
93
+    $redirect = empty($forum_id) ? XOOPS_URL . '/modules/'.$xoopsModule->getVar('dirname').'/index.php' : XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/viewforum.php?forum={$forum_id}";
94 94
     redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
95 95
 }
96 96
 $forum_id = $topicObject->getVar('forum_id');
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
 if ((!$isAdmin && $topicObject->getVar('approved') < 0) || (!$forumHandler->getPermission($forumObject))
104 104
     || (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view'))) {
105
-    redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
105
+    redirect_header(XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewforum.php?forum='.$forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
106 106
 }
107 107
 
108 108
 // START irmtfan - find if topic is read or unread - for all users (member and anon)
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         // hack jump to last post read if post_id is empty - is there any better way?
129 129
         if (empty($post_id) && $topic_is_unread
130 130
             && !empty($GLOBALS['xoopsModuleConfig']['jump_to_topic_last_post_read_enabled'])) {
131
-            header('Location: ' . Request::getString('REQUEST_URI', '', 'SERVER') . '&post_id=' . $topic_last_post_time_or_id_read);
131
+            header('Location: '.Request::getString('REQUEST_URI', '', 'SERVER').'&post_id='.$topic_last_post_time_or_id_read);
132 132
         }
133 133
     }
134 134
 }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 // irmtfan new method
168 168
 if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
169 169
     $xoopsTpl->assign('xoops_module_header', '
170
-    <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forumObject->getVar('forum_id') . '" />
170
+    <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name').'-'.$forumObject->getVar('forum_name').'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/rss.php?f='.$forumObject->getVar('forum_id').'" />
171 171
     ' . @$xoopsTpl->get_template_vars('xoops_module_header'));
172 172
 }
173 173
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
         'collapse' => $iconHandler->getImageSource('more')
196 196
     ];
197 197
     if (1 == $infobox['show']) {
198
-        $infobox['style'] = 'none';        //irmtfan move semicolon
198
+        $infobox['style'] = 'none'; //irmtfan move semicolon
199 199
         $infobox['alt']   = _MD_NEWBB_SEEUSERDATA;
200 200
         $infobox['src']   = 'more';
201 201
     } else {
202
-        $infobox['style'] = 'block';        //irmtfan move semicolon
202
+        $infobox['style'] = 'block'; //irmtfan move semicolon
203 203
         $infobox['alt']   = _MD_NEWBB_HIDEUSERDATA;
204 204
         $infobox['src']   = 'less';
205 205
     }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 // END irmtfan improve infobox
210 210
 
211 211
 $xoopsTpl->assign([
212
-                      'topic_title'    => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?topic_id=' . $topic_id . '">' . $topicObject->getFullTitle() . '</a>',
212
+                      'topic_title'    => '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewtopic.php?topic_id='.$topic_id.'">'.$topicObject->getFullTitle().'</a>',
213 213
                       'forum_name'     => $forumObject->getVar('forum_name'),
214 214
                       'lang_nexttopic' => _MD_NEWBB_NEXTTOPIC,
215 215
                       'lang_prevtopic' => _MD_NEWBB_PREVTOPIC,
@@ -231,20 +231,20 @@  discard block
 block discarded – undo
231 231
 $t_reply = newbbDisplayImage('t_reply', _MD_NEWBB_REPLY);
232 232
 // irmtfan show topic status if show reg is 0 and revise forum_post_or_register
233 233
 if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'post')) {
234
-    $xoopsTpl->assign('forum_post', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/newtopic.php?forum=' . $forum_id . '"> ' . $t_new . '</a>');
234
+    $xoopsTpl->assign('forum_post', '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/newtopic.php?forum='.$forum_id.'"> '.$t_new.'</a>');
235 235
 } else {
236 236
     if ($topicObject->getVar('topic_status')) {
237 237
         $xoopsTpl->assign('topic_lock', _MD_NEWBB_TOPICLOCKED);
238 238
     }
239 239
     if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) {
240
-        $xoopsTpl->assign('forum_register', '<a href="' . XOOPS_URL . '/user.php?xoops_redirect=' . htmlspecialchars($xoopsRequestUri, ENT_QUOTES | ENT_HTML5) . '">' . _MD_NEWBB_REGTOPOST . '</a>');
240
+        $xoopsTpl->assign('forum_register', '<a href="'.XOOPS_URL.'/user.php?xoops_redirect='.htmlspecialchars($xoopsRequestUri, ENT_QUOTES | ENT_HTML5).'">'._MD_NEWBB_REGTOPOST.'</a>');
241 241
     }
242 242
 }
243 243
 // irmtfan for backward compatibility assign forum_post_or_register smarty again.
244
-$xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post') . @$xoopsTpl->get_template_vars('forum_register') . @$xoopsTpl->get_template_vars('topic_lock'));
244
+$xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post').@$xoopsTpl->get_template_vars('forum_register').@$xoopsTpl->get_template_vars('topic_lock'));
245 245
 
246 246
 if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')) {
247
-    $xoopsTpl->assign('forum_reply', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/reply.php?topic_id=' . $topic_id . '"> ' . $t_reply . '</a>');
247
+    $xoopsTpl->assign('forum_reply', '<a href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/reply.php?topic_id='.$topic_id.'"> '.$t_reply.'</a>');
248 248
 }
249 249
 
250 250
 $poster_array  = [];
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     /** @var \XoopsMemberHandler $memberHandler */
266 266
     $memberHandler = xoops_getHandler('member');
267 267
     $userid_array  = array_keys($poster_array);
268
-    $user_criteria = '(' . implode(',', $userid_array) . ')';
268
+    $user_criteria = '('.implode(',', $userid_array).')';
269 269
     $users         = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true);
270 270
 } else {
271 271
     $users = [];
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 
284 284
 if ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $require_reply) {
285 285
     if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) {
286
-        $viewtopic_posters = newbbGetSession('t' . $topic_id, true);
286
+        $viewtopic_posters = newbbGetSession('t'.$topic_id, true);
287 287
         if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) {
288 288
             $viewtopic_posters = $topicHandler->getAllPosters($topicObject);
289
-            newbbSetSession('t' . $topic_id, $viewtopic_posters);
289
+            newbbSetSession('t'.$topic_id, $viewtopic_posters);
290 290
         }
291 291
     } else {
292 292
         $viewtopic_posters = $topicHandler->getAllPosters($topicObject);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
         'post_date'       => 0,
303 303
         'post_image'      => '',
304 304
         'post_title'      => '',
305
-        'post_text'       => '<div style="text-align: center;vertical-align: middle;"><br>' . xoops_getbanner() . '</div>',
305
+        'post_text'       => '<div style="text-align: center;vertical-align: middle;"><br>'.xoops_getbanner().'</div>',
306 306
         'post_attachment' => '',
307 307
         'post_edit'       => 0,
308 308
         'post_no'         => 0,
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 if ($total_posts > $GLOBALS['xoopsModuleConfig']['posts_per_page']) {
340 340
     require_once $GLOBALS['xoops']->path('class/pagenav.php');
341 341
 
342
-    $nav = new \XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&amp;order=' . $order . '&amp;status=' . $status . '&amp;mode=' . $mode);
342
+    $nav = new \XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id='.$topic_id.'&amp;order='.$order.'&amp;status='.$status.'&amp;mode='.$mode);
343 343
     //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite']) && $GLOBALS['xoopsModuleConfig']['do_rewrite'] === 1) $nav->url = XOOPS_URL . $nav->url;
344 344
     if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
345 345
         $navi = $nav->renderSelect();
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 }
360 360
 
361 361
 if (!empty($postsArray[$post_id])) {
362
-    $xoops_pagetitle = $postsArray[$post_id]->getVar('subject') . ' [' . $forumObject->getVar('forum_name') . ']';
362
+    $xoops_pagetitle = $postsArray[$post_id]->getVar('subject').' ['.$forumObject->getVar('forum_name').']';
363 363
     $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
364 364
     $xoopsOption['xoops_pagetitle'] = $xoops_pagetitle;
365 365
     $kw                             = array_unique(explode(' ', strip_tags($postsArray[$post_id]->getVar('post_text')), 150));
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
     $z     = 0;
369 369
     foreach ($kw as $k) {
370 370
         if ($z < 30 && strlen(trim($k)) > 5) {
371
-            $kwort .= trim($k) . ' ';
371
+            $kwort .= trim($k).' ';
372 372
             ++$z;
373 373
         }
374 374
     }
@@ -395,56 +395,56 @@  discard block
 block discarded – undo
395 395
 // START irmtfan add restore to viewtopic
396 396
 // if the topic is active
397 397
 if ($topicObject->getVar('approved') > 0) {
398
-    $admin_actions['merge']  = [
399
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=merge&amp;topic_id=' . $topic_id,
398
+    $admin_actions['merge'] = [
399
+        'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=merge&amp;topic_id='.$topic_id,
400 400
         'name'  => _MD_NEWBB_MERGETOPIC,
401 401
         'image' => $ad_merge
402 402
     ];
403
-    $admin_actions['move']   = [
404
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=move&amp;topic_id=' . $topic_id,
403
+    $admin_actions['move'] = [
404
+        'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=move&amp;topic_id='.$topic_id,
405 405
         'name'  => _MD_NEWBB_MOVETOPIC,
406 406
         'image' => $ad_move
407 407
     ];
408 408
     $admin_actions['delete'] = [
409
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=delete&amp;topic_id=' . $topic_id,
409
+        'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=delete&amp;topic_id='.$topic_id,
410 410
         'name'  => _MD_NEWBB_DELETETOPIC,
411 411
         'image' => $ad_delete
412 412
     ];
413 413
     if (!$topicObject->getVar('topic_status')) {
414 414
         $admin_actions['lock'] = [
415
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=lock&amp;topic_id=' . $topic_id,
415
+            'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=lock&amp;topic_id='.$topic_id,
416 416
             'image' => $ad_lock,
417 417
             'name'  => _MD_NEWBB_LOCKTOPIC
418 418
         ];
419 419
     } else {
420 420
         $admin_actions['unlock'] = [
421
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unlock&amp;topic_id=' . $topic_id,
421
+            'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=unlock&amp;topic_id='.$topic_id,
422 422
             'image' => $ad_unlock,
423 423
             'name'  => _MD_NEWBB_UNLOCKTOPIC
424 424
         ];
425 425
     }
426 426
     if (!$topicObject->getVar('topic_sticky')) {
427 427
         $admin_actions['sticky'] = [
428
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=sticky&amp;topic_id=' . $topic_id,
428
+            'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=sticky&amp;topic_id='.$topic_id,
429 429
             'image' => $ad_sticky,
430 430
             'name'  => _MD_NEWBB_STICKYTOPIC
431 431
         ];
432 432
     } else {
433 433
         $admin_actions['unsticky'] = [
434
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unsticky&amp;topic_id=' . $topic_id,
434
+            'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=unsticky&amp;topic_id='.$topic_id,
435 435
             'image' => $ad_unsticky,
436 436
             'name'  => _MD_NEWBB_UNSTICKYTOPIC
437 437
         ];
438 438
     }
439 439
     if (!$topicObject->getVar('topic_digest')) {
440 440
         $admin_actions['digest'] = [
441
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=digest&amp;topic_id=' . $topic_id,
441
+            'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=digest&amp;topic_id='.$topic_id,
442 442
             'image' => $ad_digest,
443 443
             'name'  => _MD_NEWBB_DIGESTTOPIC
444 444
         ];
445 445
     } else {
446 446
         $admin_actions['undigest'] = [
447
-            'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=undigest&amp;topic_id=' . $topic_id,
447
+            'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=undigest&amp;topic_id='.$topic_id,
448 448
             'image' => $ad_undigest,
449 449
             'name'  => _MD_NEWBB_UNDIGESTTOPIC
450 450
         ];
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
     // if the topic is pending/deleted then restore/approve
453 453
 } else {
454 454
     $admin_actions['restore'] = [
455
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=restore&amp;topic_id=' . $topic_id,
455
+        'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/topicmanager.php?mode=restore&amp;topic_id='.$topic_id,
456 456
         'name'  => _MD_NEWBB_RESTORETOPIC,
457 457
         'image' => $ad_restore
458 458
     ];
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
                                                  'is_visible'      => $isVisible,
532 532
                                                  'visible_message' => $visibleMsg,
533 533
                                                  'disp_votes'      => $xp_config['disp_vote_nums'],
534
-                                                 'lang_vote'       => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE'),
535
-                                                 'lang_results'    => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_RESULTS'),
534
+                                                 'lang_vote'       => constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'_VOTE'),
535
+                                                 'lang_results'    => constant('_MD_'.strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']).'_RESULTS'),
536 536
                                                  'back_link'       => ''
537 537
                                              ]);
538
-                $classRenderer = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Renderer';
538
+                $classRenderer = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']).'Renderer';
539 539
                 /** @var \XoopsModules\Xoopspoll\Renderer $renderer */
540 540
                 $renderer = new $classRenderer($pollObject);
541 541
                 // check to see if user has voted, show form if not, otherwise get results for form
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                     $myTpl = new \XoopsTpl();
548 548
                     $renderer->assignForm($myTpl);
549 549
                     $myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&amp;poll_id={$poll_id}"));
550
-                    $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/templates/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '_view.tpl'));
550
+                    $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/templates/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'_view.tpl'));
551 551
                     $GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform);
552 552
                 } else {
553 553
                     $GLOBALS['xoopsTpl']->assign('can_vote', false);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
             // old xoopspoll or umfrage or any clone from them
559 559
         } else {
560 560
             $pollObject    = new $classPoll($poll_id);
561
-            $classRenderer = $classPoll . 'Renderer';
561
+            $classRenderer = $classPoll.'Renderer';
562 562
             $renderer      = new $classRenderer($pollObject);
563 563
             $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2);
564 564
             $xoopsTpl->assign('has_ended', $pollObject->getVar('end_time') < time() ? 1 : 0);
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 
580 580
                 }
581 581
             }
582
-            $classLog = $classPoll . 'Log';
582
+            $classLog = $classPoll.'Log';
583 583
             $hasvoted = 0;
584 584
             if ($GLOBALS['xoopsUser']) {
585 585
                 if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $uid)) {
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
             if ($hasvoted || $pollObject->hasExpired()) {
596 596
                 $renderer->assignResults($xoopsTpl);
597 597
                 $xoopsTpl->assign('topic_pollresult', 1);
598
-                setcookie('newbb_polls[' . $poll_id . ']', 1);
598
+                setcookie('newbb_polls['.$poll_id.']', 1);
599 599
             } else {
600 600
                 $renderer->assignForm($xoopsTpl);
601 601
                 $xoopsTpl->assign('lang_vote', _PL_VOTE);
602 602
                 $xoopsTpl->assign('lang_results', _PL_RESULTS);
603
-                setcookie('newbb_polls[' . $poll_id . ']', 1);
603
+                setcookie('newbb_polls['.$poll_id.']', 1);
604 604
             }
605 605
         }
606 606
     }
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
             if (is_object($GLOBALS['xoopsUser'])
612 612
                 && $GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster')) {
613 613
                 $t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL);
614
-                $xoopsTpl->assign('forum_addpoll', '<a href=\'' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=add&amp;topic_id=' . $topic_id . '\'>' . $t_poll . '</a>');
614
+                $xoopsTpl->assign('forum_addpoll', '<a href=\''.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/polls.php?op=add&amp;topic_id='.$topic_id.'\'>'.$t_poll.'</a>');
615 615
             }
616 616
         } elseif ($isAdmin
617 617
                   || (is_object($pollObject) && is_object($GLOBALS['xoopsUser'])
@@ -623,22 +623,22 @@  discard block
 block discarded – undo
623 623
 
624 624
             $adminpoll_actions                = [];
625 625
             $adminpoll_actions['editpoll']    = [
626
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
626
+                'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/polls.php?op=edit&amp;poll_id='.$topicObject->getVar('poll_id').'&amp;topic_id='.$topic_id,
627 627
                 'image' => $poll_edit,
628 628
                 'name'  => _MD_NEWBB_EDITPOLL
629 629
             ];
630
-            $adminpoll_actions['deletepoll']  = [
631
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id,
630
+            $adminpoll_actions['deletepoll'] = [
631
+                'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/polls.php?op=delete&amp;poll_id='.$topicObject->getVar('poll_id').'&amp;topic_id='.$topic_id,
632 632
                 'image' => $poll_delete,
633 633
                 'name'  => _MD_NEWBB_DELETEPOLL
634 634
             ];
635 635
             $adminpoll_actions['restartpoll'] = [
636
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
636
+                'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/polls.php?op=restart&amp;poll_id='.$topicObject->getVar('poll_id').'&amp;topic_id='.$topic_id.'&amp;forum='.$forum_id,
637 637
                 'image' => $poll_restart,
638 638
                 'name'  => _MD_NEWBB_RESTARTPOLL
639 639
             ];
640
-            $adminpoll_actions['logpoll']     = [
641
-                'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=log&amp;poll_id=' . $topicObject->getVar('poll_id') . '&amp;topic_id=' . $topic_id . '&amp;forum=' . $forum_id,
640
+            $adminpoll_actions['logpoll'] = [
641
+                'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/polls.php?op=log&amp;poll_id='.$topicObject->getVar('poll_id').'&amp;topic_id='.$topic_id.'&amp;forum='.$forum_id,
642 642
                 'image' => $poll_log,
643 643
                 'name'  => _MD_NEWBB_POLL_VIEWLOG
644 644
             ];
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
         $rating_img = newbbDisplayImage('blank');
671 671
     } else {
672 672
         // irmtfan - add alt key for rating
673
-        $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating));
673
+        $rating_img = newbbDisplayImage('rate'.$rating, constant('_MD_NEWBB_RATE'.$rating));
674 674
     }
675 675
     $xoopsTpl->assign('rating_img', $rating_img);
676 676
     $xoopsTpl->assign('rate1', newbbDisplayImage('rate1', _MD_NEWBB_RATE1));
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 
683 683
 // create jump box
684 684
 if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) {
685
-    require_once __DIR__ . '/include/functions.forum.php';
685
+    require_once __DIR__.'/include/functions.forum.php';
686 686
     $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id));
687 687
 }
688 688
 
@@ -703,25 +703,25 @@  discard block
 block discarded – undo
703 703
 $viewmode_options = [];
704 704
 if ('DESC' === $order) {
705 705
     $viewmode_options[] = [
706
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=ASC&amp;status=$status&amp;topic_id=' . $topic_id,
706
+        'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewtopic.php?order=ASC&amp;status=$status&amp;topic_id='.$topic_id,
707 707
         'title' => _OLDESTFIRST
708 708
     ];
709 709
 } else {
710 710
     $viewmode_options[] = [
711
-        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=DESC&amp;status=$status&amp;topic_id=' . $topic_id,
711
+        'link'  => XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewtopic.php?order=DESC&amp;status=$status&amp;topic_id='.$topic_id,
712 712
         'title' => _NEWESTFIRST
713 713
     ];
714 714
 }
715 715
 
716 716
 switch ($status) {
717 717
     case 'active':
718
-        $current_status = '[' . _MD_NEWBB_TYPE_ADMIN . ']';
718
+        $current_status = '['._MD_NEWBB_TYPE_ADMIN.']';
719 719
         break;
720 720
     case 'pending':
721
-        $current_status = '[' . _MD_NEWBB_TYPE_PENDING . ']';
721
+        $current_status = '['._MD_NEWBB_TYPE_PENDING.']';
722 722
         break;
723 723
     case 'deleted':
724
-        $current_status = '[' . _MD_NEWBB_TYPE_DELETED . ']';
724
+        $current_status = '['._MD_NEWBB_TYPE_DELETED.']';
725 725
         break;
726 726
     default:
727 727
         $current_status = '';
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
     && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')
745 745
     && $moderateHandler->verifyUser(-1, '', $forumObject->getVar('forum_id'))) {
746 746
     // END irmtfan add verifyUser to quick reply
747
-    $forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php', 'post', true);
747
+    $forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/post.php', 'post', true);
748 748
     if (!is_object($GLOBALS['xoopsUser'])) {
749 749
         //$configHandler = xoops_getHandler('config');
750 750
         $user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT);
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 
780 780
     $forum_form->addElement(new \XoopsFormHidden('isreply', 1));
781 781
 
782
-    $forum_form->addElement(new \XoopsFormHidden('subject', _MD_NEWBB_RE . ': ' . $topicObject->getVar('topic_title', 'e')));
782
+    $forum_form->addElement(new \XoopsFormHidden('subject', _MD_NEWBB_RE.': '.$topicObject->getVar('topic_title', 'e')));
783 783
     $forum_form->addElement(new \XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id));
784 784
     $forum_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
785 785
     $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id));
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     $forum_form->addElement(new \XoopsFormHidden('contents_submit', 1));
792 792
 
793 793
     $submit_button = new \XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit');
794
-    $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value === \'RE\' || document.forms.quick_reply.message.value === \'\') { alert(\'' . _MD_NEWBB_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"');
794
+    $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value === \'RE\' || document.forms.quick_reply.message.value === \'\') { alert(\''._MD_NEWBB_QUICKREPLY_EMPTY.'\'); return false;} else { return true;}"');
795 795
     $forum_form->addElement($submit_button);
796 796
 
797 797
     $toggles = newbbGetCookie('G', true);
@@ -806,13 +806,13 @@  discard block
 block discarded – undo
806 806
     $quickreply['show']   = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled']
807 807
     $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles, true) ? false : true) : true;
808 808
     if ($quickreply['expand']) {
809
-        $quickreply['style']     = 'block';        //irmtfan move semicolon
809
+        $quickreply['style']     = 'block'; //irmtfan move semicolon
810 810
         $quickreply_icon_display = $qr_expand;
811
-        $quickreply_alt          = _MD_NEWBB_HIDE . ' ' . _MD_NEWBB_QUICKREPLY;
811
+        $quickreply_alt          = _MD_NEWBB_HIDE.' '._MD_NEWBB_QUICKREPLY;
812 812
     } else {
813
-        $quickreply['style']     = 'none';        //irmtfan move semicolon
813
+        $quickreply['style']     = 'none'; //irmtfan move semicolon
814 814
         $quickreply_icon_display = $qr_collapse;
815
-        $quickreply_alt          = _MD_NEWBB_SEE . ' ' . _MD_NEWBB_QUICKREPLY;
815
+        $quickreply_alt          = _MD_NEWBB_SEE.' '._MD_NEWBB_QUICKREPLY;
816 816
     }
817 817
     $quickreply['displayImage'] = newbbDisplayImage($quickreply_icon_display, $quickreply_alt);
818 818
     $quickreply['form']         = $forum_form->render();
@@ -828,6 +828,6 @@  discard block
 block discarded – undo
828 828
     $xoopsTpl->assign('tagbar', tagBar($topicObject->getVar('topic_tags', 'n')));
829 829
 }
830 830
 // irmtfan move to footer.php
831
-require_once __DIR__ . '/footer.php';
831
+require_once __DIR__.'/footer.php';
832 832
 require_once $GLOBALS['xoops']->path('footer.php');
833 833
 $xoopsLogger->stopTime('newBB_viewtopic');
Please login to merge, or discard this patch.
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.
admin/index.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function newbb_admin_mkdir($target, $mode = 0777)
51 51
 {
52
-    $target = str_replace('..', '', $target);
52
+	$target = str_replace('..', '', $target);
53 53
 
54
-    // http://www.php.net/manual/en/function.mkdir.php
55
-    return is_dir($target) || (newbb_admin_mkdir(dirname($target), $mode) && (!mkdir($target, $mode) && !is_dir($target)));
54
+	// http://www.php.net/manual/en/function.mkdir.php
55
+	return is_dir($target) || (newbb_admin_mkdir(dirname($target), $mode) && (!mkdir($target, $mode) && !is_dir($target)));
56 56
 }
57 57
 
58 58
 /**
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
  */
63 63
 function newbb_admin_chmod($target, $mode = 0777)
64 64
 {
65
-    $target = str_replace('..', '', $target);
65
+	$target = str_replace('..', '', $target);
66 66
 
67
-    return @chmod($target, $mode);
67
+	return @chmod($target, $mode);
68 68
 }
69 69
 
70 70
 /**
@@ -72,32 +72,32 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function newbb_getImageLibs()
74 74
 {
75
-    $imageLibs = [];
76
-    unset($output, $status);
77
-    if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
78
-        $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
79
-        @exec($path . 'convert -version', $output, $status);
80
-        if (empty($status) && !empty($output) && preg_match("/imagemagick[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
81
-            $imageLibs['imagemagick'] = $matches[0];
82
-        }
83
-
84
-        unset($output, $status);
85
-    }
86
-    if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
87
-        $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
88
-        @exec($path . 'jpegtopnm -version 2>&1', $output, $status);
89
-        if (empty($status) && !empty($output) && preg_match("/netpbm[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
90
-            $imageLibs['netpbm'] = $matches[0];
91
-        }
92
-        unset($output, $status);
93
-    }
94
-
95
-    if (function_exists('gd_info')) {
96
-        $tmpInfo         = gd_info();
97
-        $imageLibs['gd'] = $tmpInfo['GD Version'];
98
-    }
99
-
100
-    return $imageLibs;
75
+	$imageLibs = [];
76
+	unset($output, $status);
77
+	if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
78
+		$path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
79
+		@exec($path . 'convert -version', $output, $status);
80
+		if (empty($status) && !empty($output) && preg_match("/imagemagick[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
81
+			$imageLibs['imagemagick'] = $matches[0];
82
+		}
83
+
84
+		unset($output, $status);
85
+	}
86
+	if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
87
+		$path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
88
+		@exec($path . 'jpegtopnm -version 2>&1', $output, $status);
89
+		if (empty($status) && !empty($output) && preg_match("/netpbm[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
90
+			$imageLibs['netpbm'] = $matches[0];
91
+		}
92
+		unset($output, $status);
93
+	}
94
+
95
+	if (function_exists('gd_info')) {
96
+		$tmpInfo         = gd_info();
97
+		$imageLibs['gd'] = $tmpInfo['GD Version'];
98
+	}
99
+
100
+	return $imageLibs;
101 101
 }
102 102
 
103 103
 xoops_cp_header();
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 //XOOPS_POLL
114 114
 $xoopspoll = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
115 115
 if (is_object($xoopspoll)) {
116
-    $isOK = $xoopspoll->getVar('isactive');
116
+	$isOK = $xoopspoll->getVar('isactive');
117 117
 }
118 118
 // END irmtfan add a poll_module config
119 119
 
@@ -121,19 +121,19 @@  discard block
 block discarded – undo
121 121
 $postmaxsize_iniphp = return_bytes(@ini_get('post_max_size'));
122 122
 $uploadlimit        = _AM_NEWBB_MEMLIMITTOLARGE;
123 123
 if ($postmaxsize_iniphp < $memlimit_iniphp) {
124
-    $uploadlimit = sprintf(_AM_NEWBB_MEMLIMITOK, return_bytes($postmaxsize_iniphp, true));
124
+	$uploadlimit = sprintf(_AM_NEWBB_MEMLIMITOK, return_bytes($postmaxsize_iniphp, true));
125 125
 }
126 126
 
127 127
 $adminObject->addInfoBox(_AM_NEWBB_PREFERENCES);
128 128
 // START irmtfan better poll module display link and version - check if xoops poll module is available
129 129
 if ($isOK) {
130
-    $pollLink = _AM_NEWBB_AVAILABLE . ': ';
131
-    $pollLink .= '<a href="' . XOOPS_URL . '/modules/' . $xoopspoll->getVar('dirname') . '/admin/index.php"';
132
-    $pollLink .= ' alt="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
133
-    $pollLink .= ' title="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
134
-    $pollLink .= '>' . '(' . $xoopspoll->getVar('name') . ')</a>';
130
+	$pollLink = _AM_NEWBB_AVAILABLE . ': ';
131
+	$pollLink .= '<a href="' . XOOPS_URL . '/modules/' . $xoopspoll->getVar('dirname') . '/admin/index.php"';
132
+	$pollLink .= ' alt="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
133
+	$pollLink .= ' title="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
134
+	$pollLink .= '>' . '(' . $xoopspoll->getVar('name') . ')</a>';
135 135
 } else {
136
-    $pollLink = _AM_NEWBB_NOTAVAILABLE;
136
+	$pollLink = _AM_NEWBB_NOTAVAILABLE;
137 137
 }
138 138
 $adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_POLLMODULE . ': %s', $pollLink));
139 139
 // END irmtfan better poll module display link and version - check if xoops poll module is available
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 $adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_REPORT_PROCESSED . ': %s', $reportHandler->getCount(new \Criteria('report_result', 1))));
154 154
 
155 155
 foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
156
-    Newbb\Utility::prepareFolder($uploadFolders[$i]);
157
-    $adminObject->addConfigBoxLine($uploadFolders[$i], 'folder');
156
+	Newbb\Utility::prepareFolder($uploadFolders[$i]);
157
+	$adminObject->addConfigBoxLine($uploadFolders[$i], 'folder');
158 158
 }
159 159
 
160 160
 $adminObject->displayNavigation(basename(__FILE__));
@@ -174,24 +174,24 @@  discard block
 block discarded – undo
174 174
  */
175 175
 function return_bytes($sizeAsString, $b = false)
176 176
 {
177
-    if (false === $b) {
178
-        switch (substr($sizeAsString, -1)) {
179
-            case 'M':
180
-            case 'm':
181
-                return (int)$sizeAsString * 1048576;
182
-            case 'K':
183
-            case 'k':
184
-                return (int)$sizeAsString * 1024;
185
-            case 'G':
186
-            case 'g':
187
-                return (int)$sizeAsString * 1073741824;
188
-            default:
189
-                return $sizeAsString;
190
-        }
191
-    } else {
192
-        $base   = log($sizeAsString) / log(1024);
193
-        $suffix = ['', 'KB', 'MB', 'GB', 'TB'];
194
-
195
-        return round(1024 ** ($base - floor($base))) . ' ' . $suffix[(int)floor($base)];
196
-    }
177
+	if (false === $b) {
178
+		switch (substr($sizeAsString, -1)) {
179
+			case 'M':
180
+			case 'm':
181
+				return (int)$sizeAsString * 1048576;
182
+			case 'K':
183
+			case 'k':
184
+				return (int)$sizeAsString * 1024;
185
+			case 'G':
186
+			case 'g':
187
+				return (int)$sizeAsString * 1073741824;
188
+			default:
189
+				return $sizeAsString;
190
+		}
191
+	} else {
192
+		$base   = log($sizeAsString) / log(1024);
193
+		$suffix = ['', 'KB', 'MB', 'GB', 'TB'];
194
+
195
+		return round(1024 ** ($base - floor($base))) . ' ' . $suffix[(int)floor($base)];
196
+	}
197 197
 }
Please login to merge, or discard this patch.
class/Common/Breadcrumb.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -31,49 +31,49 @@
 block discarded – undo
31 31
  */
32 32
 class Breadcrumb
33 33
 {
34
-    /** @var string */
35
-    private $dirname;
34
+	/** @var string */
35
+	private $dirname;
36 36
 
37
-    /** @var array */
38
-    private $bread = [];
37
+	/** @var array */
38
+	private $bread = [];
39 39
 
40
-    public function __construct()
41
-    {
42
-        $this->dirname = basename(dirname(dirname(__DIR__)));
43
-    }
40
+	public function __construct()
41
+	{
42
+		$this->dirname = basename(dirname(dirname(__DIR__)));
43
+	}
44 44
 
45
-    /**
46
-     * Add link to breadcrumb
47
-     *
48
-     * @param string $title
49
-     * @param string $link
50
-     */
51
-    public function addLink($title = '', $link = '')
52
-    {
53
-        $this->bread[] = [
54
-            'link'  => $link,
55
-            'title' => $title
56
-        ];
57
-    }
45
+	/**
46
+	 * Add link to breadcrumb
47
+	 *
48
+	 * @param string $title
49
+	 * @param string $link
50
+	 */
51
+	public function addLink($title = '', $link = '')
52
+	{
53
+		$this->bread[] = [
54
+			'link'  => $link,
55
+			'title' => $title
56
+		];
57
+	}
58 58
 
59
-    /**
60
-     * Render Pedigree BreadCrumb
61
-     *
62
-     * @return string
63
-     */
64
-    public function render()
65
-    {
66
-        if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
67
-            require_once $GLOBALS['xoops']->path('class/theme.php');
68
-            $GLOBALS['xoTheme'] = new \xos_opal_Theme();
69
-        }
59
+	/**
60
+	 * Render Pedigree BreadCrumb
61
+	 *
62
+	 * @return string
63
+	 */
64
+	public function render()
65
+	{
66
+		if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
67
+			require_once $GLOBALS['xoops']->path('class/theme.php');
68
+			$GLOBALS['xoTheme'] = new \xos_opal_Theme();
69
+		}
70 70
 
71
-        require_once $GLOBALS['xoops']->path('class/template.php');
72
-        $breadcrumbTpl = new \XoopsTpl();
73
-        $breadcrumbTpl->assign('breadcrumb', $this->bread);
74
-        $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
75
-        unset($breadcrumbTpl);
71
+		require_once $GLOBALS['xoops']->path('class/template.php');
72
+		$breadcrumbTpl = new \XoopsTpl();
73
+		$breadcrumbTpl->assign('breadcrumb', $this->bread);
74
+		$html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl');
75
+		unset($breadcrumbTpl);
76 76
 
77
-        return $html;
78
-    }
77
+		return $html;
78
+	}
79 79
 }
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/Post.php 1 patch
Indentation   +668 added lines, -668 removed lines patch added patch discarded remove patch
@@ -43,672 +43,672 @@
 block discarded – undo
43 43
  */
44 44
 class Post extends \XoopsObject
45 45
 {
46
-    //class Post extends \XoopsObject {
47
-    private $attachmentArray = [];
48
-
49
-    /**
50
-     *
51
-     */
52
-    public function __construct()
53
-    {
54
-        parent::__construct();
55
-
56
-        $this->initVar('post_id', XOBJ_DTYPE_INT);
57
-        $this->initVar('topic_id', XOBJ_DTYPE_INT, 0, true);
58
-        $this->initVar('forum_id', XOBJ_DTYPE_INT, 0, true);
59
-        $this->initVar('post_time', XOBJ_DTYPE_INT, 0, true);
60
-        //        $this->initVar('poster_ip', XOBJ_DTYPE_INT, 0);
61
-        $this->initVar('poster_ip', XOBJ_DTYPE_TXTBOX, '');
62
-        $this->initVar('poster_name', XOBJ_DTYPE_TXTBOX, '');
63
-        $this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true);
64
-        $this->initVar('pid', XOBJ_DTYPE_INT, 0);
65
-        $this->initVar('dohtml', XOBJ_DTYPE_INT, 0);
66
-        $this->initVar('dosmiley', XOBJ_DTYPE_INT, 1);
67
-        $this->initVar('doxcode', XOBJ_DTYPE_INT, 1);
68
-        $this->initVar('doimage', XOBJ_DTYPE_INT, 1);
69
-        $this->initVar('dobr', XOBJ_DTYPE_INT, 1);
70
-        $this->initVar('uid', XOBJ_DTYPE_INT, 1);
71
-        $this->initVar('icon', XOBJ_DTYPE_TXTBOX, '');
72
-        $this->initVar('attachsig', XOBJ_DTYPE_INT, 0);
73
-        $this->initVar('approved', XOBJ_DTYPE_INT, 1);
74
-        $this->initVar('post_karma', XOBJ_DTYPE_INT, 0);
75
-        $this->initVar('require_reply', XOBJ_DTYPE_INT, 0);
76
-        $this->initVar('attachment', XOBJ_DTYPE_TXTAREA, '');
77
-        $this->initVar('post_text', XOBJ_DTYPE_TXTAREA, '');
78
-        $this->initVar('post_edit', XOBJ_DTYPE_TXTAREA, '');
79
-    }
80
-
81
-    // ////////////////////////////////////////////////////////////////////////////////////
82
-    // attachment functions    TODO: there should be a file/attachment management class
83
-    /**
84
-     * @return array|mixed|null
85
-     */
86
-    public function getAttachment()
87
-    {
88
-        if (count($this->attachmentArray)) {
89
-            return $this->attachmentArray;
90
-        }
91
-        $attachment = $this->getVar('attachment');
92
-        if (empty($attachment)) {
93
-            $this->attachmentArray = [];
94
-        } else {
95
-            $this->attachmentArray = @unserialize(base64_decode($attachment));
96
-        }
97
-
98
-        return $this->attachmentArray;
99
-    }
100
-
101
-    /**
102
-     * @param $attachKey
103
-     * @return bool
104
-     */
105
-    public function incrementDownload($attachKey)
106
-    {
107
-        if (!$attachKey) {
108
-            return false;
109
-        }
110
-        $this->attachmentArray[(string)$attachKey]['numDownload']++;
111
-
112
-        return $this->attachmentArray[(string)$attachKey]['numDownload'];
113
-    }
114
-
115
-    /**
116
-     * @return bool
117
-     */
118
-    public function saveAttachment()
119
-    {
120
-        $attachmentSave = '';
121
-        if (is_array($this->attachmentArray) && count($this->attachmentArray) > 0) {
122
-            $attachmentSave = base64_encode(serialize($this->attachmentArray));
123
-        }
124
-        $this->setVar('attachment', $attachmentSave);
125
-        $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' SET attachment=' . $GLOBALS['xoopsDB']->quoteString($attachmentSave) . ' WHERE post_id = ' . $this->getVar('post_id');
126
-        if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
127
-            //xoops_error($GLOBALS['xoopsDB']->error());
128
-            return false;
129
-        }
130
-
131
-        return true;
132
-    }
133
-
134
-    /**
135
-     * @param  array|null $attachArray
136
-     * @return bool
137
-     */
138
-    public function deleteAttachment($attachArray = null)
139
-    {
140
-        $attachOld = $this->getAttachment();
141
-        if (!is_array($attachOld) || count($attachOld) < 1) {
142
-            return true;
143
-        }
144
-        $this->attachmentArray = [];
145
-
146
-        if (null === $attachArray) {
147
-            $attachArray = array_keys($attachOld);
148
-        } // to delete all!
149
-        if (!is_array($attachArray)) {
150
-            $attachArray = [$attachArray];
151
-        }
152
-
153
-        foreach ($attachOld as $key => $attach) {
154
-            if (in_array($key, $attachArray)) {
155
-                @unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']));
156
-                @unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved'])); // delete thumbnails
157
-                continue;
158
-            }
159
-            $this->attachmentArray[$key] = $attach;
160
-        }
161
-        $attachmentSave = '';
162
-        if (is_array($this->attachmentArray) && count($this->attachmentArray) > 0) {
163
-            $attachmentSave = base64_encode(serialize($this->attachmentArray));
164
-        }
165
-        $this->setVar('attachment', $attachmentSave);
166
-
167
-        return true;
168
-    }
169
-
170
-    /**
171
-     * @param  string $name_saved
172
-     * @param  string $nameDisplay
173
-     * @param  string $mimetype
174
-     * @param  int    $numDownload
175
-     * @return bool
176
-     */
177
-    public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = '', $numDownload = 0)
178
-    {
179
-        static $counter = 0;
180
-        $this->attachmentArray = $this->getAttachment();
181
-        if ($name_saved) {
182
-            $key                         = (string)(time() + $counter++);
183
-            $this->attachmentArray[$key] = [
184
-                'name_saved'  => $name_saved,
185
-                'nameDisplay' => empty($nameDisplay) ? $nameDisplay : $name_saved,
186
-                'mimetype'    => $mimetype,
187
-                'numDownload' => empty($numDownload) ? (int)$numDownload : 0
188
-            ];
189
-        }
190
-        $attachmentSave = null;
191
-        if (is_array($this->attachmentArray)) {
192
-            $attachmentSave = base64_encode(serialize($this->attachmentArray));
193
-        }
194
-        $this->setVar('attachment', $attachmentSave);
195
-
196
-        return true;
197
-    }
198
-
199
-    /**
200
-     * TODO: refactor
201
-     * @param  bool $asSource
202
-     * @return string
203
-     */
204
-    public function displayAttachment($asSource = false)
205
-    {
206
-        global $xoopsModule;
207
-
208
-        $post_attachment = '';
209
-        $attachments     = $this->getAttachment();
210
-        if (is_array($attachments) && count($attachments) > 0) {
211
-            $iconHandler = newbbGetIconHandler();
212
-            $mime_path   = $iconHandler->getPath('mime');
213
-            require_once dirname(__DIR__) . '/include/functions.image.php';
214
-            $image_extensions = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; // need improve !!!
215
-            $post_attachment  .= '<br><strong>' . _MD_NEWBB_ATTACHMENT . '</strong>:';
216
-            $post_attachment  .= '<br><hr size="1" noshade="noshade" /><br>';
217
-            foreach ($attachments as $key => $att) {
218
-                $file_extension = ltrim(strrchr($att['name_saved'], '.'), '.');
219
-                $filetype       = $file_extension;
220
-                if (file_exists($GLOBALS['xoops']->path($mime_path . '/' . $filetype . '.gif'))) {
221
-                    $icon_filetype = XOOPS_URL . '/' . $mime_path . '/' . $filetype . '.gif';
222
-                } else {
223
-                    $icon_filetype = XOOPS_URL . '/' . $mime_path . '/unknown.gif';
224
-                }
225
-                $file_size = @filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved']));
226
-                $file_size = number_format($file_size / 1024, 2) . ' KB';
227
-                if (in_array(strtolower($file_extension), $image_extensions)
228
-                    && $GLOBALS['xoopsModuleConfig']['media_allowed']) {
229
-                    $post_attachment .= '<br><img src="' . $icon_filetype . '" alt="' . $filetype . '" /><strong>&nbsp; ' . $att['nameDisplay'] . '</strong> <small>(' . $file_size . ')</small>';
230
-                    $post_attachment .= '<br>' . newbbAttachmentImage($att['name_saved']);
231
-                    $isDisplayed     = true;
232
-                } else {
233
-                    if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) {
234
-                        $post_attachment .= '<a href="'
235
-                                            . XOOPS_URL
236
-                                            . '/modules/'
237
-                                            . $xoopsModule->getVar('dirname', 'n')
238
-                                            . '/dl_attachment.php?attachid='
239
-                                            . $key
240
-                                            . '&amp;post_id='
241
-                                            . $this->getVar('post_id')
242
-                                            . '"> <img src="'
243
-                                            . $icon_filetype
244
-                                            . '" alt="'
245
-                                            . $filetype
246
-                                            . '" /> '
247
-                                            . $att['nameDisplay']
248
-                                            . '</a> '
249
-                                            . _MD_NEWBB_FILESIZE
250
-                                            . ': '
251
-                                            . $file_size
252
-                                            . '; '
253
-                                            . _MD_NEWBB_HITS
254
-                                            . ': '
255
-                                            . $att['numDownload'];
256
-                    } elseif ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->uid() > 0
257
-                              && $GLOBALS['xoopsUser']->isactive()) {
258
-                        $post_attachment .= '<a href="'
259
-                                            . XOOPS_URL
260
-                                            . '/modules/'
261
-                                            . $xoopsModule->getVar('dirname', 'n')
262
-                                            . '/dl_attachment.php?attachid='
263
-                                            . $key
264
-                                            . '&amp;post_id='
265
-                                            . $this->getVar('post_id')
266
-                                            . '"> <img src="'
267
-                                            . $icon_filetype
268
-                                            . '" alt="'
269
-                                            . $filetype
270
-                                            . '" /> '
271
-                                            . $att['nameDisplay']
272
-                                            . '</a> '
273
-                                            . _MD_NEWBB_FILESIZE
274
-                                            . ': '
275
-                                            . $file_size
276
-                                            . '; '
277
-                                            . _MD_NEWBB_HITS
278
-                                            . ': '
279
-                                            . $att['numDownload'];
280
-                    } else {
281
-                        $post_attachment .= _MD_NEWBB_SEENOTGUEST;
282
-                    }
283
-                }
284
-                $post_attachment .= '<br>';
285
-            }
286
-        }
287
-
288
-        return $post_attachment;
289
-    }
290
-    // attachment functions
291
-    // ////////////////////////////////////////////////////////////////////////////////////
292
-
293
-    /**
294
-     * @param  string $poster_name
295
-     * @param  string $post_editmsg
296
-     * @return bool
297
-     */
298
-    public function setPostEdit($poster_name = '', $post_editmsg = '')
299
-    {
300
-        $edit_user = '';
301
-        if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])
302
-            || (time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60
303
-            || $this->getVar('approved') < 1) {
304
-            return true;
305
-        }
306
-        if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) {
307
-            if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $GLOBALS['xoopsUser']->getVar('name')) {
308
-                $edit_user = $GLOBALS['xoopsUser']->getVar('name');
309
-            } else {
310
-                $edit_user = $GLOBALS['xoopsUser']->getVar('uname');
311
-            }
312
-        }
313
-        $post_edit              = [];
314
-        $post_edit['edit_user'] = $edit_user; // (?) The proper way is to store uid instead of name.
315
-        // However, to save queries when displaying, the current way is ok.
316
-        $post_edit['edit_time'] = time();
317
-        $post_edit['edit_msg']  = $post_editmsg;
318
-
319
-        $post_edits = $this->getVar('post_edit');
320
-        if (!empty($post_edits)) {
321
-            $post_edits = unserialize(base64_decode($post_edits));
322
-        }
323
-        if (!is_array($post_edits)) {
324
-            $post_edits = [];
325
-        }
326
-        $post_edits[] = $post_edit;
327
-        $post_edit    = base64_encode(serialize($post_edits));
328
-        unset($post_edits);
329
-        $this->setVar('post_edit', $post_edit);
330
-
331
-        return true;
332
-    }
333
-
334
-    /**
335
-     * @return bool|string
336
-     */
337
-    public function displayPostEdit()
338
-    {
339
-        global $myts;
340
-
341
-        if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])) {
342
-            return false;
343
-        }
344
-
345
-        $post_edit  = '';
346
-        $post_edits = $this->getVar('post_edit');
347
-        if (!empty($post_edits)) {
348
-            $post_edits = unserialize(base64_decode($post_edits));
349
-        }
350
-        if (!isset($post_edits) || !is_array($post_edits)) {
351
-            $post_edits = [];
352
-        }
353
-        if (is_array($post_edits) && count($post_edits) > 0) {
354
-            foreach ($post_edits as $postedit) {
355
-                $edit_time = (int)$postedit['edit_time'];
356
-                $edit_user = $postedit['edit_user'];
357
-                $edit_msg  = !empty($postedit['edit_msg']) ? $postedit['edit_msg'] : '';
358
-                // Start irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
359
-                if (empty($GLOBALS['xoopsModuleConfig']['do_latestedit'])) {
360
-                    $post_edit = '';
361
-                }
362
-                // End irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
363
-                // START hacked by irmtfan
364
-                // display/save all edit records.
365
-                $post_edit .= _MD_NEWBB_EDITEDBY . ' ' . $edit_user . ' ' . _MD_NEWBB_ON . ' ' . formatTimestamp($edit_time) . '<br>';
366
-                // if reason is not empty
367
-                if ('' !== $edit_msg) {
368
-                    $post_edit .= _MD_NEWBB_EDITEDMSG . ' ' . $edit_msg . '<br>';
369
-                }
370
-                // START hacked by irmtfan
371
-            }
372
-        }
373
-
374
-        return $post_edit;
375
-    }
376
-
377
-    /**
378
-     * @return array
379
-     */
380
-    public function &getPostBody()
381
-    {
382
-        global $viewtopic_users;
383
-        $newbbConfig = newbbLoadConfig();
384
-        require_once  dirname(__DIR__) . '/include/functions.user.php';
385
-        require_once  dirname(__DIR__) . '/include/functions.render.php';
386
-
387
-        $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
388
-        /** @var KarmaHandler $karmaHandler */
389
-        $karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma');
390
-        $user_karma   = $karmaHandler->getUserKarma();
391
-
392
-        $post               = [];
393
-        $post['attachment'] = false;
394
-        $post_text          = newbbDisplayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
395
-        if (newbbIsAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
396
-            $post['text'] = $post_text . '<br>' . $this->displayAttachment();
397
-        } elseif ($newbbConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
398
-            $post['text'] = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma'));
399
-        } elseif ($newbbConfig['allow_require_reply'] && $this->getVar('require_reply')
400
-                  && (!$uid || !isset($viewtopic_users[$uid]))) {
401
-            $post['text'] = _MD_NEWBB_REPLY_REQUIREMENT;
402
-        } else {
403
-            $post['text'] = $post_text . '<br>' . $this->displayAttachment();
404
-        }
405
-        /** @var \XoopsMemberHandler $memberHandler */
406
-        $memberHandler = xoops_getHandler('member');
407
-        $eachposter    = $memberHandler->getUser($this->getVar('uid'));
408
-        if (is_object($eachposter) && $eachposter->isActive()) {
409
-            if ($newbbConfig['show_realname'] && $eachposter->getVar('name')) {
410
-                $post['author'] = $eachposter->getVar('name');
411
-            } else {
412
-                $post['author'] = $eachposter->getVar('uname');
413
-            }
414
-            unset($eachposter);
415
-        } else {
416
-            $post['author'] = $this->getVar('poster_name') ?: $GLOBALS['xoopsConfig']['anonymous'];
417
-        }
418
-
419
-        $post['subject'] = newbbHtmlspecialchars($this->vars['subject']['value']);
420
-
421
-        $post['date'] = $this->getVar('post_time');
422
-
423
-        return $post;
424
-    }
425
-
426
-    /**
427
-     * @return bool
428
-     */
429
-    public function isTopic()
430
-    {
431
-        return !$this->getVar('pid');
432
-    }
433
-
434
-    /**
435
-     * @param  string $action_tag
436
-     * @return bool
437
-     */
438
-    public function checkTimelimit($action_tag = 'edit_timelimit')
439
-    {
440
-        $newbbConfig = newbbLoadConfig();
441
-        if (empty($newbbConfig['edit_timelimit'])) {
442
-            return true;
443
-        }
444
-
445
-        return ($this->getVar('post_time') > time() - $newbbConfig[$action_tag] * 60);
446
-    }
447
-
448
-    /**
449
-     * @param  int $uid
450
-     * @return bool
451
-     */
452
-    public function checkIdentity($uid = -1)
453
-    {
454
-        $uid = ($uid > -1) ? $uid : (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0);
455
-        if ($this->getVar('uid') > 0) {
456
-            $user_ok = ($uid == $this->getVar('uid'));
457
-        } else {
458
-            static $user_ip;
459
-            if (!isset($user_ip)) {
460
-                $user_ip = \Xmf\IPAddress::fromRequest()->asReadable();
461
-            }
462
-            $user_ok = ($user_ip == $this->getVar('poster_ip'));
463
-        }
464
-
465
-        return $user_ok;
466
-    }
467
-
468
-    // TODO: cleaning up and merge with post hanldings in viewpost.php
469
-
470
-    /**
471
-     * @param $isAdmin
472
-     * @return array
473
-     */
474
-    public function showPost($isAdmin)
475
-    {
476
-        global $xoopsModule, $myts;
477
-        global $forumUrl, $forumImage, $forumObject, $online, $viewmode;
478
-        global $viewtopic_users, $viewtopic_posters, $topicObject, $user_karma;
479
-        global $order, $start, $total_posts, $topic_status;
480
-        static $post_NO = 0;
481
-        static $name_anonymous;
482
-        /** @var TopicHandler $topicHandler */
483
-        $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
484
-        if (null === $name_anonymous) {
485
-            $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
486
-        }
487
-
488
-        require_once  dirname(__DIR__) . '/include/functions.time.php';
489
-        require_once  dirname(__DIR__) . '/include/functions.render.php';
490
-
491
-        $post_id  = $this->getVar('post_id');
492
-        $topic_id = $this->getVar('topic_id');
493
-        $forum_id = $this->getVar('forum_id');
494
-
495
-        $query_vars              = ['status', 'order', 'start', 'mode', 'viewmode'];
496
-        $query_array             = [];
497
-        $query_array['topic_id'] = "topic_id={$topic_id}";
498
-        foreach ($query_vars as $var) {
499
-            if (Request::getString($var, '', 'GET')) {
500
-                $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
501
-            }
502
-        }
503
-        $page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
504
-
505
-        $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
506
-
507
-        ++$post_NO;
508
-        if ('desc' === strtolower($order)) {
509
-            $post_no = $total_posts - ($start + $post_NO) + 1;
510
-        } else {
511
-            $post_no = $start + $post_NO;
512
-        }
513
-
514
-        if ($isAdmin || $this->checkIdentity()) {
515
-            $post_text       = $this->getVar('post_text');
516
-            $post_attachment = $this->displayAttachment();
517
-        } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
518
-            $post_text       = "<div class='karma'>" . sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '</div>';
519
-            $post_attachment = '';
520
-        } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply')
521
-                  && (!$uid || !in_array($uid, $viewtopic_posters))) {
522
-            $post_text       = "<div class='karma'>" . _MD_NEWBB_REPLY_REQUIREMENT . '</div>';
523
-            $post_attachment = '';
524
-        } else {
525
-            $post_text       = $this->getVar('post_text');
526
-            $post_attachment = $this->displayAttachment();
527
-        }
528
-
529
-        // Hightlight search words
530
-        $post_title = $this->getVar('subject');
531
-        if ($keywords = Request::getString('keywords', '', 'GET')) {
532
-            //$keywords   = $myts->htmlSpecialChars(trim(urldecode(Request::getString('keywords', '', 'GET'))));
533
-            $post_text  = Highlighter::apply($keywords, $post_text, '<mark>', '</mark>');
534
-            $post_title = Highlighter::apply($keywords, $post_title, '<mark>', '</mark>');
535
-        }
536
-
537
-        if (isset($viewtopic_users[$this->getVar('uid')])) {
538
-            $poster = $viewtopic_users[$this->getVar('uid')];
539
-        } else {
540
-            $name   = ($post_name = $this->getVar('poster_name')) ? $post_name : $name_anonymous;
541
-            $poster = [
542
-                'poster_uid' => 0,
543
-                'name'       => $name,
544
-                'link'       => $name
545
-            ];
546
-        }
547
-
548
-        if ($posticon = $this->getVar('icon')) {
549
-            $post_image = '<a name="' . $post_id . '"><img src="' . XOOPS_URL . '/images/subject/' . $posticon . '" alt="" /></a>';
550
-        } else {
551
-            $post_image = '<a name="' . $post_id . '"><img src="' . XOOPS_URL . '/images/icons/posticon.gif" alt="" /></a>';
552
-        }
553
-
554
-        $thread_buttons = [];
555
-        $mod_buttons    = [];
556
-
557
-        if ($isAdmin && ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->getVar('uid') !== $this->getVar('uid'))
558
-            && $this->getVar('uid') > 0) {
559
-            $mod_buttons['bann']['image']    = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT);
560
-            $mod_buttons['bann']['link']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&amp;uid=' . $this->getVar('uid');
561
-            $mod_buttons['bann']['name']     = _MD_NEWBB_SUSPEND_MANAGEMENT;
562
-            $thread_buttons['bann']['image'] = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT);
563
-            $thread_buttons['bann']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&amp;uid=' . $this->getVar('uid');
564
-            $thread_buttons['bann']['name']  = _MD_NEWBB_SUSPEND_MANAGEMENT;
565
-        }
566
-
567
-        if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) {
568
-            //            /** @var TopicHandler $topicHandler */
569
-            //            $topicHandler =  Newbb\Helper::getInstance()->getHandler('Topic');
570
-            $topic_status = $topicObject->getVar('topic_status');
571
-            if ($topicHandler->getPermission($forum_id, $topic_status, 'edit')) {
572
-                $edit_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit')));
573
-
574
-                if ($edit_ok) {
575
-                    $thread_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
576
-                    $thread_buttons['edit']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
577
-                    $thread_buttons['edit']['name']  = _EDIT;
578
-                    $mod_buttons['edit']['image']    = newbbDisplayImage('p_edit', _EDIT);
579
-                    $mod_buttons['edit']['link']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
580
-                    $mod_buttons['edit']['name']     = _EDIT;
581
-                }
582
-            }
583
-
584
-            if ($topicHandler->getPermission($forum_id, $topic_status, 'delete')) {
585
-                $delete_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit')));
586
-
587
-                if ($delete_ok) {
588
-                    $thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
589
-                    $thread_buttons['delete']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
590
-                    $thread_buttons['delete']['name']  = _DELETE;
591
-                    $mod_buttons['delete']['image']    = newbbDisplayImage('p_delete', _DELETE);
592
-                    $mod_buttons['delete']['link']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
593
-                    $mod_buttons['delete']['name']     = _DELETE;
594
-                }
595
-            }
596
-            if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) {
597
-                $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
598
-                $thread_buttons['reply']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}";
599
-                $thread_buttons['reply']['name']  = _MD_NEWBB_REPLY;
600
-
601
-                $thread_buttons['quote']['image'] = newbbDisplayImage('p_quote', _MD_NEWBB_QUOTE);
602
-                $thread_buttons['quote']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}&amp;quotedac=1";
603
-                $thread_buttons['quote']['name']  = _MD_NEWBB_QUOTE;
604
-            }
605
-        } else {
606
-            $mod_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
607
-            $mod_buttons['edit']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
608
-            $mod_buttons['edit']['name']  = _EDIT;
609
-
610
-            $mod_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
611
-            $mod_buttons['delete']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
612
-            $mod_buttons['delete']['name']  = _DELETE;
613
-
614
-            $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
615
-            $thread_buttons['reply']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}";
616
-            $thread_buttons['reply']['name']  = _MD_NEWBB_REPLY;
617
-        }
618
-
619
-        if (!$isAdmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) {
620
-            $thread_buttons['report']['image'] = newbbDisplayImage('p_report', _MD_NEWBB_REPORT);
621
-            $thread_buttons['report']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/report.php?{$page_query}";
622
-            $thread_buttons['report']['name']  = _MD_NEWBB_REPORT;
623
-        }
624
-
625
-        $thread_action = [];
626
-        // irmtfan add pdf permission
627
-        if (file_exists(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php')
628
-            && $topicHandler->getPermission($forum_id, $topic_status, 'pdf')) {
629
-            $thread_action['pdf']['image']  = newbbDisplayImage('pdf', _MD_NEWBB_PDF);
630
-            $thread_action['pdf']['link']   = XOOPS_URL . '/modules/newbb/makepdf.php?type=post&amp;pageid=0';
631
-            $thread_action['pdf']['name']   = _MD_NEWBB_PDF;
632
-            $thread_action['pdf']['target'] = '_blank';
633
-        }
634
-        // irmtfan add print permission
635
-        if ($topicHandler->getPermission($forum_id, $topic_status, 'print')) {
636
-            $thread_action['print']['image']  = newbbDisplayImage('printer', _MD_NEWBB_PRINT);
637
-            $thread_action['print']['link']   = XOOPS_URL . '/modules/newbb/print.php?form=2&amp;forum=' . $forum_id . '&amp;topic_id=' . $topic_id;
638
-            $thread_action['print']['name']   = _MD_NEWBB_PRINT;
639
-            $thread_action['print']['target'] = '_blank';
640
-        }
641
-
642
-        if ($GLOBALS['xoopsModuleConfig']['show_sociallinks']) {
643
-            $full_title  = $this->getVar('subject');
644
-            $clean_title = preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject'));
645
-            $full_link   = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id;
646
-
647
-            $thread_action['social_twitter']['image']  = newbbDisplayImage('twitter', _MD_NEWBB_SHARE_TWITTER);
648
-            $thread_action['social_twitter']['link']   = 'http://twitter.com/share?text=' . $clean_title . '&amp;url=' . $full_link;
649
-            $thread_action['social_twitter']['name']   = _MD_NEWBB_SHARE_TWITTER;
650
-            $thread_action['social_twitter']['target'] = '_blank';
651
-
652
-            $thread_action['social_facebook']['image']  = newbbDisplayImage('facebook', _MD_NEWBB_SHARE_FACEBOOK);
653
-            $thread_action['social_facebook']['link']   = 'http://www.facebook.com/sharer.php?u=' . $full_link;
654
-            $thread_action['social_facebook']['name']   = _MD_NEWBB_SHARE_FACEBOOK;
655
-            $thread_action['social_facebook']['target'] = '_blank';
656
-
657
-            $thread_action['social_gplus']['image']  = newbbDisplayImage('googleplus', _MD_NEWBB_SHARE_GOOGLEPLUS);
658
-            $thread_action['social_gplus']['link']   = 'https://plusone.google.com/_/+1/confirm?hl=en&url=' . $full_link;
659
-            $thread_action['social_gplus']['name']   = _MD_NEWBB_SHARE_GOOGLEPLUS;
660
-            $thread_action['social_gplus']['target'] = '_blank';
661
-
662
-            $thread_action['social_linkedin']['image']  = newbbDisplayImage('linkedin', _MD_NEWBB_SHARE_LINKEDIN);
663
-            $thread_action['social_linkedin']['link']   = 'http://www.linkedin.com/shareArticle?mini=true&amp;title=' . $full_title . '&amp;url=' . $full_link;
664
-            $thread_action['social_linkedin']['name']   = _MD_NEWBB_SHARE_LINKEDIN;
665
-            $thread_action['social_linkedin']['target'] = '_blank';
666
-
667
-            $thread_action['social_delicious']['image']  = newbbDisplayImage('delicious', _MD_NEWBB_SHARE_DELICIOUS);
668
-            $thread_action['social_delicious']['link']   = 'http://del.icio.us/post?title=' . $full_title . '&amp;url=' . $full_link;
669
-            $thread_action['social_delicious']['name']   = _MD_NEWBB_SHARE_DELICIOUS;
670
-            $thread_action['social_delicious']['target'] = '_blank';
671
-
672
-            $thread_action['social_digg']['image']  = newbbDisplayImage('digg', _MD_NEWBB_SHARE_DIGG);
673
-            $thread_action['social_digg']['link']   = 'http://digg.com/submit?phase=2&amp;title=' . $full_title . '&amp;url=' . $full_link;
674
-            $thread_action['social_digg']['name']   = _MD_NEWBB_SHARE_DIGG;
675
-            $thread_action['social_digg']['target'] = '_blank';
676
-
677
-            $thread_action['social_reddit']['image']  = newbbDisplayImage('reddit', _MD_NEWBB_SHARE_REDDIT);
678
-            $thread_action['social_reddit']['link']   = 'http://reddit.com/submit?title=' . $full_title . '&amp;url=' . $full_link;
679
-            $thread_action['social_reddit']['name']   = _MD_NEWBB_SHARE_REDDIT;
680
-            $thread_action['social_reddit']['target'] = '_blank';
681
-
682
-            $thread_action['social_wong']['image']  = newbbDisplayImage('wong', _MD_NEWBB_SHARE_MRWONG);
683
-            $thread_action['social_wong']['link']   = 'http://www.mister-wong.de/index.php?action=addurl&bm_url=' . $full_link;
684
-            $thread_action['social_wong']['name']   = _MD_NEWBB_SHARE_MRWONG;
685
-            $thread_action['social_wong']['target'] = '_blank';
686
-        }
687
-
688
-        $post = [
689
-            'post_id'         => $post_id,
690
-            'post_parent_id'  => $this->getVar('pid'),
691
-            'post_date'       => newbbFormatTimestamp($this->getVar('post_time')),
692
-            'post_image'      => $post_image,
693
-            'post_title'      => $post_title,
694
-            // irmtfan $post_title to add highlight keywords
695
-            'post_text'       => $post_text,
696
-            'post_attachment' => $post_attachment,
697
-            'post_edit'       => $this->displayPostEdit(),
698
-            'post_no'         => $post_no,
699
-            'post_signature'  => $this->getVar('attachsig') ? @$poster['signature'] : '',
700
-            //            'poster_ip'       => ($isAdmin && $GLOBALS['xoopsModuleConfig']['show_ip']) ? long2ip($this->getVar('poster_ip')) : '',
701
-            'poster_ip'       => ($isAdmin
702
-                                  && $GLOBALS['xoopsModuleConfig']['show_ip']) ? $this->getVar('poster_ip') : '',
703
-            'thread_action'   => $thread_action,
704
-            'thread_buttons'  => $thread_buttons,
705
-            'mod_buttons'     => $mod_buttons,
706
-            'poster'          => $poster,
707
-            'post_permalink'  => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $post_id . '"></a>'
708
-        ];
709
-
710
-        unset($thread_buttons, $mod_buttons, $eachposter);
711
-
712
-        return $post;
713
-    }
46
+	//class Post extends \XoopsObject {
47
+	private $attachmentArray = [];
48
+
49
+	/**
50
+	 *
51
+	 */
52
+	public function __construct()
53
+	{
54
+		parent::__construct();
55
+
56
+		$this->initVar('post_id', XOBJ_DTYPE_INT);
57
+		$this->initVar('topic_id', XOBJ_DTYPE_INT, 0, true);
58
+		$this->initVar('forum_id', XOBJ_DTYPE_INT, 0, true);
59
+		$this->initVar('post_time', XOBJ_DTYPE_INT, 0, true);
60
+		//        $this->initVar('poster_ip', XOBJ_DTYPE_INT, 0);
61
+		$this->initVar('poster_ip', XOBJ_DTYPE_TXTBOX, '');
62
+		$this->initVar('poster_name', XOBJ_DTYPE_TXTBOX, '');
63
+		$this->initVar('subject', XOBJ_DTYPE_TXTBOX, '', true);
64
+		$this->initVar('pid', XOBJ_DTYPE_INT, 0);
65
+		$this->initVar('dohtml', XOBJ_DTYPE_INT, 0);
66
+		$this->initVar('dosmiley', XOBJ_DTYPE_INT, 1);
67
+		$this->initVar('doxcode', XOBJ_DTYPE_INT, 1);
68
+		$this->initVar('doimage', XOBJ_DTYPE_INT, 1);
69
+		$this->initVar('dobr', XOBJ_DTYPE_INT, 1);
70
+		$this->initVar('uid', XOBJ_DTYPE_INT, 1);
71
+		$this->initVar('icon', XOBJ_DTYPE_TXTBOX, '');
72
+		$this->initVar('attachsig', XOBJ_DTYPE_INT, 0);
73
+		$this->initVar('approved', XOBJ_DTYPE_INT, 1);
74
+		$this->initVar('post_karma', XOBJ_DTYPE_INT, 0);
75
+		$this->initVar('require_reply', XOBJ_DTYPE_INT, 0);
76
+		$this->initVar('attachment', XOBJ_DTYPE_TXTAREA, '');
77
+		$this->initVar('post_text', XOBJ_DTYPE_TXTAREA, '');
78
+		$this->initVar('post_edit', XOBJ_DTYPE_TXTAREA, '');
79
+	}
80
+
81
+	// ////////////////////////////////////////////////////////////////////////////////////
82
+	// attachment functions    TODO: there should be a file/attachment management class
83
+	/**
84
+	 * @return array|mixed|null
85
+	 */
86
+	public function getAttachment()
87
+	{
88
+		if (count($this->attachmentArray)) {
89
+			return $this->attachmentArray;
90
+		}
91
+		$attachment = $this->getVar('attachment');
92
+		if (empty($attachment)) {
93
+			$this->attachmentArray = [];
94
+		} else {
95
+			$this->attachmentArray = @unserialize(base64_decode($attachment));
96
+		}
97
+
98
+		return $this->attachmentArray;
99
+	}
100
+
101
+	/**
102
+	 * @param $attachKey
103
+	 * @return bool
104
+	 */
105
+	public function incrementDownload($attachKey)
106
+	{
107
+		if (!$attachKey) {
108
+			return false;
109
+		}
110
+		$this->attachmentArray[(string)$attachKey]['numDownload']++;
111
+
112
+		return $this->attachmentArray[(string)$attachKey]['numDownload'];
113
+	}
114
+
115
+	/**
116
+	 * @return bool
117
+	 */
118
+	public function saveAttachment()
119
+	{
120
+		$attachmentSave = '';
121
+		if (is_array($this->attachmentArray) && count($this->attachmentArray) > 0) {
122
+			$attachmentSave = base64_encode(serialize($this->attachmentArray));
123
+		}
124
+		$this->setVar('attachment', $attachmentSave);
125
+		$sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' SET attachment=' . $GLOBALS['xoopsDB']->quoteString($attachmentSave) . ' WHERE post_id = ' . $this->getVar('post_id');
126
+		if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
127
+			//xoops_error($GLOBALS['xoopsDB']->error());
128
+			return false;
129
+		}
130
+
131
+		return true;
132
+	}
133
+
134
+	/**
135
+	 * @param  array|null $attachArray
136
+	 * @return bool
137
+	 */
138
+	public function deleteAttachment($attachArray = null)
139
+	{
140
+		$attachOld = $this->getAttachment();
141
+		if (!is_array($attachOld) || count($attachOld) < 1) {
142
+			return true;
143
+		}
144
+		$this->attachmentArray = [];
145
+
146
+		if (null === $attachArray) {
147
+			$attachArray = array_keys($attachOld);
148
+		} // to delete all!
149
+		if (!is_array($attachArray)) {
150
+			$attachArray = [$attachArray];
151
+		}
152
+
153
+		foreach ($attachOld as $key => $attach) {
154
+			if (in_array($key, $attachArray)) {
155
+				@unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']));
156
+				@unlink($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved'])); // delete thumbnails
157
+				continue;
158
+			}
159
+			$this->attachmentArray[$key] = $attach;
160
+		}
161
+		$attachmentSave = '';
162
+		if (is_array($this->attachmentArray) && count($this->attachmentArray) > 0) {
163
+			$attachmentSave = base64_encode(serialize($this->attachmentArray));
164
+		}
165
+		$this->setVar('attachment', $attachmentSave);
166
+
167
+		return true;
168
+	}
169
+
170
+	/**
171
+	 * @param  string $name_saved
172
+	 * @param  string $nameDisplay
173
+	 * @param  string $mimetype
174
+	 * @param  int    $numDownload
175
+	 * @return bool
176
+	 */
177
+	public function setAttachment($name_saved = '', $nameDisplay = '', $mimetype = '', $numDownload = 0)
178
+	{
179
+		static $counter = 0;
180
+		$this->attachmentArray = $this->getAttachment();
181
+		if ($name_saved) {
182
+			$key                         = (string)(time() + $counter++);
183
+			$this->attachmentArray[$key] = [
184
+				'name_saved'  => $name_saved,
185
+				'nameDisplay' => empty($nameDisplay) ? $nameDisplay : $name_saved,
186
+				'mimetype'    => $mimetype,
187
+				'numDownload' => empty($numDownload) ? (int)$numDownload : 0
188
+			];
189
+		}
190
+		$attachmentSave = null;
191
+		if (is_array($this->attachmentArray)) {
192
+			$attachmentSave = base64_encode(serialize($this->attachmentArray));
193
+		}
194
+		$this->setVar('attachment', $attachmentSave);
195
+
196
+		return true;
197
+	}
198
+
199
+	/**
200
+	 * TODO: refactor
201
+	 * @param  bool $asSource
202
+	 * @return string
203
+	 */
204
+	public function displayAttachment($asSource = false)
205
+	{
206
+		global $xoopsModule;
207
+
208
+		$post_attachment = '';
209
+		$attachments     = $this->getAttachment();
210
+		if (is_array($attachments) && count($attachments) > 0) {
211
+			$iconHandler = newbbGetIconHandler();
212
+			$mime_path   = $iconHandler->getPath('mime');
213
+			require_once dirname(__DIR__) . '/include/functions.image.php';
214
+			$image_extensions = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; // need improve !!!
215
+			$post_attachment  .= '<br><strong>' . _MD_NEWBB_ATTACHMENT . '</strong>:';
216
+			$post_attachment  .= '<br><hr size="1" noshade="noshade" /><br>';
217
+			foreach ($attachments as $key => $att) {
218
+				$file_extension = ltrim(strrchr($att['name_saved'], '.'), '.');
219
+				$filetype       = $file_extension;
220
+				if (file_exists($GLOBALS['xoops']->path($mime_path . '/' . $filetype . '.gif'))) {
221
+					$icon_filetype = XOOPS_URL . '/' . $mime_path . '/' . $filetype . '.gif';
222
+				} else {
223
+					$icon_filetype = XOOPS_URL . '/' . $mime_path . '/unknown.gif';
224
+				}
225
+				$file_size = @filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved']));
226
+				$file_size = number_format($file_size / 1024, 2) . ' KB';
227
+				if (in_array(strtolower($file_extension), $image_extensions)
228
+					&& $GLOBALS['xoopsModuleConfig']['media_allowed']) {
229
+					$post_attachment .= '<br><img src="' . $icon_filetype . '" alt="' . $filetype . '" /><strong>&nbsp; ' . $att['nameDisplay'] . '</strong> <small>(' . $file_size . ')</small>';
230
+					$post_attachment .= '<br>' . newbbAttachmentImage($att['name_saved']);
231
+					$isDisplayed     = true;
232
+				} else {
233
+					if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) {
234
+						$post_attachment .= '<a href="'
235
+											. XOOPS_URL
236
+											. '/modules/'
237
+											. $xoopsModule->getVar('dirname', 'n')
238
+											. '/dl_attachment.php?attachid='
239
+											. $key
240
+											. '&amp;post_id='
241
+											. $this->getVar('post_id')
242
+											. '"> <img src="'
243
+											. $icon_filetype
244
+											. '" alt="'
245
+											. $filetype
246
+											. '" /> '
247
+											. $att['nameDisplay']
248
+											. '</a> '
249
+											. _MD_NEWBB_FILESIZE
250
+											. ': '
251
+											. $file_size
252
+											. '; '
253
+											. _MD_NEWBB_HITS
254
+											. ': '
255
+											. $att['numDownload'];
256
+					} elseif ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->uid() > 0
257
+							  && $GLOBALS['xoopsUser']->isactive()) {
258
+						$post_attachment .= '<a href="'
259
+											. XOOPS_URL
260
+											. '/modules/'
261
+											. $xoopsModule->getVar('dirname', 'n')
262
+											. '/dl_attachment.php?attachid='
263
+											. $key
264
+											. '&amp;post_id='
265
+											. $this->getVar('post_id')
266
+											. '"> <img src="'
267
+											. $icon_filetype
268
+											. '" alt="'
269
+											. $filetype
270
+											. '" /> '
271
+											. $att['nameDisplay']
272
+											. '</a> '
273
+											. _MD_NEWBB_FILESIZE
274
+											. ': '
275
+											. $file_size
276
+											. '; '
277
+											. _MD_NEWBB_HITS
278
+											. ': '
279
+											. $att['numDownload'];
280
+					} else {
281
+						$post_attachment .= _MD_NEWBB_SEENOTGUEST;
282
+					}
283
+				}
284
+				$post_attachment .= '<br>';
285
+			}
286
+		}
287
+
288
+		return $post_attachment;
289
+	}
290
+	// attachment functions
291
+	// ////////////////////////////////////////////////////////////////////////////////////
292
+
293
+	/**
294
+	 * @param  string $poster_name
295
+	 * @param  string $post_editmsg
296
+	 * @return bool
297
+	 */
298
+	public function setPostEdit($poster_name = '', $post_editmsg = '')
299
+	{
300
+		$edit_user = '';
301
+		if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])
302
+			|| (time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60
303
+			|| $this->getVar('approved') < 1) {
304
+			return true;
305
+		}
306
+		if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) {
307
+			if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $GLOBALS['xoopsUser']->getVar('name')) {
308
+				$edit_user = $GLOBALS['xoopsUser']->getVar('name');
309
+			} else {
310
+				$edit_user = $GLOBALS['xoopsUser']->getVar('uname');
311
+			}
312
+		}
313
+		$post_edit              = [];
314
+		$post_edit['edit_user'] = $edit_user; // (?) The proper way is to store uid instead of name.
315
+		// However, to save queries when displaying, the current way is ok.
316
+		$post_edit['edit_time'] = time();
317
+		$post_edit['edit_msg']  = $post_editmsg;
318
+
319
+		$post_edits = $this->getVar('post_edit');
320
+		if (!empty($post_edits)) {
321
+			$post_edits = unserialize(base64_decode($post_edits));
322
+		}
323
+		if (!is_array($post_edits)) {
324
+			$post_edits = [];
325
+		}
326
+		$post_edits[] = $post_edit;
327
+		$post_edit    = base64_encode(serialize($post_edits));
328
+		unset($post_edits);
329
+		$this->setVar('post_edit', $post_edit);
330
+
331
+		return true;
332
+	}
333
+
334
+	/**
335
+	 * @return bool|string
336
+	 */
337
+	public function displayPostEdit()
338
+	{
339
+		global $myts;
340
+
341
+		if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])) {
342
+			return false;
343
+		}
344
+
345
+		$post_edit  = '';
346
+		$post_edits = $this->getVar('post_edit');
347
+		if (!empty($post_edits)) {
348
+			$post_edits = unserialize(base64_decode($post_edits));
349
+		}
350
+		if (!isset($post_edits) || !is_array($post_edits)) {
351
+			$post_edits = [];
352
+		}
353
+		if (is_array($post_edits) && count($post_edits) > 0) {
354
+			foreach ($post_edits as $postedit) {
355
+				$edit_time = (int)$postedit['edit_time'];
356
+				$edit_user = $postedit['edit_user'];
357
+				$edit_msg  = !empty($postedit['edit_msg']) ? $postedit['edit_msg'] : '';
358
+				// Start irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
359
+				if (empty($GLOBALS['xoopsModuleConfig']['do_latestedit'])) {
360
+					$post_edit = '';
361
+				}
362
+				// End irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
363
+				// START hacked by irmtfan
364
+				// display/save all edit records.
365
+				$post_edit .= _MD_NEWBB_EDITEDBY . ' ' . $edit_user . ' ' . _MD_NEWBB_ON . ' ' . formatTimestamp($edit_time) . '<br>';
366
+				// if reason is not empty
367
+				if ('' !== $edit_msg) {
368
+					$post_edit .= _MD_NEWBB_EDITEDMSG . ' ' . $edit_msg . '<br>';
369
+				}
370
+				// START hacked by irmtfan
371
+			}
372
+		}
373
+
374
+		return $post_edit;
375
+	}
376
+
377
+	/**
378
+	 * @return array
379
+	 */
380
+	public function &getPostBody()
381
+	{
382
+		global $viewtopic_users;
383
+		$newbbConfig = newbbLoadConfig();
384
+		require_once  dirname(__DIR__) . '/include/functions.user.php';
385
+		require_once  dirname(__DIR__) . '/include/functions.render.php';
386
+
387
+		$uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
388
+		/** @var KarmaHandler $karmaHandler */
389
+		$karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma');
390
+		$user_karma   = $karmaHandler->getUserKarma();
391
+
392
+		$post               = [];
393
+		$post['attachment'] = false;
394
+		$post_text          = newbbDisplayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
395
+		if (newbbIsAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
396
+			$post['text'] = $post_text . '<br>' . $this->displayAttachment();
397
+		} elseif ($newbbConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
398
+			$post['text'] = sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma'));
399
+		} elseif ($newbbConfig['allow_require_reply'] && $this->getVar('require_reply')
400
+				  && (!$uid || !isset($viewtopic_users[$uid]))) {
401
+			$post['text'] = _MD_NEWBB_REPLY_REQUIREMENT;
402
+		} else {
403
+			$post['text'] = $post_text . '<br>' . $this->displayAttachment();
404
+		}
405
+		/** @var \XoopsMemberHandler $memberHandler */
406
+		$memberHandler = xoops_getHandler('member');
407
+		$eachposter    = $memberHandler->getUser($this->getVar('uid'));
408
+		if (is_object($eachposter) && $eachposter->isActive()) {
409
+			if ($newbbConfig['show_realname'] && $eachposter->getVar('name')) {
410
+				$post['author'] = $eachposter->getVar('name');
411
+			} else {
412
+				$post['author'] = $eachposter->getVar('uname');
413
+			}
414
+			unset($eachposter);
415
+		} else {
416
+			$post['author'] = $this->getVar('poster_name') ?: $GLOBALS['xoopsConfig']['anonymous'];
417
+		}
418
+
419
+		$post['subject'] = newbbHtmlspecialchars($this->vars['subject']['value']);
420
+
421
+		$post['date'] = $this->getVar('post_time');
422
+
423
+		return $post;
424
+	}
425
+
426
+	/**
427
+	 * @return bool
428
+	 */
429
+	public function isTopic()
430
+	{
431
+		return !$this->getVar('pid');
432
+	}
433
+
434
+	/**
435
+	 * @param  string $action_tag
436
+	 * @return bool
437
+	 */
438
+	public function checkTimelimit($action_tag = 'edit_timelimit')
439
+	{
440
+		$newbbConfig = newbbLoadConfig();
441
+		if (empty($newbbConfig['edit_timelimit'])) {
442
+			return true;
443
+		}
444
+
445
+		return ($this->getVar('post_time') > time() - $newbbConfig[$action_tag] * 60);
446
+	}
447
+
448
+	/**
449
+	 * @param  int $uid
450
+	 * @return bool
451
+	 */
452
+	public function checkIdentity($uid = -1)
453
+	{
454
+		$uid = ($uid > -1) ? $uid : (is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0);
455
+		if ($this->getVar('uid') > 0) {
456
+			$user_ok = ($uid == $this->getVar('uid'));
457
+		} else {
458
+			static $user_ip;
459
+			if (!isset($user_ip)) {
460
+				$user_ip = \Xmf\IPAddress::fromRequest()->asReadable();
461
+			}
462
+			$user_ok = ($user_ip == $this->getVar('poster_ip'));
463
+		}
464
+
465
+		return $user_ok;
466
+	}
467
+
468
+	// TODO: cleaning up and merge with post hanldings in viewpost.php
469
+
470
+	/**
471
+	 * @param $isAdmin
472
+	 * @return array
473
+	 */
474
+	public function showPost($isAdmin)
475
+	{
476
+		global $xoopsModule, $myts;
477
+		global $forumUrl, $forumImage, $forumObject, $online, $viewmode;
478
+		global $viewtopic_users, $viewtopic_posters, $topicObject, $user_karma;
479
+		global $order, $start, $total_posts, $topic_status;
480
+		static $post_NO = 0;
481
+		static $name_anonymous;
482
+		/** @var TopicHandler $topicHandler */
483
+		$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
484
+		if (null === $name_anonymous) {
485
+			$name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
486
+		}
487
+
488
+		require_once  dirname(__DIR__) . '/include/functions.time.php';
489
+		require_once  dirname(__DIR__) . '/include/functions.render.php';
490
+
491
+		$post_id  = $this->getVar('post_id');
492
+		$topic_id = $this->getVar('topic_id');
493
+		$forum_id = $this->getVar('forum_id');
494
+
495
+		$query_vars              = ['status', 'order', 'start', 'mode', 'viewmode'];
496
+		$query_array             = [];
497
+		$query_array['topic_id'] = "topic_id={$topic_id}";
498
+		foreach ($query_vars as $var) {
499
+			if (Request::getString($var, '', 'GET')) {
500
+				$query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET');
501
+			}
502
+		}
503
+		$page_query = htmlspecialchars(implode('&', array_values($query_array)), ENT_QUOTES | ENT_HTML5);
504
+
505
+		$uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
506
+
507
+		++$post_NO;
508
+		if ('desc' === strtolower($order)) {
509
+			$post_no = $total_posts - ($start + $post_NO) + 1;
510
+		} else {
511
+			$post_no = $start + $post_NO;
512
+		}
513
+
514
+		if ($isAdmin || $this->checkIdentity()) {
515
+			$post_text       = $this->getVar('post_text');
516
+			$post_attachment = $this->displayAttachment();
517
+		} elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
518
+			$post_text       = "<div class='karma'>" . sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '</div>';
519
+			$post_attachment = '';
520
+		} elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply')
521
+				  && (!$uid || !in_array($uid, $viewtopic_posters))) {
522
+			$post_text       = "<div class='karma'>" . _MD_NEWBB_REPLY_REQUIREMENT . '</div>';
523
+			$post_attachment = '';
524
+		} else {
525
+			$post_text       = $this->getVar('post_text');
526
+			$post_attachment = $this->displayAttachment();
527
+		}
528
+
529
+		// Hightlight search words
530
+		$post_title = $this->getVar('subject');
531
+		if ($keywords = Request::getString('keywords', '', 'GET')) {
532
+			//$keywords   = $myts->htmlSpecialChars(trim(urldecode(Request::getString('keywords', '', 'GET'))));
533
+			$post_text  = Highlighter::apply($keywords, $post_text, '<mark>', '</mark>');
534
+			$post_title = Highlighter::apply($keywords, $post_title, '<mark>', '</mark>');
535
+		}
536
+
537
+		if (isset($viewtopic_users[$this->getVar('uid')])) {
538
+			$poster = $viewtopic_users[$this->getVar('uid')];
539
+		} else {
540
+			$name   = ($post_name = $this->getVar('poster_name')) ? $post_name : $name_anonymous;
541
+			$poster = [
542
+				'poster_uid' => 0,
543
+				'name'       => $name,
544
+				'link'       => $name
545
+			];
546
+		}
547
+
548
+		if ($posticon = $this->getVar('icon')) {
549
+			$post_image = '<a name="' . $post_id . '"><img src="' . XOOPS_URL . '/images/subject/' . $posticon . '" alt="" /></a>';
550
+		} else {
551
+			$post_image = '<a name="' . $post_id . '"><img src="' . XOOPS_URL . '/images/icons/posticon.gif" alt="" /></a>';
552
+		}
553
+
554
+		$thread_buttons = [];
555
+		$mod_buttons    = [];
556
+
557
+		if ($isAdmin && ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->getVar('uid') !== $this->getVar('uid'))
558
+			&& $this->getVar('uid') > 0) {
559
+			$mod_buttons['bann']['image']    = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT);
560
+			$mod_buttons['bann']['link']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&amp;uid=' . $this->getVar('uid');
561
+			$mod_buttons['bann']['name']     = _MD_NEWBB_SUSPEND_MANAGEMENT;
562
+			$thread_buttons['bann']['image'] = newbbDisplayImage('p_bann', _MD_NEWBB_SUSPEND_MANAGEMENT);
563
+			$thread_buttons['bann']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/moderate.php?forum=' . $forum_id . '&amp;uid=' . $this->getVar('uid');
564
+			$thread_buttons['bann']['name']  = _MD_NEWBB_SUSPEND_MANAGEMENT;
565
+		}
566
+
567
+		if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) {
568
+			//            /** @var TopicHandler $topicHandler */
569
+			//            $topicHandler =  Newbb\Helper::getInstance()->getHandler('Topic');
570
+			$topic_status = $topicObject->getVar('topic_status');
571
+			if ($topicHandler->getPermission($forum_id, $topic_status, 'edit')) {
572
+				$edit_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit')));
573
+
574
+				if ($edit_ok) {
575
+					$thread_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
576
+					$thread_buttons['edit']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
577
+					$thread_buttons['edit']['name']  = _EDIT;
578
+					$mod_buttons['edit']['image']    = newbbDisplayImage('p_edit', _EDIT);
579
+					$mod_buttons['edit']['link']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
580
+					$mod_buttons['edit']['name']     = _EDIT;
581
+				}
582
+			}
583
+
584
+			if ($topicHandler->getPermission($forum_id, $topic_status, 'delete')) {
585
+				$delete_ok = ($isAdmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit')));
586
+
587
+				if ($delete_ok) {
588
+					$thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
589
+					$thread_buttons['delete']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
590
+					$thread_buttons['delete']['name']  = _DELETE;
591
+					$mod_buttons['delete']['image']    = newbbDisplayImage('p_delete', _DELETE);
592
+					$mod_buttons['delete']['link']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
593
+					$mod_buttons['delete']['name']     = _DELETE;
594
+				}
595
+			}
596
+			if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) {
597
+				$thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
598
+				$thread_buttons['reply']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}";
599
+				$thread_buttons['reply']['name']  = _MD_NEWBB_REPLY;
600
+
601
+				$thread_buttons['quote']['image'] = newbbDisplayImage('p_quote', _MD_NEWBB_QUOTE);
602
+				$thread_buttons['quote']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}&amp;quotedac=1";
603
+				$thread_buttons['quote']['name']  = _MD_NEWBB_QUOTE;
604
+			}
605
+		} else {
606
+			$mod_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
607
+			$mod_buttons['edit']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/edit.php?{$page_query}";
608
+			$mod_buttons['edit']['name']  = _EDIT;
609
+
610
+			$mod_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
611
+			$mod_buttons['delete']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/delete.php?{$page_query}";
612
+			$mod_buttons['delete']['name']  = _DELETE;
613
+
614
+			$thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
615
+			$thread_buttons['reply']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/reply.php?{$page_query}";
616
+			$thread_buttons['reply']['name']  = _MD_NEWBB_REPLY;
617
+		}
618
+
619
+		if (!$isAdmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) {
620
+			$thread_buttons['report']['image'] = newbbDisplayImage('p_report', _MD_NEWBB_REPORT);
621
+			$thread_buttons['report']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/report.php?{$page_query}";
622
+			$thread_buttons['report']['name']  = _MD_NEWBB_REPORT;
623
+		}
624
+
625
+		$thread_action = [];
626
+		// irmtfan add pdf permission
627
+		if (file_exists(XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php')
628
+			&& $topicHandler->getPermission($forum_id, $topic_status, 'pdf')) {
629
+			$thread_action['pdf']['image']  = newbbDisplayImage('pdf', _MD_NEWBB_PDF);
630
+			$thread_action['pdf']['link']   = XOOPS_URL . '/modules/newbb/makepdf.php?type=post&amp;pageid=0';
631
+			$thread_action['pdf']['name']   = _MD_NEWBB_PDF;
632
+			$thread_action['pdf']['target'] = '_blank';
633
+		}
634
+		// irmtfan add print permission
635
+		if ($topicHandler->getPermission($forum_id, $topic_status, 'print')) {
636
+			$thread_action['print']['image']  = newbbDisplayImage('printer', _MD_NEWBB_PRINT);
637
+			$thread_action['print']['link']   = XOOPS_URL . '/modules/newbb/print.php?form=2&amp;forum=' . $forum_id . '&amp;topic_id=' . $topic_id;
638
+			$thread_action['print']['name']   = _MD_NEWBB_PRINT;
639
+			$thread_action['print']['target'] = '_blank';
640
+		}
641
+
642
+		if ($GLOBALS['xoopsModuleConfig']['show_sociallinks']) {
643
+			$full_title  = $this->getVar('subject');
644
+			$clean_title = preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject'));
645
+			$full_link   = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post_id;
646
+
647
+			$thread_action['social_twitter']['image']  = newbbDisplayImage('twitter', _MD_NEWBB_SHARE_TWITTER);
648
+			$thread_action['social_twitter']['link']   = 'http://twitter.com/share?text=' . $clean_title . '&amp;url=' . $full_link;
649
+			$thread_action['social_twitter']['name']   = _MD_NEWBB_SHARE_TWITTER;
650
+			$thread_action['social_twitter']['target'] = '_blank';
651
+
652
+			$thread_action['social_facebook']['image']  = newbbDisplayImage('facebook', _MD_NEWBB_SHARE_FACEBOOK);
653
+			$thread_action['social_facebook']['link']   = 'http://www.facebook.com/sharer.php?u=' . $full_link;
654
+			$thread_action['social_facebook']['name']   = _MD_NEWBB_SHARE_FACEBOOK;
655
+			$thread_action['social_facebook']['target'] = '_blank';
656
+
657
+			$thread_action['social_gplus']['image']  = newbbDisplayImage('googleplus', _MD_NEWBB_SHARE_GOOGLEPLUS);
658
+			$thread_action['social_gplus']['link']   = 'https://plusone.google.com/_/+1/confirm?hl=en&url=' . $full_link;
659
+			$thread_action['social_gplus']['name']   = _MD_NEWBB_SHARE_GOOGLEPLUS;
660
+			$thread_action['social_gplus']['target'] = '_blank';
661
+
662
+			$thread_action['social_linkedin']['image']  = newbbDisplayImage('linkedin', _MD_NEWBB_SHARE_LINKEDIN);
663
+			$thread_action['social_linkedin']['link']   = 'http://www.linkedin.com/shareArticle?mini=true&amp;title=' . $full_title . '&amp;url=' . $full_link;
664
+			$thread_action['social_linkedin']['name']   = _MD_NEWBB_SHARE_LINKEDIN;
665
+			$thread_action['social_linkedin']['target'] = '_blank';
666
+
667
+			$thread_action['social_delicious']['image']  = newbbDisplayImage('delicious', _MD_NEWBB_SHARE_DELICIOUS);
668
+			$thread_action['social_delicious']['link']   = 'http://del.icio.us/post?title=' . $full_title . '&amp;url=' . $full_link;
669
+			$thread_action['social_delicious']['name']   = _MD_NEWBB_SHARE_DELICIOUS;
670
+			$thread_action['social_delicious']['target'] = '_blank';
671
+
672
+			$thread_action['social_digg']['image']  = newbbDisplayImage('digg', _MD_NEWBB_SHARE_DIGG);
673
+			$thread_action['social_digg']['link']   = 'http://digg.com/submit?phase=2&amp;title=' . $full_title . '&amp;url=' . $full_link;
674
+			$thread_action['social_digg']['name']   = _MD_NEWBB_SHARE_DIGG;
675
+			$thread_action['social_digg']['target'] = '_blank';
676
+
677
+			$thread_action['social_reddit']['image']  = newbbDisplayImage('reddit', _MD_NEWBB_SHARE_REDDIT);
678
+			$thread_action['social_reddit']['link']   = 'http://reddit.com/submit?title=' . $full_title . '&amp;url=' . $full_link;
679
+			$thread_action['social_reddit']['name']   = _MD_NEWBB_SHARE_REDDIT;
680
+			$thread_action['social_reddit']['target'] = '_blank';
681
+
682
+			$thread_action['social_wong']['image']  = newbbDisplayImage('wong', _MD_NEWBB_SHARE_MRWONG);
683
+			$thread_action['social_wong']['link']   = 'http://www.mister-wong.de/index.php?action=addurl&bm_url=' . $full_link;
684
+			$thread_action['social_wong']['name']   = _MD_NEWBB_SHARE_MRWONG;
685
+			$thread_action['social_wong']['target'] = '_blank';
686
+		}
687
+
688
+		$post = [
689
+			'post_id'         => $post_id,
690
+			'post_parent_id'  => $this->getVar('pid'),
691
+			'post_date'       => newbbFormatTimestamp($this->getVar('post_time')),
692
+			'post_image'      => $post_image,
693
+			'post_title'      => $post_title,
694
+			// irmtfan $post_title to add highlight keywords
695
+			'post_text'       => $post_text,
696
+			'post_attachment' => $post_attachment,
697
+			'post_edit'       => $this->displayPostEdit(),
698
+			'post_no'         => $post_no,
699
+			'post_signature'  => $this->getVar('attachsig') ? @$poster['signature'] : '',
700
+			//            'poster_ip'       => ($isAdmin && $GLOBALS['xoopsModuleConfig']['show_ip']) ? long2ip($this->getVar('poster_ip')) : '',
701
+			'poster_ip'       => ($isAdmin
702
+								  && $GLOBALS['xoopsModuleConfig']['show_ip']) ? $this->getVar('poster_ip') : '',
703
+			'thread_action'   => $thread_action,
704
+			'thread_buttons'  => $thread_buttons,
705
+			'mod_buttons'     => $mod_buttons,
706
+			'poster'          => $poster,
707
+			'post_permalink'  => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $post_id . '"></a>'
708
+		];
709
+
710
+		unset($thread_buttons, $mod_buttons, $eachposter);
711
+
712
+		return $post;
713
+	}
714 714
 }
Please login to merge, or discard this patch.