1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* @package Board3 Portal v2.1 |
5
|
|
|
* @copyright (c) 2013 Board3 Group ( www.board3.de ) |
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace board3\portal\modules; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @package News |
14
|
|
|
*/ |
15
|
|
|
class news extends module_base |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Allowed columns: Just sum up your options (Exp: left + right = 10) |
19
|
|
|
* top 1 |
20
|
|
|
* left 2 |
21
|
|
|
* center 4 |
22
|
|
|
* right 8 |
23
|
|
|
* bottom 16 |
24
|
|
|
*/ |
25
|
|
|
public $columns = 21; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Default modulename |
29
|
|
|
*/ |
30
|
|
|
public $name = 'LATEST_NEWS'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Default module-image: |
34
|
|
|
* file must be in "{T_THEME_PATH}/images/portal/" |
35
|
|
|
*/ |
36
|
|
|
public $image_src = ''; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* module-language file |
40
|
|
|
* file must be in "language/{$user->lang}/mods/portal/" |
41
|
|
|
*/ |
42
|
|
|
public $language = 'portal_news_module'; |
43
|
|
|
|
44
|
|
|
/** @var bool Can include this module multiple times */ |
45
|
|
|
protected $multiple_includes = true; |
46
|
|
|
|
47
|
|
|
/** @var \phpbb\auth\auth */ |
48
|
|
|
protected $auth; |
49
|
|
|
|
50
|
|
|
/** @var \phpbb\cache\service */ |
51
|
|
|
protected $cache; |
52
|
|
|
|
53
|
|
|
/** @var \phpbb\config\config */ |
54
|
|
|
protected $config; |
55
|
|
|
|
56
|
|
|
/** @var \phpbb\db\driver\driver_Interface */ |
57
|
|
|
protected $db; |
58
|
|
|
|
59
|
|
|
/** @var \phpbb\pagination */ |
60
|
|
|
protected $pagination; |
61
|
|
|
|
62
|
|
|
/** @var \board3\portal\includes\modules_helper */ |
63
|
|
|
protected $modules_helper; |
64
|
|
|
|
65
|
|
|
/** @var \phpbb\request\request */ |
66
|
|
|
protected $request; |
67
|
|
|
|
68
|
|
|
/** @var \phpbb\template\template */ |
69
|
|
|
protected $template; |
70
|
|
|
|
71
|
|
|
/** @var string PHP file extension */ |
72
|
|
|
protected $php_ext; |
73
|
|
|
|
74
|
|
|
/** @var string phpBB root path */ |
75
|
|
|
protected $phpbb_root_path; |
76
|
|
|
|
77
|
|
|
/** @var \phpbb\user */ |
78
|
|
|
protected $user; |
79
|
|
|
|
80
|
|
|
/** @var \board3\portal\portal\fetch_posts */ |
81
|
|
|
protected $fetch_posts; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Construct a news object |
85
|
|
|
* |
86
|
|
|
* @param \phpbb\auth\auth $auth phpBB auth |
87
|
|
|
* @param \phpbb\cache\service $cache phpBB cache system |
88
|
|
|
* @param \phpbb\config\config $config phpBB config |
89
|
|
|
* @param \phpbb\db\driver\driver_interface $db phpBB db driver |
90
|
|
|
* @param \phpbb\pagination $pagination phpBB pagination |
91
|
|
|
* @param \board3\portal\includes\modules_helper $modules_helper Portal modules helper |
92
|
|
|
* @param \phpbb\request\request $request phpBB request |
93
|
|
|
* @param \phpbb\template\template $template phpBB template |
94
|
|
|
* @param string $phpbb_root_path phpBB root path |
95
|
|
|
* @param string $phpEx php file extension |
96
|
|
|
* @param \phpbb\user $user phpBB user object |
97
|
|
|
* @param \board3\portal\portal\fetch_posts $fetch_posts Fetch posts object |
98
|
|
|
*/ |
99
|
|
View Code Duplication |
public function __construct($auth, $cache, $config, $db, $pagination, $modules_helper, $request, $template, $phpbb_root_path, $phpEx, $user, $fetch_posts) |
100
|
|
|
{ |
101
|
|
|
$this->auth = $auth; |
102
|
|
|
$this->cache = $cache; |
103
|
|
|
$this->config = $config; |
104
|
|
|
$this->db = $db; |
105
|
|
|
$this->pagination = $pagination; |
106
|
|
|
$this->modules_helper = $modules_helper; |
107
|
|
|
$this->request = $request; |
108
|
|
|
$this->template = $template; |
109
|
|
|
$this->phpbb_root_path = $phpbb_root_path; |
110
|
|
|
$this->php_ext = $phpEx; |
111
|
|
|
$this->user = $user; |
112
|
|
|
$this->fetch_posts = $fetch_posts; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
*/ |
118
|
|
|
public function get_template_center($module_id) |
119
|
|
|
{ |
120
|
|
|
$news = $this->request->variable('news_' . $module_id, -1); |
121
|
|
|
$news = ($news > $this->config['board3_number_of_news_' . $module_id] -1) ? -1 : $news; |
122
|
|
|
$this->user->add_lang('viewforum'); |
123
|
|
|
$start = $this->request->variable('np_' . $module_id, 0); |
124
|
|
|
$start = ($start < 0) ? 0 : $start; |
125
|
|
|
$total_news = 1; |
126
|
|
|
|
127
|
|
|
// Fetch news from portal functions.php with check if "read full" is requested. |
128
|
|
|
$portal_news_length = ($news < 0 && !$this->config['board3_news_style_' . $module_id]) ? $this->config['board3_news_length_' . $module_id] : 0; |
129
|
|
|
$this->fetch_posts->set_module_id($module_id); |
130
|
|
|
$fetch_news = $this->fetch_posts->get_posts( |
131
|
|
|
$this->config['board3_news_forum_' . $module_id], |
132
|
|
|
$this->config['board3_news_permissions_' . $module_id], |
133
|
|
|
$this->config['board3_number_of_news_' . $module_id], |
134
|
|
|
$portal_news_length, |
135
|
|
|
0, |
136
|
|
|
($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', |
137
|
|
|
$start, |
138
|
|
|
(bool) $this->config['board3_news_exclude_' . $module_id] |
139
|
|
|
); |
140
|
|
|
|
141
|
|
|
$topic_icons = false; |
142
|
|
|
if (!empty($fetch_news['topic_icons'])) |
143
|
|
|
{ |
144
|
|
|
$topic_icons = true; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
// Standard news row |
148
|
|
|
$news_row = array( |
149
|
|
|
'S_NEWEST_OR_FIRST' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['JUMP_NEWEST'] : $this->user->lang['JUMP_FIRST'], |
150
|
|
|
'POSTED_BY_TEXT' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['LAST_POST'] : $this->user->lang['POSTED'], |
151
|
|
|
'S_DISPLAY_NEWS_RVS' => ($this->config['board3_show_news_replies_views_' . $module_id]) ? true : false, |
152
|
|
|
'S_TOPIC_ICONS' => $topic_icons, |
153
|
|
|
'MODULE_ID' => $module_id, |
154
|
|
|
); |
155
|
|
|
|
156
|
|
|
// Any news present? If not terminate it here. |
157
|
|
|
if (sizeof($fetch_news) == 0) |
158
|
|
|
{ |
159
|
|
|
// Create standard news row |
160
|
|
|
$this->template->assign_block_vars('news', $news_row); |
161
|
|
|
|
162
|
|
|
$this->template->assign_block_vars('news.news_row', array( |
163
|
|
|
'S_NO_TOPICS' => true, |
164
|
|
|
'S_NOT_LAST' => false, |
165
|
|
|
)); |
166
|
|
|
} |
167
|
|
|
else |
168
|
|
|
{ |
169
|
|
|
// Count number of posts for news archive, considering if permission check is dis- or enabled. |
170
|
|
|
if ($this->config['board3_news_archive_' . $module_id]) |
171
|
|
|
{ |
172
|
|
|
$permissions = $this->config['board3_news_permissions_' . $module_id]; |
173
|
|
|
$forum_from = $this->config['board3_news_forum_' . $module_id]; |
174
|
|
|
|
175
|
|
|
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); |
176
|
|
|
|
177
|
|
|
$str_where = ''; |
178
|
|
|
|
179
|
|
|
// Get disallowed forums |
180
|
|
|
$disallow_access = $this->modules_helper->get_disallowed_forums($permissions); |
181
|
|
|
|
182
|
|
View Code Duplication |
if ($this->config['board3_news_exclude_' . $module_id] == true) |
183
|
|
|
{ |
184
|
|
|
$disallow_access = array_merge($disallow_access, $forum_from); |
185
|
|
|
$forum_from = array(); |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
if (sizeof($forum_from)) |
189
|
|
|
{ |
190
|
|
|
$disallow_access = array_diff($forum_from, $disallow_access); |
191
|
|
|
if (!sizeof($disallow_access)) |
192
|
|
|
{ |
193
|
|
|
return array(); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
foreach ($disallow_access as $acc_id) |
197
|
|
|
{ |
198
|
|
|
$acc_id = (int) $acc_id; |
199
|
|
|
$str_where .= "forum_id = $acc_id OR "; |
200
|
|
|
} |
201
|
|
|
} |
202
|
|
|
else |
203
|
|
|
{ |
204
|
|
|
foreach ($disallow_access as $acc_id) |
205
|
|
|
{ |
206
|
|
|
$acc_id = (int) $acc_id; |
207
|
|
|
$str_where .= "forum_id <> $acc_id AND "; |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; |
212
|
|
|
|
213
|
|
|
$topic_type = ($this->config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL; |
214
|
|
|
|
215
|
|
|
$sql = 'SELECT COUNT(topic_id) AS num_topics |
216
|
|
|
FROM ' . TOPICS_TABLE . ' |
217
|
|
|
WHERE ' . $topic_type . ' |
218
|
|
|
AND topic_visibility = ' . ITEM_APPROVED . ' |
219
|
|
|
AND topic_moved_id = 0 |
220
|
|
|
' . $str_where; |
221
|
|
|
$result = $this->db->sql_query($sql, 30); |
222
|
|
|
$total_news = (int) $this->db->sql_fetchfield('num_topics'); |
223
|
|
|
$this->db->sql_freeresult($result); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
$topic_tracking_info = get_portal_tracking_info($fetch_news); |
227
|
|
|
|
228
|
|
|
// Create pagination if necessary |
229
|
|
|
if ($this->config['board3_news_archive_' . $module_id]) |
230
|
|
|
{ |
231
|
|
|
$pagination = generate_portal_pagination($this->modules_helper->route('board3_portal_controller'), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $module_id); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id]) |
235
|
|
|
{ |
236
|
|
|
$news_row = array_merge($news_row, array( |
237
|
|
|
'NP_PAGINATION' => (!empty($pagination)) ? $pagination : '', |
238
|
|
|
'TOTAL_NEWS' => ($total_news == 1) ? sprintf($this->user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($this->user->lang['VIEW_FORUM_TOPICS'][2], $total_news), |
239
|
|
|
'NP_PAGE_NUMBER' => $this->pagination->on_page($total_news, $this->config['board3_number_of_news_' . $module_id], $start), |
240
|
|
|
)); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
// Create standard news row |
244
|
|
|
$this->template->assign_block_vars('news', $news_row); |
245
|
|
|
|
246
|
|
|
// Show the news overview |
247
|
|
|
if ($news < 0) |
248
|
|
|
{ |
249
|
|
|
$count = $fetch_news['topic_count']; |
250
|
|
|
for ($i = 0; $i < $count; $i++) |
251
|
|
|
{ |
252
|
|
View Code Duplication |
if (isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) |
253
|
|
|
{ |
254
|
|
|
$open_bracket = '[ '; |
255
|
|
|
$close_bracket = ' ]'; |
256
|
|
|
$read_full = $this->user->lang['READ_FULL']; |
257
|
|
|
} |
258
|
|
|
else |
259
|
|
|
{ |
260
|
|
|
$open_bracket = ''; |
261
|
|
|
$close_bracket = ''; |
262
|
|
|
$read_full = ''; |
263
|
|
|
} |
264
|
|
|
// unread? |
265
|
|
|
$forum_id = $fetch_news[$i]['forum_id']; |
266
|
|
|
$topic_id = $fetch_news[$i]['topic_id']; |
267
|
|
|
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; |
268
|
|
|
|
269
|
|
|
$read_full_url = ($this->request->is_set('np_' . $module_id)) ? "np_$module_id=$start&news_$module_id=$i#n_{$module_id}_$i" : "news_$module_id=$i#n_{$module_id}_$i"; |
270
|
|
|
$view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); |
271
|
|
|
|
272
|
|
|
$replies = ($this->auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; |
273
|
|
|
|
274
|
|
View Code Duplication |
switch ($fetch_news[$i]['topic_type']) |
275
|
|
|
{ |
276
|
|
|
case POST_STICKY: |
277
|
|
|
$folder = 'sticky_read'; |
278
|
|
|
$folder_new = 'sticky_unread'; |
279
|
|
|
break; |
280
|
|
|
case POST_ANNOUNCE: |
281
|
|
|
$folder = 'announce_read'; |
282
|
|
|
$folder_new = 'announce_unread'; |
283
|
|
|
break; |
284
|
|
|
default: |
285
|
|
|
$folder = 'topic_read'; |
286
|
|
|
$folder_new = 'topic_unread'; |
287
|
|
|
if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) |
288
|
|
|
{ |
289
|
|
|
$folder .= '_hot'; |
290
|
|
|
$folder_new .= '_hot'; |
291
|
|
|
} |
292
|
|
|
break; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) |
296
|
|
|
{ |
297
|
|
|
$folder .= '_locked'; |
298
|
|
|
$folder_new .= '_locked'; |
299
|
|
|
} |
300
|
|
|
if ($fetch_news[$i]['topic_posted']) |
301
|
|
|
{ |
302
|
|
|
$folder .= '_mine'; |
303
|
|
|
$folder_new .= '_mine'; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
$folder_img = ($unread_topic) ? $folder_new : $folder; |
307
|
|
|
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); |
308
|
|
|
|
309
|
|
|
// Grab icons |
310
|
|
|
$icons = $this->cache->obtain_icons(); |
311
|
|
|
|
312
|
|
|
$this->template->assign_block_vars('news.news_row', array( |
313
|
|
|
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', |
314
|
|
|
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '', |
315
|
|
|
'TITLE' => $fetch_news[$i]['topic_title'], |
316
|
|
|
'POSTER' => $fetch_news[$i]['username'], |
317
|
|
|
'POSTER_FULL' => $fetch_news[$i]['username_full'], |
318
|
|
|
'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], |
319
|
|
|
'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', |
320
|
|
|
'TIME' => $fetch_news[$i]['topic_time'], |
321
|
|
|
'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']), |
322
|
|
|
'TEXT' => $fetch_news[$i]['post_text'], |
323
|
|
|
'REPLIES' => $fetch_news[$i]['topic_replies'], |
324
|
|
|
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], |
325
|
|
|
'N_ID' => $i, |
326
|
|
|
'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), |
327
|
|
|
'TOPIC_IMG_STYLE' => $folder_img, |
328
|
|
|
'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'), |
329
|
|
|
'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], |
330
|
|
|
'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', |
331
|
|
|
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', |
332
|
|
|
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', |
333
|
|
|
'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'), |
334
|
|
|
'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), |
335
|
|
|
'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), |
336
|
|
|
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), |
337
|
|
|
'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'), |
338
|
|
|
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), |
339
|
|
|
'U_READ_FULL' => $this->modules_helper->route('board3_portal_controller') . '?' . $read_full_url, |
340
|
|
|
'L_READ_FULL' => $read_full, |
341
|
|
|
'OPEN' => $open_bracket, |
342
|
|
|
'CLOSE' => $close_bracket, |
343
|
|
|
'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, |
344
|
|
|
'S_POLL' => $fetch_news[$i]['poll'], |
345
|
|
|
'S_UNREAD_INFO' => $unread_topic, |
346
|
|
|
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, |
347
|
|
|
)); |
348
|
|
|
|
349
|
|
|
// Assign pagination |
350
|
|
|
$this->pagination->generate_template_pagination($view_topic_url, 'news.news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1); |
351
|
|
|
|
352
|
|
View Code Duplication |
if (!empty($fetch_news[$i]['attachments'])) |
353
|
|
|
{ |
354
|
|
|
foreach ($fetch_news[$i]['attachments'] as $attachment) |
355
|
|
|
{ |
356
|
|
|
$this->template->assign_block_vars('news.news_row.attachment', array( |
357
|
|
|
'DISPLAY_ATTACHMENT' => $attachment) |
358
|
|
|
); |
359
|
|
|
} |
360
|
|
|
} |
361
|
|
|
} |
362
|
|
|
} |
363
|
|
|
// Show "read full" page |
364
|
|
|
else |
365
|
|
|
{ |
366
|
|
|
$i = $news; |
367
|
|
|
$forum_id = $fetch_news[$i]['forum_id']; |
368
|
|
|
$topic_id = $fetch_news[$i]['topic_id']; |
369
|
|
|
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; |
370
|
|
|
$open_bracket = '[ '; |
371
|
|
|
$close_bracket = ' ]'; |
372
|
|
|
$read_full = $this->user->lang['BACK']; |
373
|
|
|
|
374
|
|
|
$read_full_url = ($this->request->is_set('np_' . $module_id)) ? $this->modules_helper->route('board3_portal_controller') . "?np_$module_id=$start#n_{$module_id}_$i" : $this->modules_helper->route('board3_portal_controller') . "#n_{$module_id}_$i"; |
375
|
|
|
$view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); |
376
|
|
|
|
377
|
|
|
$this->template->assign_block_vars('news.news_row', array( |
378
|
|
|
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', |
379
|
|
|
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '', |
380
|
|
|
'TITLE' => $fetch_news[$i]['topic_title'], |
381
|
|
|
'POSTER' => $fetch_news[$i]['username'], |
382
|
|
|
'POSTER_FULL' => $fetch_news[$i]['username_full'], |
383
|
|
|
'TIME' => $fetch_news[$i]['topic_time'], |
384
|
|
|
'TEXT' => $fetch_news[$i]['post_text'], |
385
|
|
|
'REPLIES' => $fetch_news[$i]['topic_replies'], |
386
|
|
|
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], |
387
|
|
|
'N_ID' => $i, |
388
|
|
|
'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), |
389
|
|
|
'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), |
390
|
|
|
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), |
391
|
|
|
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), |
392
|
|
|
'S_POLL' => $fetch_news[$i]['poll'], |
393
|
|
|
'S_UNREAD_INFO' => $unread_topic, |
394
|
|
|
'U_READ_FULL' => $read_full_url, |
395
|
|
|
'L_READ_FULL' => $read_full, |
396
|
|
|
'OPEN' => $open_bracket, |
397
|
|
|
'CLOSE' => $close_bracket, |
398
|
|
|
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, |
399
|
|
|
)); |
400
|
|
|
|
401
|
|
|
$this->pagination->generate_template_pagination($view_topic_url, 'news.news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1); |
402
|
|
|
|
403
|
|
View Code Duplication |
if (!empty($fetch_news[$i]['attachments'])) |
404
|
|
|
{ |
405
|
|
|
foreach ($fetch_news[$i]['attachments'] as $attachment) |
406
|
|
|
{ |
407
|
|
|
$this->template->assign_block_vars('news.news_row.attachment', array( |
408
|
|
|
'DISPLAY_ATTACHMENT' => $attachment) |
409
|
|
|
); |
410
|
|
|
} |
411
|
|
|
} |
412
|
|
|
} |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
$this->template->assign_vars(array( |
416
|
|
|
'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), |
417
|
|
|
'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), |
418
|
|
|
'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'), |
419
|
|
|
)); |
420
|
|
|
|
421
|
|
|
if ($this->config['board3_news_style_' . $module_id]) |
422
|
|
|
{ |
423
|
|
|
return 'news_compact_center.html'; |
424
|
|
|
} |
425
|
|
|
else |
426
|
|
|
{ |
427
|
|
|
return 'news_center.html'; |
428
|
|
|
} |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* {@inheritdoc} |
433
|
|
|
*/ |
434
|
|
|
public function get_template_acp($module_id) |
435
|
|
|
{ |
436
|
|
|
return array( |
437
|
|
|
'title' => 'ACP_PORTAL_NEWS_SETTINGS', |
438
|
|
|
'vars' => array( |
439
|
|
|
'legend1' => 'ACP_PORTAL_NEWS_SETTINGS', |
440
|
|
|
'board3_news_style_' . $module_id => array('lang' => 'PORTAL_NEWS_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
441
|
|
|
'board3_show_all_news_' . $module_id => array('lang' => 'PORTAL_SHOW_ALL_NEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
442
|
|
|
'board3_number_of_news_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_NEWS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), |
443
|
|
|
'board3_news_length_' . $module_id => array('lang' => 'PORTAL_NEWS_LENGTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), |
444
|
|
|
'board3_news_forum_' . $module_id => array('lang' => 'PORTAL_NEWS_FORUM', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => array('board3.portal.modules_helper', 'generate_forum_select'), 'submit' => array('board3.portal.modules_helper', 'store_selected_forums')), |
445
|
|
|
'board3_news_exclude_' . $module_id => array('lang' => 'PORTAL_NEWS_EXCLUDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
446
|
|
|
'board3_news_show_last_' . $module_id => array('lang' => 'PORTAL_NEWS_SHOW_LAST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
447
|
|
|
'board3_news_archive_' . $module_id => array('lang' => 'PORTAL_NEWS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
448
|
|
|
'board3_news_permissions_' . $module_id => array('lang' => 'PORTAL_NEWS_PERMISSIONS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
449
|
|
|
'board3_show_news_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
450
|
|
|
) |
451
|
|
|
); |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* {@inheritdoc} |
456
|
|
|
*/ |
457
|
|
|
public function install($module_id) |
458
|
|
|
{ |
459
|
|
|
$this->config->set('board3_news_length_' . $module_id, 250); |
460
|
|
|
$this->config->set('board3_news_forum_' . $module_id, ''); |
461
|
|
|
$this->config->set('board3_news_permissions_' . $module_id, 1); |
462
|
|
|
$this->config->set('board3_number_of_news_' . $module_id, 5); |
463
|
|
|
$this->config->set('board3_show_all_news_' . $module_id, 1); |
464
|
|
|
$this->config->set('board3_news_exclude_' . $module_id, 0); |
465
|
|
|
$this->config->set('board3_news_archive_' . $module_id, 1); |
466
|
|
|
$this->config->set('board3_news_show_last_' . $module_id, 0); |
467
|
|
|
$this->config->set('board3_show_news_replies_views_' . $module_id, 1); |
468
|
|
|
$this->config->set('board3_news_style_' . $module_id, 1); |
469
|
|
|
return true; |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
/** |
473
|
|
|
* {@inheritdoc} |
474
|
|
|
*/ |
475
|
|
|
public function uninstall($module_id, $db) |
476
|
|
|
{ |
477
|
|
|
$del_config = array( |
478
|
|
|
'board3_news_length_' . $module_id, |
479
|
|
|
'board3_news_forum_' . $module_id, |
480
|
|
|
'board3_news_permissions_' . $module_id, |
481
|
|
|
'board3_number_of_news_' . $module_id, |
482
|
|
|
'board3_show_all_news_' . $module_id, |
483
|
|
|
'board3_news_exclude_' . $module_id, |
484
|
|
|
'board3_news_archive_' . $module_id, |
485
|
|
|
'board3_news_show_last_' . $module_id, |
486
|
|
|
'board3_show_news_replies_views_' . $module_id, |
487
|
|
|
'board3_news_style_' . $module_id, |
488
|
|
|
); |
489
|
|
|
$sql = 'DELETE FROM ' . CONFIG_TABLE . ' |
490
|
|
|
WHERE ' . $db->sql_in_set('config_name', $del_config); |
491
|
|
|
return $db->sql_query($sql); |
492
|
|
|
} |
493
|
|
|
} |
494
|
|
|
|