|
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 Modulname |
|
14
|
|
|
*/ |
|
15
|
|
|
class announcements 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 = 'GLOBAL_ANNOUNCEMENTS'; |
|
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_announcements_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\template\template */ |
|
57
|
|
|
protected $template; |
|
58
|
|
|
|
|
59
|
|
|
/** @var \phpbb\db\driver\driver_interface */ |
|
60
|
|
|
protected $db; |
|
61
|
|
|
|
|
62
|
|
|
/** @var \phpbb\pagination */ |
|
63
|
|
|
protected $pagination; |
|
64
|
|
|
|
|
65
|
|
|
/** @var \board3\portal\includes\modules_helper */ |
|
66
|
|
|
protected $modules_helper; |
|
67
|
|
|
|
|
68
|
|
|
/** @var \phpbb\request\request */ |
|
69
|
|
|
protected $request; |
|
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 an announcements object |
|
85
|
|
|
* |
|
86
|
|
|
* @param \phpbb\auth\auth $auth phpBB auth service |
|
87
|
|
|
* @param \phpbb\cache\service $cache phpBB cache driver |
|
88
|
|
|
* @param \phpbb\config\config $config phpBB config |
|
89
|
|
|
* @param \phpbb\template\template $template phpBB template |
|
90
|
|
|
* @param \phpbb\db\driver\driver_interface $db Database driver |
|
91
|
|
|
* @param \phpbb\pagination $pagination phpBB pagination |
|
92
|
|
|
* @param \board3\portal\includes\modules_helper $modules_helper Portal modules helper |
|
93
|
|
|
* @param \phpbb\request\request $request phpBB request |
|
94
|
|
|
* @param string $phpEx php file extension |
|
95
|
|
|
* @param string $phpbb_root_path phpBB root path |
|
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, $template, $db, $pagination, $modules_helper, $request, $phpEx, $phpbb_root_path, $user, $fetch_posts) |
|
100
|
|
|
{ |
|
101
|
|
|
$this->auth = $auth; |
|
102
|
|
|
$this->cache = $cache; |
|
103
|
|
|
$this->config = $config; |
|
104
|
|
|
$this->template = $template; |
|
105
|
|
|
$this->db = $db; |
|
106
|
|
|
$this->pagination = $pagination; |
|
107
|
|
|
$this->modules_helper = $modules_helper; |
|
108
|
|
|
$this->request = $request; |
|
109
|
|
|
$this->php_ext = $phpEx; |
|
110
|
|
|
$this->phpbb_root_path = $phpbb_root_path; |
|
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
|
|
|
$announcement = $this->request->variable('announcement_' . $module_id, -1); |
|
121
|
|
|
$announcement = ($announcement > $this->config['board3_announcements_length_' . $module_id] -1) ? -1 : $announcement; |
|
122
|
|
|
$start = $this->request->variable('ap_' . $module_id, 0); |
|
123
|
|
|
$start = ($start < 0) ? 0 : $start; |
|
124
|
|
|
$total_announcements = 1; |
|
125
|
|
|
|
|
126
|
|
|
// Fetch announcements from portal functions.php with check if "read full" is requested. |
|
127
|
|
|
$portal_announcement_length = ($announcement < 0 && !$this->config['board3_announcements_style_' . $module_id]) ? $this->config['board3_announcements_length_' . $module_id] : 0; |
|
128
|
|
|
$this->fetch_posts->set_module_id($module_id); |
|
129
|
|
|
$fetch_news = $this->fetch_posts->get_posts( |
|
130
|
|
|
$this->config['board3_global_announcements_forum_' . $module_id], |
|
131
|
|
|
$this->config['board3_announcements_permissions_' . $module_id], |
|
132
|
|
|
$this->config['board3_number_of_announcements_' . $module_id], |
|
133
|
|
|
$portal_announcement_length, |
|
134
|
|
|
$this->config['board3_announcements_day_' . $module_id], |
|
135
|
|
|
'announcements', |
|
136
|
|
|
$start, |
|
137
|
|
|
(bool) $this->config['board3_announcements_forum_exclude_' . $module_id] |
|
138
|
|
|
); |
|
139
|
|
|
|
|
140
|
|
|
$topic_icons = false; |
|
141
|
|
|
if (!empty($fetch_news['topic_icons'])) |
|
142
|
|
|
{ |
|
143
|
|
|
$topic_icons = true; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
// Standard announcements row |
|
147
|
|
|
$announcements_row = array( |
|
148
|
|
|
'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), |
|
149
|
|
|
'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), |
|
150
|
|
|
'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'), |
|
151
|
|
|
'S_DISPLAY_ANNOUNCEMENTS_RVS' => ($this->config['board3_show_announcements_replies_views_' . $module_id]) ? true : false, |
|
152
|
|
|
'S_TOPIC_ICONS' => $topic_icons, |
|
153
|
|
|
'MODULE_ID' => $module_id, |
|
154
|
|
|
); |
|
155
|
|
|
|
|
156
|
|
|
// Any announcements present? If not terminate it here. |
|
157
|
|
|
if (sizeof($fetch_news) < 3) |
|
158
|
|
|
{ |
|
159
|
|
|
$this->template->assign_block_vars('announcements', $announcements_row); |
|
160
|
|
|
|
|
161
|
|
|
$this->template->assign_block_vars('announcements.center_row', array( |
|
162
|
|
|
'S_NO_TOPICS' => true, |
|
163
|
|
|
'S_NOT_LAST' => false |
|
164
|
|
|
)); |
|
165
|
|
|
|
|
166
|
|
|
$this->template->assign_var('S_CAN_READ', false); |
|
167
|
|
|
} |
|
168
|
|
|
else |
|
169
|
|
|
{ |
|
170
|
|
|
// Count number of posts for announcements archive, considering if permission check is dis- or enabled. |
|
171
|
|
|
if ($this->config['board3_announcements_archive_' . $module_id]) |
|
172
|
|
|
{ |
|
173
|
|
|
$permissions = $this->config['board3_announcements_permissions_' . $module_id]; |
|
174
|
|
|
$forum_from = $this->config['board3_global_announcements_forum_' . $module_id]; |
|
175
|
|
|
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); |
|
176
|
|
|
|
|
177
|
|
|
$time = ($this->config['board3_announcements_day_' . $module_id] == 0) ? 0 : $this->config['board3_announcements_day_' . $module_id]; |
|
178
|
|
|
$post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400); |
|
179
|
|
|
|
|
180
|
|
|
$str_where = ''; |
|
181
|
|
|
|
|
182
|
|
|
// Get disallowed forums |
|
183
|
|
|
$disallow_access = $this->modules_helper->get_disallowed_forums($permissions); |
|
184
|
|
|
|
|
185
|
|
View Code Duplication |
if ($this->config['board3_announcements_forum_exclude_' . $module_id] == true) |
|
186
|
|
|
{ |
|
187
|
|
|
$disallow_access = array_merge($disallow_access, $forum_from); |
|
188
|
|
|
$forum_from = array(); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
$global_f = 0; |
|
192
|
|
|
|
|
193
|
|
|
if (sizeof($forum_from)) |
|
194
|
|
|
{ |
|
195
|
|
|
$disallow_access = array_diff($forum_from, $disallow_access); |
|
196
|
|
|
if (!sizeof($disallow_access)) |
|
197
|
|
|
{ |
|
198
|
|
|
return array(); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
foreach ($disallow_access as $acc_id) |
|
202
|
|
|
{ |
|
203
|
|
|
$str_where .= 'forum_id = ' . (int) $acc_id . ' OR '; |
|
204
|
|
|
if ($global_f < 1 && $acc_id > 0) |
|
205
|
|
|
{ |
|
206
|
|
|
$global_f = $acc_id; |
|
207
|
|
|
} |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
else |
|
211
|
|
|
{ |
|
212
|
|
|
foreach ($disallow_access as $acc_id) |
|
213
|
|
|
{ |
|
214
|
|
|
$str_where .= 'forum_id <> ' . (int) $acc_id . ' AND '; |
|
215
|
|
|
} |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
$str_where = (strlen($str_where) > 0) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : ''; |
|
219
|
|
|
|
|
220
|
|
|
$sql = 'SELECT COUNT(topic_id) AS num_topics |
|
221
|
|
|
FROM ' . TOPICS_TABLE . ' |
|
222
|
|
|
WHERE ((topic_type = ' . POST_GLOBAL . ') |
|
223
|
|
|
OR topic_type = ' . POST_ANNOUNCE . ') |
|
224
|
|
|
AND topic_visibility = 1 |
|
225
|
|
|
AND topic_moved_id = 0 |
|
226
|
|
|
' . $post_time . ' |
|
227
|
|
|
' . $str_where; |
|
228
|
|
|
$result = $this->db->sql_query($sql, 30); |
|
229
|
|
|
$total_announcements = (int) $this->db->sql_fetchfield('num_topics'); |
|
230
|
|
|
$this->db->sql_freeresult($result); |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
$topic_tracking_info = (get_portal_tracking_info($fetch_news)); |
|
234
|
|
|
|
|
235
|
|
|
if ($this->config['board3_number_of_announcements_' . $module_id] != 0 && $this->config['board3_announcements_archive_' . $module_id]) |
|
236
|
|
|
{ |
|
237
|
|
|
$pagination = generate_portal_pagination($this->modules_helper->route('board3_portal_controller'), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements', $module_id); |
|
238
|
|
|
|
|
239
|
|
|
$announcements_row = array_merge($announcements_row, array( |
|
240
|
|
|
'AP_PAGINATION' => (isset($pagination)) ? $pagination : '', |
|
241
|
|
|
'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $this->user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($this->user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements), |
|
242
|
|
|
'AP_PAGE_NUMBER' => $this->pagination->on_page($total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start), |
|
243
|
|
|
)); |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
// Assign announcements row |
|
247
|
|
|
$this->template->assign_block_vars('announcements', $announcements_row); |
|
248
|
|
|
|
|
249
|
|
|
// Show the announcements overview |
|
250
|
|
|
if ($announcement < 0) |
|
251
|
|
|
{ |
|
252
|
|
|
$count = $fetch_news['topic_count']; |
|
253
|
|
|
for ($i = 0; $i < $count; $i++) |
|
254
|
|
|
{ |
|
255
|
|
View Code Duplication |
if (isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true) |
|
256
|
|
|
{ |
|
257
|
|
|
$open_bracket = '[ '; |
|
258
|
|
|
$close_bracket = ' ]'; |
|
259
|
|
|
$read_full = $this->user->lang['READ_FULL']; |
|
260
|
|
|
} |
|
261
|
|
|
else |
|
262
|
|
|
{ |
|
263
|
|
|
$open_bracket = ''; |
|
264
|
|
|
$close_bracket = ''; |
|
265
|
|
|
$read_full = ''; |
|
266
|
|
|
} |
|
267
|
|
|
// unread? |
|
268
|
|
|
$forum_id = $fetch_news[$i]['forum_id']; |
|
269
|
|
|
$topic_id = $fetch_news[$i]['topic_id']; |
|
270
|
|
|
|
|
271
|
|
|
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; |
|
272
|
|
|
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id; |
|
273
|
|
|
$read_full_url = ($this->request->is_set('ap_' . $module_id)) ? "ap_{$module_id}=$start&announcement_{$module_id}=$i#a_{$module_id}_$i" : "announcement_{$module_id}=$i#a_{$module_id}_$i"; |
|
274
|
|
|
$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); |
|
275
|
|
|
|
|
276
|
|
|
$replies = ($this->auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; |
|
277
|
|
|
|
|
278
|
|
View Code Duplication |
switch ($fetch_news[$i]['topic_type']) |
|
279
|
|
|
{ |
|
280
|
|
|
case POST_GLOBAL: |
|
281
|
|
|
$folder = 'global_read'; |
|
282
|
|
|
$folder_new = 'global_unread'; |
|
283
|
|
|
break; |
|
284
|
|
|
case POST_ANNOUNCE: |
|
285
|
|
|
$folder = 'announce_read'; |
|
286
|
|
|
$folder_new = 'announce_unread'; |
|
287
|
|
|
break; |
|
288
|
|
|
default: |
|
289
|
|
|
$folder = 'topic_read'; |
|
290
|
|
|
$folder_new = 'topic_unread'; |
|
291
|
|
|
if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) |
|
292
|
|
|
{ |
|
293
|
|
|
$folder .= '_hot'; |
|
294
|
|
|
$folder_new .= '_hot'; |
|
295
|
|
|
} |
|
296
|
|
|
break; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) |
|
300
|
|
|
{ |
|
301
|
|
|
$folder .= '_locked'; |
|
302
|
|
|
$folder_new .= '_locked'; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
if ($fetch_news[$i]['topic_posted']) |
|
306
|
|
|
{ |
|
307
|
|
|
$folder .= '_mine'; |
|
308
|
|
|
$folder_new .= '_mine'; |
|
309
|
|
|
} |
|
310
|
|
|
$folder_img = ($unread_topic) ? $folder_new : $folder; |
|
311
|
|
|
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); |
|
312
|
|
|
|
|
313
|
|
|
// Grab icons |
|
314
|
|
|
$icons = $this->cache->obtain_icons(); |
|
315
|
|
|
|
|
316
|
|
|
$this->template->assign_block_vars('announcements.center_row', array( |
|
317
|
|
|
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', |
|
318
|
|
|
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '', |
|
319
|
|
|
'TITLE' => $fetch_news[$i]['topic_title'], |
|
320
|
|
|
'POSTER' => $fetch_news[$i]['username'], |
|
321
|
|
|
'POSTER_FULL' => $fetch_news[$i]['username_full'], |
|
322
|
|
|
'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], |
|
323
|
|
|
'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']) : '', |
|
324
|
|
|
'TIME' => $fetch_news[$i]['topic_time'], |
|
325
|
|
|
'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']), |
|
326
|
|
|
'TEXT' => $fetch_news[$i]['post_text'], |
|
327
|
|
|
'REPLIES' => $fetch_news[$i]['topic_replies'], |
|
328
|
|
|
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], |
|
329
|
|
|
'A_ID' => $i, |
|
330
|
|
|
'TOPIC_IMG_STYLE' => $folder_img, |
|
331
|
|
|
'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), |
|
332
|
|
|
'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'), |
|
333
|
|
|
'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt], |
|
334
|
|
|
'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'), |
|
335
|
|
|
'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', |
|
336
|
|
|
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', |
|
337
|
|
|
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', |
|
338
|
|
|
'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), |
|
339
|
|
|
'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), |
|
340
|
|
|
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), |
|
341
|
|
|
'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'), |
|
342
|
|
|
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), |
|
343
|
|
|
'U_READ_FULL' => $this->modules_helper->route('board3_portal_controller') . '?' . $read_full_url, |
|
344
|
|
|
'L_READ_FULL' => $read_full, |
|
345
|
|
|
'OPEN' => $open_bracket, |
|
346
|
|
|
'CLOSE' => $close_bracket, |
|
347
|
|
|
'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, |
|
348
|
|
|
'S_POLL' => $fetch_news[$i]['poll'], |
|
349
|
|
|
'S_UNREAD_INFO' => $unread_topic, |
|
350
|
|
|
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, |
|
351
|
|
|
)); |
|
352
|
|
|
|
|
353
|
|
|
$this->pagination->generate_template_pagination($view_topic_url, 'announcements.center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true); |
|
354
|
|
|
|
|
355
|
|
View Code Duplication |
if (!empty($fetch_news[$i]['attachments'])) |
|
356
|
|
|
{ |
|
357
|
|
|
foreach ($fetch_news[$i]['attachments'] as $attachment) |
|
358
|
|
|
{ |
|
359
|
|
|
$this->template->assign_block_vars('announcements.center_row.attachment', array( |
|
360
|
|
|
'DISPLAY_ATTACHMENT' => $attachment) |
|
361
|
|
|
); |
|
362
|
|
|
} |
|
363
|
|
|
} |
|
364
|
|
|
} |
|
365
|
|
|
} |
|
366
|
|
|
// Show "read full" page |
|
367
|
|
|
else |
|
368
|
|
|
{ |
|
369
|
|
|
$i = $announcement; |
|
370
|
|
|
|
|
371
|
|
|
/** |
|
372
|
|
|
* redirect to portal page if the specified announcement does not exist |
|
373
|
|
|
* force #top anchor in order to get rid of the #a anchor |
|
374
|
|
|
*/ |
|
375
|
|
|
if (!isset($fetch_news[$i])) |
|
376
|
|
|
{ |
|
377
|
|
|
redirect($this->modules_helper->route('board3_portal_controller') . '#top'); |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
$forum_id = $fetch_news[$i]['forum_id']; |
|
381
|
|
|
$topic_id = $fetch_news[$i]['topic_id']; |
|
382
|
|
|
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); |
|
383
|
|
|
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; |
|
384
|
|
|
$open_bracket = '[ '; |
|
385
|
|
|
$close_bracket = ' ]'; |
|
386
|
|
|
$read_full = $this->user->lang['BACK']; |
|
387
|
|
|
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id; |
|
388
|
|
|
|
|
389
|
|
|
$read_full_url = ($this->request->is_set('ap_' . $module_id)) ? $this->modules_helper->route('board3_portal_controller') . "?ap_{$module_id}=$start#a_{$module_id}_$i" : $this->modules_helper->route('board3_portal_controller') . "#a_{$module_id}_$i"; |
|
390
|
|
|
$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); |
|
391
|
|
|
|
|
392
|
|
|
$this->template->assign_block_vars('announcements.center_row', array( |
|
393
|
|
|
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '', |
|
394
|
|
|
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '', |
|
395
|
|
|
'TITLE' => $fetch_news[$i]['topic_title'], |
|
396
|
|
|
'POSTER' => $fetch_news[$i]['username'], |
|
397
|
|
|
'POSTER_FULL' => $fetch_news[$i]['username_full'], |
|
398
|
|
|
'TIME' => $fetch_news[$i]['topic_time'], |
|
399
|
|
|
'TEXT' => $fetch_news[$i]['post_text'], |
|
400
|
|
|
'REPLIES' => $fetch_news[$i]['topic_replies'], |
|
401
|
|
|
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], |
|
402
|
|
|
'A_ID' => $i, |
|
403
|
|
|
'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']), |
|
404
|
|
|
'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), |
|
405
|
|
|
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), |
|
406
|
|
|
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), |
|
407
|
|
|
'S_POLL' => $fetch_news[$i]['poll'], |
|
408
|
|
|
'S_UNREAD_INFO' => $unread_topic, |
|
409
|
|
|
'U_READ_FULL' => $read_full_url, |
|
410
|
|
|
'L_READ_FULL' => $read_full, |
|
411
|
|
|
'OPEN' => $open_bracket, |
|
412
|
|
|
'CLOSE' => $close_bracket, |
|
413
|
|
|
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, |
|
414
|
|
|
)); |
|
415
|
|
|
|
|
416
|
|
|
$this->pagination->generate_template_pagination($view_topic_url, 'announcements.center_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true); |
|
417
|
|
|
|
|
418
|
|
View Code Duplication |
if (!empty($fetch_news[$i]['attachments'])) |
|
419
|
|
|
{ |
|
420
|
|
|
foreach ($fetch_news[$i]['attachments'] as $attachment) |
|
421
|
|
|
{ |
|
422
|
|
|
$this->template->assign_block_vars('announcements.center_row.attachment', array( |
|
423
|
|
|
'DISPLAY_ATTACHMENT' => $attachment) |
|
424
|
|
|
); |
|
425
|
|
|
} |
|
426
|
|
|
} |
|
427
|
|
|
} |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
if ($this->config['board3_announcements_style_' . $module_id]) |
|
431
|
|
|
{ |
|
432
|
|
|
return 'announcements_center_compact.html'; |
|
433
|
|
|
} |
|
434
|
|
|
else |
|
435
|
|
|
{ |
|
436
|
|
|
return 'announcements_center.html'; |
|
437
|
|
|
} |
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
/** |
|
441
|
|
|
* {@inheritdoc} |
|
442
|
|
|
*/ |
|
443
|
|
|
public function get_template_acp($module_id) |
|
444
|
|
|
{ |
|
445
|
|
|
return array( |
|
446
|
|
|
'title' => 'ACP_PORTAL_ANNOUNCE_SETTINGS', |
|
447
|
|
|
'vars' => array( |
|
448
|
|
|
'legend1' => 'ACP_PORTAL_ANNOUNCE_SETTINGS', |
|
449
|
|
|
'board3_announcements_style_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_STYLE' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
|
450
|
|
|
'board3_number_of_announcements_' . $module_id => array('lang' => 'PORTAL_NUMBER_OF_ANNOUNCEMENTS' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), |
|
451
|
|
|
'board3_announcements_day_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_DAY' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), |
|
452
|
|
|
'board3_announcements_length_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_LENGTH' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), |
|
453
|
|
|
'board3_global_announcements_forum_' . $module_id => array('lang' => 'PORTAL_GLOBAL_ANNOUNCEMENTS_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')), |
|
454
|
|
|
'board3_announcements_forum_exclude_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_FORUM_EXCLUDE', 'validate' => 'string', 'type' => 'radio:yes_no', 'explain' => true), |
|
455
|
|
|
'board3_announcements_archive_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_ARCHIVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
|
456
|
|
|
'board3_announcements_permissions_' . $module_id => array('lang' => 'PORTAL_ANNOUNCEMENTS_PERMISSIONS' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
|
457
|
|
|
'board3_show_announcements_replies_views_' . $module_id => array('lang' => 'PORTAL_SHOW_REPLIES_VIEWS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), |
|
458
|
|
|
), |
|
459
|
|
|
); |
|
460
|
|
|
} |
|
461
|
|
|
|
|
462
|
|
|
/** |
|
463
|
|
|
* {@inheritdoc} |
|
464
|
|
|
*/ |
|
465
|
|
|
public function install($module_id) |
|
466
|
|
|
{ |
|
467
|
|
|
$this->config->set('board3_announcements_style_' . $module_id, 0); |
|
468
|
|
|
$this->config->set('board3_number_of_announcements_' . $module_id, 1); |
|
469
|
|
|
$this->config->set('board3_announcements_day_' . $module_id, 0); |
|
470
|
|
|
$this->config->set('board3_announcements_length_' . $module_id, 200); |
|
471
|
|
|
$this->config->set('board3_global_announcements_forum_' . $module_id, ''); |
|
472
|
|
|
$this->config->set('board3_announcements_forum_exclude_' . $module_id, 0); |
|
473
|
|
|
$this->config->set('board3_announcements_archive_' . $module_id, 1); |
|
474
|
|
|
$this->config->set('board3_announcements_permissions_' . $module_id, 1); |
|
475
|
|
|
$this->config->set('board3_show_announcements_replies_views_' . $module_id, 1); |
|
476
|
|
|
|
|
477
|
|
|
return true; |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
/** |
|
481
|
|
|
* {@inheritdoc} |
|
482
|
|
|
*/ |
|
483
|
|
|
public function uninstall($module_id, $db) |
|
484
|
|
|
{ |
|
485
|
|
|
$del_config = array( |
|
486
|
|
|
'board3_announcements_style_' . $module_id, |
|
487
|
|
|
'board3_number_of_announcements_' . $module_id, |
|
488
|
|
|
'board3_announcements_day_' . $module_id, |
|
489
|
|
|
'board3_announcements_length_' . $module_id, |
|
490
|
|
|
'board3_global_announcements_forum_' . $module_id, |
|
491
|
|
|
'board3_announcements_forum_exclude_' . $module_id, |
|
492
|
|
|
'board3_announcements_archive_' . $module_id, |
|
493
|
|
|
'board3_announcements_permissions_' . $module_id, |
|
494
|
|
|
'board3_show_announcements_replies_views_' . $module_id, |
|
495
|
|
|
); |
|
496
|
|
|
$sql = 'DELETE FROM ' . CONFIG_TABLE . ' |
|
497
|
|
|
WHERE ' . $db->sql_in_set('config_name', $del_config); |
|
498
|
|
|
return $db->sql_query($sql); |
|
499
|
|
|
} |
|
500
|
|
|
} |
|
501
|
|
|
|