|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* You may not change or alter any portion of this comment or credits |
|
5
|
|
|
* of supporting developers from this source code or any supporting source code |
|
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
* |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
|
15
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
16
|
|
|
* @package |
|
17
|
|
|
* @since |
|
18
|
|
|
* @author XOOPS Development Team |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use XoopsModules\Newbb; |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
// irmtfan use full path because block maybe used outside newbb |
|
25
|
|
|
|
|
26
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php'); |
|
27
|
|
|
|
|
28
|
|
|
if (defined('NEWBB_BLOCK_DEFINED')) { |
|
29
|
|
|
return; |
|
30
|
|
|
} |
|
31
|
|
|
define('NEWBB_BLOCK_DEFINED', true); |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param $var |
|
35
|
|
|
* @return bool |
|
36
|
|
|
*/ |
|
37
|
|
|
function b_newbb_array_filter($var) |
|
38
|
|
|
{ |
|
39
|
|
|
return $var > 0; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
// options[0] - Citeria valid: time(by default) |
|
43
|
|
|
// options[1] - NumberToDisplay: any positive integer |
|
44
|
|
|
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days |
|
45
|
|
|
// options[3] - DisplayMode: 0-full view;1-compact view;2-lite view |
|
46
|
|
|
// options[4] - Display Navigator: 1 (by default), 0 (No) |
|
47
|
|
|
// options[5] - Title Length : 0 - no limit |
|
48
|
|
|
// options[6] - SelectedForumIDs: null for all |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param $options |
|
52
|
|
|
* @return array|bool |
|
53
|
|
|
*/ |
|
54
|
|
|
function b_newbb_show($options) |
|
55
|
|
|
{ |
|
56
|
|
|
global $accessForums; |
|
57
|
|
|
global $xoopsLogger; |
|
58
|
|
|
|
|
59
|
|
|
require_once dirname(__DIR__) . '/include/functions.config.php'; |
|
60
|
|
|
require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
61
|
|
|
|
|
62
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
63
|
|
|
$block = []; |
|
64
|
|
|
$i = 0; |
|
|
|
|
|
|
65
|
|
|
$order = ''; |
|
|
|
|
|
|
66
|
|
|
$extraCriteria = ''; |
|
67
|
|
|
if (!empty($options[2])) { |
|
68
|
|
|
//require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
69
|
|
|
$extraCriteria .= ' AND p.post_time>' . (time() - newbbGetSinceTime($options[2])); |
|
70
|
|
|
} |
|
71
|
|
|
switch ($options[0]) { |
|
72
|
|
|
case 'time': |
|
73
|
|
|
default: |
|
74
|
|
|
$order = 't.topic_last_post_id'; |
|
75
|
|
|
break; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
if (!isset($accessForums)) { |
|
79
|
|
|
/** var Newbb\PermissionHandler $permHandler */ |
|
80
|
|
|
$permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); |
|
81
|
|
|
if (!$accessForums = $permHandler->getForums()) { |
|
82
|
|
|
return $block; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
if (!empty($options[6])) { |
|
86
|
|
|
$myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums |
|
87
|
|
|
$allowedForums = array_intersect($myallowedForums, $accessForums); |
|
88
|
|
|
} else { |
|
89
|
|
|
$allowedForums = $accessForums; |
|
90
|
|
|
} |
|
91
|
|
|
if (empty($allowedForums)) { |
|
92
|
|
|
return $block; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
$forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
96
|
|
|
$approveCriteria = ' AND t.approved = 1'; |
|
97
|
|
|
|
|
98
|
|
|
$newbbConfig = newbbLoadConfig(); |
|
99
|
|
|
if (!empty($newbbConfig['do_rewrite'])) { |
|
100
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
101
|
|
|
} else { |
|
102
|
|
|
if (!defined('SEO_MODULE_NAME')) { |
|
103
|
|
|
define('SEO_MODULE_NAME', 'modules/newbb'); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$query = 'SELECT' |
|
108
|
|
|
. ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id,' |
|
109
|
|
|
. ' f.forum_name,t.topic_status,' |
|
110
|
|
|
. ' p.post_id, p.post_time, p.icon, p.uid, p.poster_name' |
|
111
|
|
|
. ' FROM ' |
|
112
|
|
|
. $GLOBALS['xoopsDB']->prefix('newbb_topics') |
|
113
|
|
|
. ' AS t ' |
|
114
|
|
|
. ' LEFT JOIN ' |
|
115
|
|
|
. $GLOBALS['xoopsDB']->prefix('newbb_posts') |
|
116
|
|
|
. ' AS p ON t.topic_last_post_id=p.post_id' |
|
117
|
|
|
. ' LEFT JOIN ' |
|
118
|
|
|
. $GLOBALS['xoopsDB']->prefix('newbb_forums') |
|
119
|
|
|
. ' AS f ON f.forum_id=t.forum_id' |
|
120
|
|
|
. ' WHERE 1=1 ' |
|
121
|
|
|
. $forumCriteria |
|
122
|
|
|
. $approveCriteria |
|
123
|
|
|
. $extraCriteria |
|
124
|
|
|
. ' ORDER BY ' |
|
125
|
|
|
. $order |
|
126
|
|
|
. ' DESC'; |
|
127
|
|
|
|
|
128
|
|
|
$result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
129
|
|
|
|
|
130
|
|
|
if (!$result) { |
|
131
|
|
|
//xoops_error($GLOBALS['xoopsDB']->error()); |
|
132
|
|
|
return false; |
|
133
|
|
|
} |
|
134
|
|
|
$block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
135
|
|
|
$rows = []; |
|
136
|
|
|
$author = []; |
|
137
|
|
|
$types = []; |
|
138
|
|
|
|
|
139
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
140
|
|
|
$rows[] = $row; |
|
141
|
|
|
$author[$row['uid']] = 1; |
|
142
|
|
|
if ($row['type_id'] > 0) { |
|
143
|
|
|
$types[$row['type_id']] = 1; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
if (count($rows) < 1) { |
|
148
|
|
|
return $block; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
152
|
|
|
$author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
153
|
|
|
|
|
154
|
|
|
if (count($types) > 0) { |
|
155
|
|
|
/** @var Newbb\TypeHandler $typeHandler */ |
|
156
|
|
|
$typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); |
|
157
|
|
|
$type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
foreach ($rows as $arr) { |
|
161
|
|
|
// irmtfan add lastposticon - load main lang |
|
162
|
|
|
xoops_loadLanguage('main', 'newbb'); |
|
163
|
|
|
$topic = []; |
|
164
|
|
|
$topic_page_jump = newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST); |
|
165
|
|
|
$topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . ']'; |
|
166
|
|
|
|
|
167
|
|
|
$topic['post_id'] = $arr['post_id']; |
|
168
|
|
|
$topic['topic_status'] = $arr['topic_status']; |
|
169
|
|
|
$topic['forum_id'] = $arr['forum_id']; |
|
170
|
|
|
$topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
171
|
|
|
$topic['id'] = $arr['topic_id']; |
|
172
|
|
|
|
|
173
|
|
|
$title = $myts->htmlSpecialChars($arr['topic_title']); |
|
174
|
|
|
if (!empty($options[5])) { |
|
175
|
|
|
$title = xoops_substr($title, 0, $options[5]); |
|
176
|
|
|
} |
|
177
|
|
|
$topic['title'] = $topic['topic_subject'] . ' ' . $title; |
|
178
|
|
|
$topic['replies'] = $arr['topic_replies']; |
|
179
|
|
|
$topic['views'] = $arr['topic_views']; |
|
180
|
|
|
$topic['time'] = newbbFormatTimestamp($arr['post_time']); |
|
181
|
|
|
if (!empty($author_name[$arr['uid']])) { |
|
182
|
|
|
$topic_poster = $author_name[$arr['uid']]; |
|
183
|
|
|
} else { |
|
184
|
|
|
$topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
185
|
|
|
} |
|
186
|
|
|
$topic['topic_poster'] = $topic_poster; |
|
187
|
|
|
$topic['topic_page_jump'] = $topic_page_jump; |
|
188
|
|
|
// START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
189
|
|
|
$seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
190
|
|
|
$seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
191
|
|
|
$seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
192
|
|
|
if (!empty($newbbConfig['do_rewrite'])) { |
|
193
|
|
|
$topic['seo_url'] = seo_urls($seo_url); |
|
194
|
|
|
$topic['seo_topic_url'] = seo_urls($seo_topic_url); |
|
195
|
|
|
$topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
196
|
|
|
} else { |
|
197
|
|
|
$topic['seo_url'] = $seo_url; |
|
198
|
|
|
$topic['seo_topic_url'] = $seo_topic_url; |
|
199
|
|
|
$topic['seo_forum_url'] = $seo_forum_url; |
|
200
|
|
|
} |
|
201
|
|
|
// END irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
202
|
|
|
$block['topics'][] = $topic; |
|
203
|
|
|
unset($topic); |
|
204
|
|
|
} |
|
205
|
|
|
// START irmtfan remove hardcoded html in URLs |
|
206
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
207
|
|
|
$block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
208
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
209
|
|
|
$block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
210
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
211
|
|
|
$block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
212
|
|
|
// END irmtfan remove hardcoded html in URLs |
|
213
|
|
|
$block['indexNav'] = (int)$options[4]; |
|
214
|
|
|
|
|
215
|
|
|
return $block; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
// options[0] - Citeria valid: time(by default), views, replies, digest, sticky |
|
219
|
|
|
// options[1] - NumberToDisplay: any positive integer |
|
220
|
|
|
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days |
|
221
|
|
|
// options[3] - DisplayMode: 0-full view;1-compact view;2-lite view |
|
222
|
|
|
// options[4] - Display Navigator: 1 (by default), 0 (No) |
|
223
|
|
|
// options[5] - Title Length : 0 - no limit |
|
224
|
|
|
// options[6] - SelectedForumIDs: null for all |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @param $options |
|
228
|
|
|
* @return array|bool |
|
229
|
|
|
*/ |
|
230
|
|
|
function b_newbb_topic_show($options) |
|
231
|
|
|
{ |
|
232
|
|
|
global $accessForums; |
|
233
|
|
|
require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
234
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
235
|
|
|
$block = []; |
|
236
|
|
|
$i = 0; |
|
|
|
|
|
|
237
|
|
|
$order = ''; |
|
238
|
|
|
$extraCriteria = ''; |
|
239
|
|
|
$time_criteria = null; |
|
240
|
|
|
if (!empty($options[2])) { |
|
241
|
|
|
$time_criteria = time() - newbbGetSinceTime($options[2]); |
|
242
|
|
|
$extraCriteria = ' AND t.topic_time>' . $time_criteria; |
|
243
|
|
|
} |
|
244
|
|
|
switch ($options[0]) { |
|
245
|
|
|
case 'views': |
|
246
|
|
|
$order = 't.topic_views'; |
|
247
|
|
|
break; |
|
248
|
|
|
case 'replies': |
|
249
|
|
|
$order = 't.topic_replies'; |
|
250
|
|
|
break; |
|
251
|
|
|
case 'digest': |
|
252
|
|
|
$order = 't.digest_time'; |
|
253
|
|
|
$extraCriteria = ' AND t.topic_digest=1'; |
|
254
|
|
|
if (null !== $time_criteria) { |
|
255
|
|
|
$extraCriteria .= ' AND t.digest_time>' . $time_criteria; |
|
256
|
|
|
} |
|
257
|
|
|
break; |
|
258
|
|
|
case 'sticky': |
|
259
|
|
|
$order = 't.topic_id'; |
|
260
|
|
|
$extraCriteria .= ' AND t.topic_sticky=1'; |
|
261
|
|
|
break; |
|
262
|
|
|
case 'time': |
|
263
|
|
|
default: |
|
264
|
|
|
$order = 't.topic_id'; |
|
265
|
|
|
break; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
$newbbConfig = newbbLoadConfig(); |
|
269
|
|
|
if (!empty($newbbConfig['do_rewrite'])) { |
|
270
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
271
|
|
|
} else { |
|
272
|
|
|
if (!defined('SEO_MODULE_NAME')) { |
|
273
|
|
|
define('SEO_MODULE_NAME', 'modules/newbb'); |
|
274
|
|
|
} |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
if (!isset($accessForums)) { |
|
278
|
|
|
/** var Newbb\PermissionHandler $permHandler */ |
|
279
|
|
|
$permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); |
|
280
|
|
|
if (!$accessForums = $permHandler->getForums()) { |
|
281
|
|
|
return $block; |
|
282
|
|
|
} |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
if (!empty($options[6])) { |
|
286
|
|
|
$myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums |
|
287
|
|
|
$allowedForums = array_intersect($myallowedForums, $accessForums); |
|
288
|
|
|
} else { |
|
289
|
|
|
$allowedForums = $accessForums; |
|
290
|
|
|
} |
|
291
|
|
|
if (empty($allowedForums)) { |
|
292
|
|
|
return false; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
$forumCriteria = ' AND t.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
296
|
|
|
$approveCriteria = ' AND t.approved = 1'; |
|
297
|
|
|
|
|
298
|
|
|
$query = 'SELECT' . ' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.type_id, t.topic_time, t.topic_poster, t.poster_name,' . ' f.forum_name' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' AS t ' . ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix( |
|
299
|
|
|
'newbb_forums' |
|
300
|
|
|
) . ' AS f ON f.forum_id=t.forum_id' . ' WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC'; |
|
301
|
|
|
|
|
302
|
|
|
$result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
303
|
|
|
|
|
304
|
|
|
if (!$result) { |
|
305
|
|
|
//xoops_error($GLOBALS['xoopsDB']->error()); |
|
306
|
|
|
return $block; |
|
307
|
|
|
} |
|
308
|
|
|
$block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
309
|
|
|
$rows = []; |
|
310
|
|
|
$author = []; |
|
311
|
|
|
$types = []; |
|
312
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
313
|
|
|
$rows[] = $row; |
|
314
|
|
|
$author[$row['topic_poster']] = 1; |
|
315
|
|
|
if ($row['type_id'] > 0) { |
|
316
|
|
|
$types[$row['type_id']] = 1; |
|
317
|
|
|
} |
|
318
|
|
|
} |
|
319
|
|
|
if (count($rows) < 1) { |
|
320
|
|
|
return $block; |
|
321
|
|
|
} |
|
322
|
|
|
require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
323
|
|
|
$author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
324
|
|
|
if (count($types) > 0) { |
|
325
|
|
|
/** @var Newbb\TypeHandler $typeHandler */ |
|
326
|
|
|
$typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type'); |
|
327
|
|
|
$type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN')); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
foreach ($rows as $arr) { |
|
331
|
|
|
// irmtfan remove $topic_page_jump because there is no last post |
|
332
|
|
|
//$topic_page_jump = ''; |
|
333
|
|
|
$topic = []; |
|
334
|
|
|
$topic['topic_subject'] = empty($type_list[$arr['type_id']]) ? '' : '[' . $type_list[$arr['type_id']] . '] '; |
|
335
|
|
|
$topic['forum_id'] = $arr['forum_id']; |
|
336
|
|
|
$topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
337
|
|
|
$topic['id'] = $arr['topic_id']; |
|
338
|
|
|
|
|
339
|
|
|
$title = $myts->htmlSpecialChars($arr['topic_title']); |
|
340
|
|
|
if (!empty($options[5])) { |
|
341
|
|
|
$title = xoops_substr($title, 0, $options[5]); |
|
342
|
|
|
} |
|
343
|
|
|
$topic['title'] = $topic['topic_subject'] . $title; |
|
344
|
|
|
$topic['replies'] = $arr['topic_replies']; |
|
345
|
|
|
$topic['views'] = $arr['topic_views']; |
|
346
|
|
|
$topic['time'] = newbbFormatTimestamp($arr['topic_time']); |
|
347
|
|
|
if (!empty($author_name[$arr['topic_poster']])) { |
|
348
|
|
|
$topic_poster = $author_name[$arr['topic_poster']]; |
|
349
|
|
|
} else { |
|
350
|
|
|
$topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
351
|
|
|
} |
|
352
|
|
|
$topic['topic_poster'] = $topic_poster; |
|
353
|
|
|
// irmtfan remove $topic_page_jump because there is no last post |
|
354
|
|
|
//$topic['topic_page_jump'] = $topic_page_jump; |
|
355
|
|
|
// START irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
356
|
|
|
$seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; |
|
357
|
|
|
$seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
358
|
|
|
|
|
359
|
|
|
if (!empty($newbbConfig['do_rewrite'])) { |
|
360
|
|
|
$topic['seo_topic_url'] = seo_urls($seo_topic_url); |
|
361
|
|
|
$topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
362
|
|
|
} else { |
|
363
|
|
|
$topic['seo_topic_url'] = $seo_topic_url; |
|
364
|
|
|
$topic['seo_forum_url'] = $seo_forum_url; |
|
365
|
|
|
} |
|
366
|
|
|
// END irmtfan remove hardcoded html in URLs - add $seo_topic_url |
|
367
|
|
|
$block['topics'][] = $topic; |
|
368
|
|
|
unset($topic); |
|
369
|
|
|
} |
|
370
|
|
|
// START irmtfan remove hardcoded html in URLs |
|
371
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
372
|
|
|
$block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
373
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
374
|
|
|
$block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
375
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
376
|
|
|
$block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
377
|
|
|
// END irmtfan remove hardcoded html in URLs |
|
378
|
|
|
$block['indexNav'] = (int)$options[4]; |
|
379
|
|
|
|
|
380
|
|
|
return $block; |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
// options[0] - Citeria valid: title(by default), text |
|
384
|
|
|
// options[1] - NumberToDisplay: any positive integer |
|
385
|
|
|
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days |
|
386
|
|
|
// options[3] - DisplayMode: 0-full view;1-compact view;2-lite view; Only valid for "time" |
|
387
|
|
|
// options[4] - Display Navigator: 1 (by default), 0 (No) |
|
388
|
|
|
// options[5] - Title/Text Length : 0 - no limit |
|
389
|
|
|
// options[6] - SelectedForumIDs: null for all |
|
390
|
|
|
|
|
391
|
|
|
/** |
|
392
|
|
|
* @param $options |
|
393
|
|
|
* @return array |
|
394
|
|
|
*/ |
|
395
|
|
|
function b_newbb_post_show($options) |
|
396
|
|
|
{ |
|
397
|
|
|
global $accessForums; |
|
398
|
|
|
global $newbbConfig; |
|
399
|
|
|
|
|
400
|
|
|
require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
401
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
402
|
|
|
$block = []; |
|
403
|
|
|
$i = 0; |
|
|
|
|
|
|
404
|
|
|
$order = ''; |
|
|
|
|
|
|
405
|
|
|
$extraCriteria = ''; |
|
406
|
|
|
$time_criteria = null; |
|
|
|
|
|
|
407
|
|
|
if (!empty($options[2])) { |
|
408
|
|
|
$time_criteria = time() - newbbGetSinceTime($options[2]); |
|
409
|
|
|
$extraCriteria = ' AND p.post_time>' . $time_criteria; |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
switch ($options[0]) { |
|
413
|
|
|
case 'text': |
|
414
|
|
|
if (!empty($newbbConfig['enable_karma'])) { |
|
415
|
|
|
$extraCriteria .= ' AND p.post_karma = 0'; |
|
416
|
|
|
} |
|
417
|
|
|
if (!empty($newbbConfig['allow_require_reply'])) { |
|
418
|
|
|
$extraCriteria .= ' AND p.require_reply = 0'; |
|
419
|
|
|
} |
|
420
|
|
|
// no break |
|
421
|
|
|
default: |
|
422
|
|
|
$order = 'p.post_id'; |
|
423
|
|
|
break; |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
if (!isset($accessForums)) { |
|
427
|
|
|
/** var Newbb\PermissionHandler $permHandler */ |
|
428
|
|
|
$permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); |
|
429
|
|
|
if (!$accessForums = $permHandler->getForums()) { |
|
430
|
|
|
return $block; |
|
431
|
|
|
} |
|
432
|
|
|
} |
|
433
|
|
|
|
|
434
|
|
|
$newbbConfig = newbbLoadConfig(); |
|
435
|
|
|
if (!empty($newbbConfig['do_rewrite'])) { |
|
436
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/seo_url.php'); |
|
437
|
|
|
} else { |
|
438
|
|
|
if (!defined('SEO_MODULE_NAME')) { |
|
439
|
|
|
define('SEO_MODULE_NAME', 'modules/newbb'); |
|
440
|
|
|
} |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
if (!empty($options[6])) { |
|
444
|
|
|
$myallowedForums = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums |
|
445
|
|
|
$allowedForums = array_intersect($myallowedForums, $accessForums); |
|
446
|
|
|
} else { |
|
447
|
|
|
$allowedForums = $accessForums; |
|
448
|
|
|
} |
|
449
|
|
|
if (empty($allowedForums)) { |
|
450
|
|
|
return $block; |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
$forumCriteria = ' AND p.forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
454
|
|
|
$approveCriteria = ' AND p.approved = 1'; |
|
455
|
|
|
|
|
456
|
|
|
$query = 'SELECT'; |
|
457
|
|
|
$query .= ' p.post_id, p.subject, p.post_time, p.icon, p.uid, p.poster_name,'; |
|
458
|
|
|
if ('text' === $options[0]) { |
|
459
|
|
|
$query .= ' pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr, pt.post_text,'; |
|
460
|
|
|
} |
|
461
|
|
|
$query .= ' f.forum_id, f.forum_name' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' AS p ' . ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_forums') . ' AS f ON f.forum_id=p.forum_id'; |
|
462
|
|
|
if ('text' === $options[0]) { |
|
463
|
|
|
$query .= ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_posts_text') . ' AS pt ON pt.post_id=p.post_id'; |
|
464
|
|
|
} |
|
465
|
|
|
$query .= ' WHERE 1=1 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' ORDER BY ' . $order . ' DESC'; |
|
466
|
|
|
|
|
467
|
|
|
$result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
468
|
|
|
if (!$result) { |
|
469
|
|
|
//xoops_error($GLOBALS['xoopsDB']->error()); |
|
470
|
|
|
return $block; |
|
471
|
|
|
} |
|
472
|
|
|
$block['disp_mode'] = ('text' === $options[0]) ? 3 : $options[3]; // 0 - full view; 1 - compact view; 2 - lite view; |
|
473
|
|
|
$rows = []; |
|
474
|
|
|
$author = []; |
|
475
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
476
|
|
|
$rows[] = $row; |
|
477
|
|
|
$author[$row['uid']] = 1; |
|
478
|
|
|
} |
|
479
|
|
|
if (count($rows) < 1) { |
|
480
|
|
|
return $block; |
|
481
|
|
|
} |
|
482
|
|
|
require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
483
|
|
|
$author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true); |
|
484
|
|
|
|
|
485
|
|
|
foreach ($rows as $arr) { |
|
486
|
|
|
//if ($arr['icon'] && is_file($GLOBALS['xoops']->path('images/subject/' . $arr['icon']))) { |
|
487
|
|
|
if (!empty($arr['icon'])) { |
|
488
|
|
|
$last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($arr['icon'], ENT_QUOTES | ENT_HTML5) . '" alt="" >'; |
|
|
|
|
|
|
489
|
|
|
} else { |
|
490
|
|
|
$last_post_icon = '<img src="' . XOOPS_URL . '/images/subject/icon1.gif" alt="" >'; |
|
491
|
|
|
} |
|
492
|
|
|
//$topic['jump_post'] = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=" . $arr['post_id'] ."#forumpost" . $arr['post_id'] . "'>" . $last_post_icon . '</a>'; |
|
493
|
|
|
$topic = []; |
|
494
|
|
|
$topic['forum_id'] = $arr['forum_id']; |
|
495
|
|
|
$topic['forum_name'] = $myts->htmlSpecialChars($arr['forum_name']); |
|
496
|
|
|
//$topic['id'] = $arr['topic_id']; |
|
497
|
|
|
|
|
498
|
|
|
$title = $myts->htmlSpecialChars($arr['subject']); |
|
499
|
|
|
if ('text' !== $options[0] && !empty($options[5])) { |
|
500
|
|
|
$title = xoops_substr($title, 0, $options[5]); |
|
501
|
|
|
} |
|
502
|
|
|
$topic['title'] = $title; |
|
503
|
|
|
$topic['post_id'] = $arr['post_id']; |
|
504
|
|
|
$topic['time'] = newbbFormatTimestamp($arr['post_time']); |
|
505
|
|
|
if (!empty($author_name[$arr['uid']])) { |
|
506
|
|
|
$topic_poster = $author_name[$arr['uid']]; |
|
507
|
|
|
} else { |
|
508
|
|
|
$topic_poster = $myts->htmlSpecialChars($arr['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous']); |
|
509
|
|
|
} |
|
510
|
|
|
$topic['topic_poster'] = $topic_poster; |
|
511
|
|
|
|
|
512
|
|
|
if ('text' === $options[0]) { |
|
513
|
|
|
$post_text = $myts->displayTarea($arr['post_text'], $arr['dohtml'], $arr['dosmiley'], $arr['doxcode'], 1, $arr['dobr']); |
|
514
|
|
|
if (!empty($options[5])) { |
|
515
|
|
|
$post_text = xoops_substr(strip_tags($post_text), 0, $options[5]); |
|
516
|
|
|
} |
|
517
|
|
|
$topic['post_text'] = $post_text; |
|
518
|
|
|
} |
|
519
|
|
|
// START irmtfan remove hardcoded html in URLs |
|
520
|
|
|
$seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; |
|
521
|
|
|
$seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; |
|
522
|
|
|
// END irmtfan remove hardcoded html in URLs |
|
523
|
|
|
if (!empty($newbbConfig['do_rewrite'])) { |
|
524
|
|
|
$topic['seo_url'] = seo_urls($seo_url); |
|
525
|
|
|
$topic['seo_forum_url'] = seo_urls($seo_forum_url); |
|
526
|
|
|
} else { |
|
527
|
|
|
$topic['seo_url'] = $seo_url; |
|
528
|
|
|
$topic['seo_forum_url'] = $seo_forum_url; |
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
$block['topics'][] = $topic; |
|
532
|
|
|
unset($topic); |
|
533
|
|
|
} |
|
534
|
|
|
// START irmtfan remove hardcoded html in URLs |
|
535
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME; |
|
536
|
|
|
$block['seo_top_allforums'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
537
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/list.topic.php'; |
|
538
|
|
|
$block['seo_top_alltopics'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
539
|
|
|
$seo_top_allforums = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewpost.php'; |
|
540
|
|
|
$block['seo_top_allposts'] = !empty($newbbConfig['do_rewrite']) ? seo_urls($seo_top_allforums) : $seo_top_allforums; |
|
541
|
|
|
// END irmtfan remove hardcoded html in URLs |
|
542
|
|
|
|
|
543
|
|
|
$block['indexNav'] = (int)$options[4]; |
|
544
|
|
|
|
|
545
|
|
|
return $block; |
|
546
|
|
|
} |
|
547
|
|
|
|
|
548
|
|
|
// options[0] - Citeria valid: post(by default), topic, digest, sticky |
|
549
|
|
|
// options[1] - NumberToDisplay: any positive integer |
|
550
|
|
|
// options[2] - TimeDuration: negative for hours, positive for days, for instance, -5 for 5 hours and 5 for 5 days |
|
551
|
|
|
// options[3] - DisplayMode: 0-full view;1-compact view; |
|
552
|
|
|
// options[4] - Display Navigator: 1 (by default), 0 (No) |
|
553
|
|
|
// options[5] - Title Length : 0 - no limit |
|
554
|
|
|
// options[6] - SelectedForumIDs: null for all |
|
555
|
|
|
|
|
556
|
|
|
/** |
|
557
|
|
|
* @param $options |
|
558
|
|
|
* @return array|bool |
|
559
|
|
|
*/ |
|
560
|
|
|
function b_newbb_author_show($options) |
|
561
|
|
|
{ |
|
562
|
|
|
global $accessForums; |
|
563
|
|
|
global $newbbConfig; |
|
564
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
565
|
|
|
$block = []; |
|
566
|
|
|
// $i = 0; |
|
567
|
|
|
$type = 'topic'; |
|
568
|
|
|
$order = 'count'; |
|
569
|
|
|
$extraCriteria = ''; |
|
570
|
|
|
$time_criteria = null; |
|
571
|
|
|
if (!empty($options[2])) { |
|
572
|
|
|
require_once dirname(__DIR__) . '/include/functions.time.php'; |
|
573
|
|
|
$time_criteria = time() - newbbGetSinceTime($options[2]); |
|
574
|
|
|
$extraCriteria = ' AND topic_time > ' . $time_criteria; |
|
575
|
|
|
} |
|
576
|
|
|
switch ($options[0]) { |
|
577
|
|
|
case 'topic': |
|
578
|
|
|
break; |
|
579
|
|
|
case 'digest': |
|
580
|
|
|
$extraCriteria = ' AND topic_digest = 1'; |
|
581
|
|
|
if (null !== $time_criteria) { |
|
582
|
|
|
$extraCriteria .= ' AND digest_time > ' . $time_criteria; |
|
583
|
|
|
} |
|
584
|
|
|
break; |
|
585
|
|
|
case 'sticky': |
|
586
|
|
|
$extraCriteria .= ' AND topic_sticky = 1'; |
|
587
|
|
|
break; |
|
588
|
|
|
case 'post': |
|
589
|
|
|
default: |
|
590
|
|
|
$type = 'post'; |
|
591
|
|
|
if (null !== $time_criteria) { |
|
592
|
|
|
$extraCriteria = ' AND post_time > ' . $time_criteria; |
|
593
|
|
|
} |
|
594
|
|
|
break; |
|
595
|
|
|
} |
|
596
|
|
|
|
|
597
|
|
|
if (!isset($accessForums)) { |
|
598
|
|
|
/** var Newbb\PermissionHandler $permHandler */ |
|
599
|
|
|
$permHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); |
|
600
|
|
|
if (!$accessForums = $permHandler->getForums()) { |
|
601
|
|
|
return $block; |
|
602
|
|
|
} |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
if (!empty($options[5])) { |
|
606
|
|
|
$myallowedForums = array_filter(array_slice($options, 5), '\b_newbb_array_filter'); // get allowed forums |
|
607
|
|
|
$allowedForums = array_intersect($myallowedForums, $accessForums); |
|
608
|
|
|
} else { |
|
609
|
|
|
$allowedForums = $accessForums; |
|
610
|
|
|
} |
|
611
|
|
|
if (empty($allowedForums)) { |
|
612
|
|
|
return false; |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
if ('topic' === $type) { |
|
616
|
|
|
$forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
617
|
|
|
$approveCriteria = ' AND approved = 1'; |
|
618
|
|
|
$query = 'SELECT DISTINCT topic_poster AS author, COUNT(*) AS count |
|
619
|
|
|
FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' |
|
620
|
|
|
WHERE topic_poster>0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY topic_poster ORDER BY ' . $order . ' DESC'; |
|
621
|
|
|
} else { |
|
622
|
|
|
$forumCriteria = ' AND forum_id IN (' . implode(',', $allowedForums) . ')'; |
|
623
|
|
|
$approveCriteria = ' AND approved = 1'; |
|
624
|
|
|
$query = 'SELECT DISTINCT uid AS author, COUNT(*) AS count |
|
625
|
|
|
FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . ' |
|
626
|
|
|
WHERE uid > 0 ' . $forumCriteria . $approveCriteria . $extraCriteria . ' GROUP BY uid ORDER BY ' . $order . ' DESC'; |
|
627
|
|
|
} |
|
628
|
|
|
|
|
629
|
|
|
$result = $GLOBALS['xoopsDB']->query($query, $options[1], 0); |
|
630
|
|
|
if (!$result) { |
|
631
|
|
|
//xoops_error($GLOBALS['xoopsDB']->error()); |
|
632
|
|
|
return $block; |
|
633
|
|
|
} |
|
634
|
|
|
$author = []; |
|
635
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
636
|
|
|
$author[$row['author']]['count'] = $row['count']; |
|
637
|
|
|
} |
|
638
|
|
|
if (count($author) < 1) { |
|
639
|
|
|
return $block; |
|
640
|
|
|
} |
|
641
|
|
|
require_once dirname(__DIR__) . '/include/functions.user.php'; |
|
642
|
|
|
$author_name = newbbGetUnameFromIds(array_keys($author), $newbbConfig['show_realname']); |
|
643
|
|
|
foreach (array_keys($author) as $uid) { |
|
644
|
|
|
$author[$uid]['name'] = $myts->htmlSpecialChars($author_name[$uid]); |
|
645
|
|
|
} |
|
646
|
|
|
$block['authors'] = &$author; |
|
647
|
|
|
$block['disp_mode'] = $options[3]; // 0 - full view; 1 - lite view; |
|
648
|
|
|
$block['indexNav'] = (int)$options[4]; |
|
649
|
|
|
|
|
650
|
|
|
return $block; |
|
651
|
|
|
} |
|
652
|
|
|
|
|
653
|
|
|
/** |
|
654
|
|
|
* @param $options |
|
655
|
|
|
* @return string |
|
656
|
|
|
*/ |
|
657
|
|
|
function b_newbb_edit($options) |
|
658
|
|
|
{ |
|
659
|
|
|
require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
660
|
|
|
|
|
661
|
|
|
$form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
662
|
|
|
$form .= "<option value='time'"; |
|
663
|
|
|
if ('time' === $options[0]) { |
|
664
|
|
|
$form .= " selected='selected' "; |
|
665
|
|
|
} |
|
666
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
667
|
|
|
$form .= '</select>'; |
|
668
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >"; |
|
669
|
|
|
$form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >"; |
|
670
|
|
|
$form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
671
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
672
|
|
|
if (0 == $options[3]) { |
|
673
|
|
|
$form .= ' checked'; |
|
674
|
|
|
} |
|
675
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
676
|
|
|
if (1 == $options[3]) { |
|
677
|
|
|
$form .= ' checked'; |
|
678
|
|
|
} |
|
679
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
680
|
|
|
if (2 == $options[3]) { |
|
681
|
|
|
$form .= ' checked'; |
|
682
|
|
|
} |
|
683
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
684
|
|
|
|
|
685
|
|
|
$form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
686
|
|
|
if (1 == $options[4]) { |
|
687
|
|
|
$form .= ' checked'; |
|
688
|
|
|
} |
|
689
|
|
|
$form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
690
|
|
|
if (0 == $options[4]) { |
|
691
|
|
|
$form .= ' checked'; |
|
692
|
|
|
} |
|
693
|
|
|
$form .= ' >' . _NO; |
|
694
|
|
|
|
|
695
|
|
|
$form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' >"; |
|
696
|
|
|
|
|
697
|
|
|
$form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
698
|
|
|
|
|
699
|
|
|
$optionsForum = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums |
|
700
|
|
|
$isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
701
|
|
|
$form .= '<br> <select name="options[]" multiple="multiple">'; |
|
702
|
|
|
$form .= '<option value="0" '; |
|
703
|
|
|
if ($isAll) { |
|
704
|
|
|
$form .= ' selected'; |
|
705
|
|
|
} |
|
706
|
|
|
$form .= '>' . _ALL . '</option>'; |
|
707
|
|
|
$form .= newbbForumSelectBox($optionsForum); |
|
708
|
|
|
$form .= '</select><br>'; |
|
709
|
|
|
|
|
710
|
|
|
return $form; |
|
711
|
|
|
} |
|
712
|
|
|
|
|
713
|
|
|
/** |
|
714
|
|
|
* @param $options |
|
715
|
|
|
* @return string |
|
716
|
|
|
*/ |
|
717
|
|
|
function b_newbb_topic_edit($options) |
|
718
|
|
|
{ |
|
719
|
|
|
require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
720
|
|
|
$form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
721
|
|
|
$form .= "<option value='time'"; |
|
722
|
|
|
if ('time' === $options[0]) { |
|
723
|
|
|
$form .= " selected='selected' "; |
|
724
|
|
|
} |
|
725
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_TIME . '</option>'; |
|
726
|
|
|
$form .= "<option value='views'"; |
|
727
|
|
|
if ('views' === $options[0]) { |
|
728
|
|
|
$form .= " selected='selected' "; |
|
729
|
|
|
} |
|
730
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_VIEWS . '</option>'; |
|
731
|
|
|
$form .= "<option value='replies'"; |
|
732
|
|
|
if ('replies' === $options[0]) { |
|
733
|
|
|
$form .= " selected='selected' "; |
|
734
|
|
|
} |
|
735
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_REPLIES . '</option>'; |
|
736
|
|
|
$form .= "<option value='digest'"; |
|
737
|
|
|
if ('digest' === $options[0]) { |
|
738
|
|
|
$form .= " selected='selected' "; |
|
739
|
|
|
} |
|
740
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_DIGEST . '</option>'; |
|
741
|
|
|
$form .= "<option value='sticky'"; |
|
742
|
|
|
if ('sticky' === $options[0]) { |
|
743
|
|
|
$form .= " selected='selected' "; |
|
744
|
|
|
} |
|
745
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_STICKY . '</option>'; |
|
746
|
|
|
$form .= '</select>'; |
|
747
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >"; |
|
748
|
|
|
$form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >"; |
|
749
|
|
|
$form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
750
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
751
|
|
|
if (0 == $options[3]) { |
|
752
|
|
|
$form .= ' checked'; |
|
753
|
|
|
} |
|
754
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
755
|
|
|
if (1 == $options[3]) { |
|
756
|
|
|
$form .= ' checked'; |
|
757
|
|
|
} |
|
758
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
759
|
|
|
if (2 == $options[3]) { |
|
760
|
|
|
$form .= ' checked'; |
|
761
|
|
|
} |
|
762
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
763
|
|
|
|
|
764
|
|
|
$form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
765
|
|
|
if (1 == $options[4]) { |
|
766
|
|
|
$form .= ' checked'; |
|
767
|
|
|
} |
|
768
|
|
|
$form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
769
|
|
|
if (0 == $options[4]) { |
|
770
|
|
|
$form .= ' checked'; |
|
771
|
|
|
} |
|
772
|
|
|
$form .= ' >' . _NO; |
|
773
|
|
|
|
|
774
|
|
|
$form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' >"; |
|
775
|
|
|
|
|
776
|
|
|
$form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
777
|
|
|
|
|
778
|
|
|
$optionsForum = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums |
|
779
|
|
|
|
|
780
|
|
|
$isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
781
|
|
|
$form .= '<br> <select name="options[]" multiple="multiple">'; |
|
782
|
|
|
$form .= '<option value="0" '; |
|
783
|
|
|
if ($isAll) { |
|
784
|
|
|
$form .= ' selected="selected"'; |
|
785
|
|
|
} |
|
786
|
|
|
$form .= '>' . _ALL . '</option>'; |
|
787
|
|
|
$form .= newbbForumSelectBox($optionsForum); |
|
788
|
|
|
$form .= '</select><br>'; |
|
789
|
|
|
|
|
790
|
|
|
return $form; |
|
791
|
|
|
} |
|
792
|
|
|
|
|
793
|
|
|
/** |
|
794
|
|
|
* @param $options |
|
795
|
|
|
* @return string |
|
796
|
|
|
*/ |
|
797
|
|
|
function b_newbb_post_edit($options) |
|
798
|
|
|
{ |
|
799
|
|
|
require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
800
|
|
|
$form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
801
|
|
|
$form .= "<option value='title'"; |
|
802
|
|
|
if ('title' === $options[0]) { |
|
803
|
|
|
$form .= " selected='selected' "; |
|
804
|
|
|
} |
|
805
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_TITLE . '</option>'; |
|
806
|
|
|
$form .= "<option value='text'"; |
|
807
|
|
|
if ('text' === $options[0]) { |
|
808
|
|
|
$form .= " selected='selected' "; |
|
809
|
|
|
} |
|
810
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_TEXT . '</option>'; |
|
811
|
|
|
$form .= '</select>'; |
|
812
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >"; |
|
813
|
|
|
$form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >"; |
|
814
|
|
|
$form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
815
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
816
|
|
|
if (0 == $options[3]) { |
|
817
|
|
|
$form .= ' checked'; |
|
818
|
|
|
} |
|
819
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_FULL . "<input type='radio' name='options[3]' value='1'"; |
|
820
|
|
|
if (1 == $options[3]) { |
|
821
|
|
|
$form .= ' checked'; |
|
822
|
|
|
} |
|
823
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='2'"; |
|
824
|
|
|
if (2 == $options[3]) { |
|
825
|
|
|
$form .= ' checked'; |
|
826
|
|
|
} |
|
827
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
828
|
|
|
|
|
829
|
|
|
$form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
830
|
|
|
if (1 == $options[4]) { |
|
831
|
|
|
$form .= ' checked'; |
|
832
|
|
|
} |
|
833
|
|
|
$form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
834
|
|
|
if (0 == $options[4]) { |
|
835
|
|
|
$form .= ' checked'; |
|
836
|
|
|
} |
|
837
|
|
|
$form .= ' >' . _NO; |
|
838
|
|
|
|
|
839
|
|
|
$form .= '<br>' . _MB_NEWBB_TITLE_LENGTH . "<input type='text' name='options[5]' value='" . $options[5] . "' >"; |
|
840
|
|
|
|
|
841
|
|
|
$form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
842
|
|
|
|
|
843
|
|
|
$optionsForum = array_filter(array_slice($options, 6), '\b_newbb_array_filter'); // get allowed forums |
|
844
|
|
|
$isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
845
|
|
|
$form .= '<br> <select name="options[]" multiple="multiple">'; |
|
846
|
|
|
$form .= '<option value="0" '; |
|
847
|
|
|
if ($isAll) { |
|
848
|
|
|
$form .= ' selected="selected"'; |
|
849
|
|
|
} |
|
850
|
|
|
$form .= '>' . _ALL . '</option>'; |
|
851
|
|
|
$form .= newbbForumSelectBox($optionsForum); |
|
852
|
|
|
$form .= '</select><br>'; |
|
853
|
|
|
|
|
854
|
|
|
return $form; |
|
855
|
|
|
} |
|
856
|
|
|
|
|
857
|
|
|
/** |
|
858
|
|
|
* @param $options |
|
859
|
|
|
* @return string |
|
860
|
|
|
*/ |
|
861
|
|
|
function b_newbb_author_edit($options) |
|
862
|
|
|
{ |
|
863
|
|
|
require_once dirname(__DIR__) . '/include/functions.forum.php'; |
|
864
|
|
|
$form = _MB_NEWBB_CRITERIA . "<select name='options[0]'>"; |
|
865
|
|
|
$form .= "<option value='post'"; |
|
866
|
|
|
if ('post' === $options[0]) { |
|
867
|
|
|
$form .= " selected='selected' "; |
|
868
|
|
|
} |
|
869
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_POST . '</option>'; |
|
870
|
|
|
$form .= "<option value='topic'"; |
|
871
|
|
|
if ('topic' === $options[0]) { |
|
872
|
|
|
$form .= " selected='selected' "; |
|
873
|
|
|
} |
|
874
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_TOPIC . '</option>'; |
|
875
|
|
|
$form .= "<option value='digest'"; |
|
876
|
|
|
if ('digest' === $options[0]) { |
|
877
|
|
|
$form .= " selected='selected' "; |
|
878
|
|
|
} |
|
879
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_DIGESTS . '</option>'; |
|
880
|
|
|
$form .= "<option value='sticky'"; |
|
881
|
|
|
if ('sticky' === $options[0]) { |
|
882
|
|
|
$form .= " selected='selected' "; |
|
883
|
|
|
} |
|
884
|
|
|
$form .= '>' . _MB_NEWBB_CRITERIA_STICKYS . '</option>'; |
|
885
|
|
|
$form .= '</select>'; |
|
886
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAY . "<input type='text' name='options[1]' value='" . $options[1] . "' >"; |
|
887
|
|
|
$form .= '<br>' . _MB_NEWBB_TIME . "<input type='text' name='options[2]' value='" . $options[2] . "' >"; |
|
888
|
|
|
$form .= '<br> <small>' . _MB_NEWBB_TIME_DESC . '</small>'; |
|
889
|
|
|
$form .= '<br>' . _MB_NEWBB_DISPLAYMODE . "<input type='radio' name='options[3]' value='0'"; |
|
890
|
|
|
if (0 == $options[3]) { |
|
891
|
|
|
$form .= ' checked'; |
|
892
|
|
|
} |
|
893
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_COMPACT . "<input type='radio' name='options[3]' value='1'"; |
|
894
|
|
|
if (1 == $options[3]) { |
|
895
|
|
|
$form .= ' checked'; |
|
896
|
|
|
} |
|
897
|
|
|
$form .= ' > ' . _MB_NEWBB_DISPLAYMODE_LITE; |
|
898
|
|
|
|
|
899
|
|
|
$form .= '<br>' . _MB_NEWBB_INDEXNAV . '<input type="radio" name="options[4]" value="1"'; |
|
900
|
|
|
if (1 == $options[4]) { |
|
901
|
|
|
$form .= ' checked'; |
|
902
|
|
|
} |
|
903
|
|
|
$form .= ' >' . _YES . '<input type="radio" name="options[4]" value="0"'; |
|
904
|
|
|
if (0 == $options[4]) { |
|
905
|
|
|
$form .= ' checked'; |
|
906
|
|
|
} |
|
907
|
|
|
$form .= ' >' . _NO; |
|
908
|
|
|
|
|
909
|
|
|
$form .= '<br><br>' . _MB_NEWBB_FORUMLIST; |
|
910
|
|
|
|
|
911
|
|
|
$optionsForum = array_filter(array_slice($options, 5), '\b_newbb_array_filter'); // get allowed forums |
|
912
|
|
|
$isAll = (0 === count($optionsForum) || empty($optionsForum[0])); |
|
913
|
|
|
$form .= '<br> <select name="options[]" multiple="multiple">'; |
|
914
|
|
|
$form .= '<option value="0" '; |
|
915
|
|
|
if ($isAll) { |
|
916
|
|
|
$form .= ' selected="selected"'; |
|
917
|
|
|
} |
|
918
|
|
|
$form .= '>' . _ALL . '</option>'; |
|
919
|
|
|
$form .= newbbForumSelectBox($optionsForum); |
|
920
|
|
|
$form .= '</select><br>'; |
|
921
|
|
|
|
|
922
|
|
|
return $form; |
|
923
|
|
|
} |
|
924
|
|
|
|
|
925
|
|
|
/** |
|
926
|
|
|
* @param $options |
|
927
|
|
|
* @return bool |
|
928
|
|
|
*/ |
|
929
|
|
|
function b_newbb_custom($options) |
|
930
|
|
|
{ |
|
931
|
|
|
// if no newbb module block set, we have to include the language file |
|
932
|
|
|
if (is_readable($GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'))) { |
|
933
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/language/' . $GLOBALS['xoopsConfig']['language'] . '/blocks.php'); |
|
934
|
|
|
} else { |
|
935
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/language/english/blocks.php'); |
|
936
|
|
|
} |
|
937
|
|
|
|
|
938
|
|
|
$options = explode('|', $options); |
|
939
|
|
|
$block = b_newbb_show($options); |
|
940
|
|
|
if (count($block['topics']) < 1) { |
|
941
|
|
|
return false; |
|
942
|
|
|
} |
|
943
|
|
|
|
|
944
|
|
|
$tpl = new \XoopsTpl(); |
|
945
|
|
|
$tpl->assign('block', $block); |
|
946
|
|
|
$tpl->display('db:newbb_block.tpl'); |
|
947
|
|
|
} |
|
948
|
|
|
|
|
949
|
|
|
/** |
|
950
|
|
|
* @param $options |
|
951
|
|
|
* @return bool |
|
952
|
|
|
*/ |
|
953
|
|
|
function b_newbb_custom_topic($options) |
|
954
|
|
|
{ |
|
955
|
|
|
/** @var \XoopsModules\Newbb\Helper $helper */ |
|
956
|
|
|
$helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
957
|
|
|
// if no newbb module block set, we have to include the language file |
|
958
|
|
|
$helper->loadLanguage('blocks'); |
|
959
|
|
|
|
|
960
|
|
|
$options = explode('|', $options); |
|
961
|
|
|
$block = b_newbb_topic_show($options); |
|
962
|
|
|
if (count($block['topics']) < 1) { |
|
963
|
|
|
return false; |
|
964
|
|
|
} |
|
965
|
|
|
|
|
966
|
|
|
$tpl = new \XoopsTpl(); |
|
967
|
|
|
$tpl->assign('block', $block); |
|
968
|
|
|
$tpl->display('db:newbb_block_topic.tpl'); |
|
969
|
|
|
} |
|
970
|
|
|
|
|
971
|
|
|
/** |
|
972
|
|
|
* @param $options |
|
973
|
|
|
* @return bool |
|
974
|
|
|
*/ |
|
975
|
|
|
function b_newbb_custom_post($options) |
|
976
|
|
|
{ |
|
977
|
|
|
/** @var \XoopsModules\Newbb\Helper $helper */ |
|
978
|
|
|
$helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
979
|
|
|
// if no newbb module block set, we have to include the language file |
|
980
|
|
|
$helper->loadLanguage('blocks'); |
|
981
|
|
|
|
|
982
|
|
|
$options = explode('|', $options); |
|
983
|
|
|
$block = b_newbb_post_show($options); |
|
984
|
|
|
if (count($block['topics']) < 1) { |
|
985
|
|
|
return false; |
|
986
|
|
|
} |
|
987
|
|
|
|
|
988
|
|
|
$tpl = new \XoopsTpl(); |
|
989
|
|
|
$tpl->assign('block', $block); |
|
990
|
|
|
$tpl->display('db:newbb_block_post.tpl'); |
|
991
|
|
|
} |
|
992
|
|
|
|
|
993
|
|
|
/** |
|
994
|
|
|
* @param $options |
|
995
|
|
|
* @return bool |
|
996
|
|
|
*/ |
|
997
|
|
|
function b_newbb_custom_author($options) |
|
998
|
|
|
{ |
|
999
|
|
|
/** @var \XoopsModules\Newbb\Helper $helper */ |
|
1000
|
|
|
$helper = \XoopsModules\Newbb\Helper::getInstance(); |
|
1001
|
|
|
// if no newbb module block set, we have to include the language file |
|
1002
|
|
|
$helper->loadLanguage('blocks'); |
|
1003
|
|
|
|
|
1004
|
|
|
$options = explode('|', $options); |
|
1005
|
|
|
$block = b_newbb_author_show($options); |
|
1006
|
|
|
if (count($block['authors']) < 1) { |
|
1007
|
|
|
return false; |
|
1008
|
|
|
} |
|
1009
|
|
|
|
|
1010
|
|
|
$tpl = new \XoopsTpl(); |
|
1011
|
|
|
$tpl->assign('block', $block); |
|
1012
|
|
|
$tpl->display('db:newbb_block_author.tpl'); |
|
1013
|
|
|
} |
|
1014
|
|
|
|
|
1015
|
|
|
// irmtfan add local stylesheet and js footer.php |
|
1016
|
|
|
require_once $GLOBALS['xoops']->path('modules/newbb/footer.php'); |
|
1017
|
|
|
|