5
* @version $Id: ucp_main.php,v 1.91 2007/10/05 14:36:33 acydburn Exp $
6
* @copyright (c) 2005 phpBB Group
7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14
if (!defined('IN_PHPBB'))
29
function ucp_main(&$p_master)
31
$this->p_master = &$p_master;
34
function main($id, $mode)
36
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
42
$user->add_lang('memberlist');
44
$sql_from = TOPICS_TABLE . ' t ';
47
if ($config['load_db_track'])
49
$sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.topic_id = t.topic_id
50
AND tp.user_id = ' . $user->data['user_id'] . ')';
51
$sql_select .= ', tp.topic_posted';
54
if ($config['load_db_lastread'])
56
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id
57
AND tt.user_id = ' . $user->data['user_id'] . ')';
58
$sql_select .= ', tt.mark_time';
61
$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
62
$folder = 'global_read';
63
$folder_new = 'global_unread';
65
// Get cleaned up list... return only those forums not having the f_read permission
66
$forum_ary = $auth->acl_getf('!f_read', true);
67
$forum_ary = array_unique(array_keys($forum_ary));
69
// Determine first forum the user is able to read into - for global announcement link
70
$sql = 'SELECT forum_id
71
FROM ' . FORUMS_TABLE . '
72
WHERE forum_type = ' . FORUM_POST;
74
if (sizeof($forum_ary))
76
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
78
$result = $db->sql_query_limit($sql, 1);
79
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
80
$db->sql_freeresult($result);
82
$sql = "SELECT t.* $sql_select
85
AND t.topic_type = " . POST_GLOBAL . '
86
ORDER BY t.topic_last_post_time DESC';
88
$topic_list = $rowset = array();
89
// If the user can't see any forums, he can't read any posts because fid of 0 is invalid
92
$result = $db->sql_query($sql);
94
while ($row = $db->sql_fetchrow($result))
96
$topic_list[] = $row['topic_id'];
97
$rowset[$row['topic_id']] = $row;
99
$db->sql_freeresult($result);
102
$topic_tracking_info = array();
103
if ($config['load_db_lastread'])
105
$topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list);
109
$topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list);
112
foreach ($topic_list as $topic_id)
114
$row = &$rowset[$topic_id];
116
$forum_id = $row['forum_id'];
117
$topic_id = $row['topic_id'];
119
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
121
$folder_img = ($unread_topic) ? $folder_new : $folder;
122
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
124
if ($row['topic_status'] == ITEM_LOCKED)
126
$folder_img .= '_locked';
130
if (!empty($row['topic_posted']) && $row['topic_posted'])
132
$folder_img .= '_mine';
135
$template->assign_block_vars('topicrow', array(
136
'FORUM_ID' => $forum_id,
137
'TOPIC_ID' => $topic_id,
138
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
139
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
140
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
141
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
142
'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']),
143
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
144
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
145
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
146
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
147
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
148
'TOPIC_TITLE' => censor_text($row['topic_title']),
149
'TOPIC_TYPE' => $topic_type,
151
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
152
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
153
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', '') : '',
155
'S_USER_POSTED' => (!empty($row['topic_posted']) && $row['topic_posted']) ? true : false,
156
'S_UNREAD' => $unread_topic,
158
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
159
'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
160
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
161
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&view=unread") . '#unread',
162
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id"))
166
if ($config['load_user_activity'])
168
if (!function_exists('display_user_activity'))
170
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
172
display_user_activity($user->data);
175
// Do the relevant calculations
176
$memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400));
177
$posts_per_day = $user->data['user_posts'] / $memberdays;
178
$percentage = ($config['num_posts']) ? min(100, ($user->data['user_posts'] / $config['num_posts']) * 100) : 0;
180
$template->assign_vars(array(
181
'USER_COLOR' => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '',
182
'JOINED' => $user->format_date($user->data['user_regdate']),
183
'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
184
'WARNINGS' => ($user->data['user_warnings']) ? $user->data['user_warnings'] : 0,
185
'POSTS' => ($user->data['user_posts']) ? $user->data['user_posts'] : 0,
186
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
187
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
189
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
190
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
192
// 'S_GROUP_OPTIONS' => $group_options,
194
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user->data['user_id'] . '&sr=posts') : '',
201
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
203
$user->add_lang('viewforum');
205
add_form_key('ucp_front_subscribed');
207
$unwatch = (isset($_POST['unwatch'])) ? true : false;
211
if (check_form_key('ucp_front_subscribed'))
213
$forums = array_keys(request_var('f', array(0 => 0)));
214
$topics = array_keys(request_var('t', array(0 => 0)));
217
if (sizeof($forums) || sizeof($topics))
222
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . '
223
WHERE ' . $db->sql_in_set('forum_id', $forums) . '
224
AND user_id = ' . $user->data['user_id'];
225
$db->sql_query($sql);
227
$l_unwatch .= '_FORUMS';
232
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
233
WHERE ' . $db->sql_in_set('topic_id', $topics) . '
234
AND user_id = ' . $user->data['user_id'];
235
$db->sql_query($sql);
237
$l_unwatch .= '_TOPICS';
239
$msg = $user->lang['UNWATCHED' . $l_unwatch];
245
$msg = $user->lang['FORM_INVALID'];
247
$message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=subscribed") . '">', '</a>');
248
meta_refresh(3, append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=subscribed"));
249
trigger_error($message);
252
$forbidden_forums = array();
254
if ($config['allow_forum_notify'])
256
$forbidden_forums = $auth->acl_getf('!f_read', true);
257
$forbidden_forums = array_unique(array_keys($forbidden_forums));
263
FORUMS_WATCH_TABLE => 'fw',
267
'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
268
AND f.forum_id = fw.forum_id
269
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true),
271
'ORDER_BY' => 'left_id'
274
if ($config['load_db_lastread'])
276
$sql_array['LEFT_JOIN'] = array(
278
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
279
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'
283
$sql_array['SELECT'] .= ', ft.mark_time ';
287
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
288
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
291
$sql = $db->sql_build_query('SELECT', $sql_array);
292
$result = $db->sql_query($sql);
294
while ($row = $db->sql_fetchrow($result))
296
$forum_id = $row['forum_id'];
298
if ($config['load_db_lastread'])
300
$forum_check = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
304
$forum_check = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
307
$unread_forum = ($row['forum_last_post_time'] > $forum_check) ? true : false;
309
// Which folder should we display?
310
if ($row['forum_status'] == ITEM_LOCKED)
312
$folder_image = ($unread_forum) ? 'forum_unread_locked' : 'forum_read_locked';
313
$folder_alt = 'FORUM_LOCKED';
317
$folder_image = ($unread_forum) ? 'forum_unread' : 'forum_read';
318
$folder_alt = ($unread_forum) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
321
// Create last post link information, if appropriate
322
if ($row['forum_last_post_id'])
324
$last_post_time = $user->format_date($row['forum_last_post_time']);
325
$last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=" . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
329
$last_post_time = $last_post_url = '';
332
$template->assign_block_vars('forumrow', array(
333
'FORUM_ID' => $forum_id,
334
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
335
'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'),
336
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',
337
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
338
'FORUM_NAME' => $row['forum_name'],
339
'LAST_POST_SUBJECT' => $row['forum_last_post_subject'],
340
'LAST_POST_TIME' => $last_post_time,
342
'LAST_POST_AUTHOR' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
343
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
344
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
345
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
347
'U_LAST_POST' => $last_post_url,
348
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
351
$db->sql_freeresult($result);
355
if ($config['allow_topic_notify'])
357
if (empty($forbidden_forums))
359
$forbidden_forums = $auth->acl_getf('!f_read', true);
360
$forbidden_forums = array_unique(array_keys($forbidden_forums));
362
$this->assign_topiclist('subscribed', $forbidden_forums);
365
$template->assign_vars(array(
366
'S_TOPIC_NOTIFY' => $config['allow_topic_notify'],
367
'S_FORUM_NOTIFY' => $config['allow_forum_notify'],
374
if (!$config['allow_bookmarks'])
376
$template->assign_vars(array(
377
'S_NO_DISPLAY_BOOKMARKS' => true)
382
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
384
$user->add_lang('viewforum');
386
if (isset($_POST['unbookmark']))
388
$s_hidden_fields = array('unbookmark' => 1);
389
$topics = (isset($_POST['t'])) ? array_keys(request_var('t', array(0 => 0))) : array();
390
$url = $this->u_action;
392
if (!sizeof($topics))
394
trigger_error('NO_BOOKMARKS_SELECTED');
397
foreach ($topics as $topic_id)
399
$s_hidden_fields['t'][$topic_id] = 1;
402
if (confirm_box(true))
404
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
405
WHERE user_id = ' . $user->data['user_id'] . '
406
AND ' . $db->sql_in_set('topic_id', $topics);
407
$db->sql_query($sql);
409
meta_refresh(3, $url);
410
$message = $user->lang['BOOKMARKS_REMOVED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
411
trigger_error($message);
415
confirm_box(false, 'REMOVE_SELECTED_BOOKMARKS', build_hidden_fields($s_hidden_fields));
418
$forbidden_forums = $auth->acl_getf('!f_read', true);
419
$forbidden_forums = array_unique(array_keys($forbidden_forums));
421
$this->assign_topiclist('bookmarks', $forbidden_forums);
427
$pm_drafts = ($this->p_master->p_name == 'pm') ? true : false;
428
$template->assign_var('S_SHOW_DRAFTS', true);
430
$user->add_lang('posting');
432
$edit = (isset($_REQUEST['edit'])) ? true : false;
433
$submit = (isset($_POST['submit'])) ? true : false;
434
$draft_id = ($edit) ? intval($_REQUEST['edit']) : 0;
435
$delete = (isset($_POST['delete'])) ? true : false;
437
$s_hidden_fields = ($edit) ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : '';
438
$draft_subject = $draft_message = '';
439
add_form_key('ucp_draft');
443
if (check_form_key('ucp_draft'))
445
$drafts = array_keys(request_var('d', array(0 => 0)));
449
$sql = 'DELETE FROM ' . DRAFTS_TABLE . '
450
WHERE ' . $db->sql_in_set('draft_id', $drafts) . '
451
AND user_id = ' . $user->data['user_id'];
452
$db->sql_query($sql);
454
$msg = $user->lang['DRAFTS_DELETED'];
459
$msg = $user->lang['FORM_INVALID'];
461
$message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
462
meta_refresh(3, $this->u_action);
463
trigger_error($message);
466
if ($submit && $edit)
468
$draft_subject = utf8_normalize_nfc(request_var('subject', '', true));
469
$draft_message = utf8_normalize_nfc(request_var('message', '', true));
470
if (check_form_key('ucp_draft'))
472
if ($draft_message && $draft_subject)
475
'draft_subject' => $draft_subject,
476
'draft_message' => $draft_message
479
$sql = 'UPDATE ' . DRAFTS_TABLE . '
480
SET ' . $db->sql_build_array('UPDATE', $draft_row) . "
481
WHERE draft_id = $draft_id
482
AND user_id = " . $user->data['user_id'];
483
$db->sql_query($sql);
485
$message = $user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
487
meta_refresh(3, $this->u_action);
488
trigger_error($message);
492
$template->assign_var('ERROR', ($draft_message == '') ? $user->lang['EMPTY_DRAFT'] : (($draft_subject == '') ? $user->lang['EMPTY_DRAFT_TITLE'] : ''));
497
$template->assign_var('ERROR', $user->lang['FORM_INVALID']);
503
$sql = 'SELECT d.*, f.forum_name
504
FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
505
WHERE d.user_id = ' . $user->data['user_id'] . ' ' .
506
(($edit) ? "AND d.draft_id = $draft_id" : '') . '
507
AND f.forum_id = d.forum_id
508
ORDER BY d.save_time DESC';
512
$sql = 'SELECT * FROM ' . DRAFTS_TABLE . '
513
WHERE user_id = ' . $user->data['user_id'] . ' ' .
514
(($edit) ? "AND draft_id = $draft_id" : '') . '
517
ORDER BY save_time DESC';
519
$result = $db->sql_query($sql);
521
$draftrows = $topic_ids = array();
523
while ($row = $db->sql_fetchrow($result))
525
if ($row['topic_id'])
527
$topic_ids[] = (int) $row['topic_id'];
531
$db->sql_freeresult($result);
533
if (sizeof($topic_ids))
535
$sql = 'SELECT topic_id, forum_id, topic_title
536
FROM ' . TOPICS_TABLE . '
537
WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids));
538
$result = $db->sql_query($sql);
540
while ($row = $db->sql_fetchrow($result))
542
$topic_rows[$row['topic_id']] = $row;
544
$db->sql_freeresult($result);
548
$template->assign_var('S_EDIT_DRAFT', $edit);
551
foreach ($draftrows as $draft)
553
$link_topic = $link_forum = $link_pm = false;
554
$insert_url = $view_url = $title = '';
556
if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id']))
559
$view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id']);
560
$title = $topic_rows[$draft['topic_id']]['topic_title'];
562
$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']);
564
else if ($auth->acl_get('f_read', $draft['forum_id']))
567
$view_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $draft['forum_id']);
568
$title = $draft['forum_name'];
570
$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']);
575
$insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d=" . $draft['draft_id']);
578
$template_row = array(
579
'DATE' => $user->format_date($draft['save_time']),
580
'DRAFT_MESSAGE' => ($submit) ? $draft_message : $draft['draft_message'],
581
'DRAFT_SUBJECT' => ($submit) ? $draft_subject : $draft['draft_subject'],
584
'DRAFT_ID' => $draft['draft_id'],
585
'FORUM_ID' => $draft['forum_id'],
586
'TOPIC_ID' => $draft['topic_id'],
588
'U_VIEW' => $view_url,
589
'U_VIEW_EDIT' => $this->u_action . '&edit=' . $draft['draft_id'],
590
'U_INSERT' => $insert_url,
592
'S_LINK_TOPIC' => $link_topic,
593
'S_LINK_FORUM' => $link_forum,
594
'S_LINK_PM' => $link_pm,
595
'S_HIDDEN_FIELDS' => $s_hidden_fields
599
($edit) ? $template->assign_vars($template_row) : $template->assign_block_vars('draftrow', $template_row);
604
$template->assign_var('S_DRAFT_ROWS', $row_count);
611
$template->assign_vars(array(
612
'L_TITLE' => $user->lang['UCP_MAIN_' . strtoupper($mode)],
614
'S_DISPLAY_MARK_ALL' => ($mode == 'watched' || ($mode == 'drafts' && !isset($_GET['edit']))) ? true : false,
615
'S_HIDDEN_FIELDS' => (isset($s_hidden_fields)) ? $s_hidden_fields : '',
616
'S_UCP_ACTION' => $this->u_action,
618
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
619
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
622
// Set desired template
623
$this->tpl_name = 'ucp_main_' . $mode;
624
$this->page_title = 'UCP_MAIN_' . strtoupper($mode);
628
* Build and assign topiclist for bookmarks/subscribed topics
630
function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array())
632
global $user, $db, $template, $config, $auth, $phpbb_root_path, $phpEx;
634
$table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE;
635
$start = request_var('start', 0);
638
'SELECT' => 'COUNT(t.topic_id) as topics_count',
645
'WHERE' => 'i.topic_id = t.topic_id
646
AND i.user_id = ' . $user->data['user_id'] . '
647
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
649
$sql = $db->sql_build_query('SELECT', $sql_array);
650
$result = $db->sql_query($sql);
651
$topics_count = (int) $db->sql_fetchfield('topics_count');
652
$db->sql_freeresult($result);
656
$template->assign_vars(array(
657
'PAGINATION' => generate_pagination($this->u_action, $topics_count, $config['topics_per_page'], $start),
658
'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start),
659
'TOTAL_TOPICS' => ($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count))
663
if ($mode == 'subscribed')
666
'SELECT' => 't.*, f.forum_name',
669
TOPICS_WATCH_TABLE => 'tw',
673
'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . '
674
AND t.topic_id = tw.topic_id
675
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
678
'ORDER_BY' => 't.topic_last_post_time DESC'
681
$sql_array['LEFT_JOIN'] = array();
686
'SELECT' => 't.*, f.forum_name, b.topic_id as b_topic_id',
689
BOOKMARKS_TABLE => 'b',
692
'WHERE' => 'b.user_id = ' . $user->data['user_id'] . '
693
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true),
695
'ORDER_BY' => 't.topic_last_post_time DESC'
698
$sql_array['LEFT_JOIN'] = array();
699
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'b.topic_id = t.topic_id');
702
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id');
704
if ($config['load_db_lastread'])
706
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']);
707
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']);
708
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time AS forum_mark_time';
711
if ($config['load_db_track'])
713
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']);
714
$sql_array['SELECT'] .= ', tp.topic_posted';
717
$sql = $db->sql_build_query('SELECT', $sql_array);
718
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
720
$topic_list = $topic_forum_list = $global_announce_list = $rowset = array();
721
while ($row = $db->sql_fetchrow($result))
723
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
725
$topic_list[] = $topic_id;
726
$rowset[$topic_id] = $row;
728
$topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread']) ? $row['forum_mark_time'] : 0;
729
$topic_forum_list[$row['forum_id']]['topics'][] = $topic_id;
731
if ($row['topic_type'] == POST_GLOBAL)
733
$global_announce_list[] = $topic_id;
736
$db->sql_freeresult($result);
738
$topic_tracking_info = array();
739
if ($config['load_db_lastread'])
741
foreach ($topic_forum_list as $f_id => $topic_row)
743
$topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time']), ($f_id == 0) ? $global_announce_list : false);
748
foreach ($topic_forum_list as $f_id => $topic_row)
750
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list);
754
foreach ($topic_list as $topic_id)
756
$row = &$rowset[$topic_id];
758
$forum_id = $row['forum_id'];
759
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
761
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
764
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
766
if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id']))
768
$topic_id = $row['topic_moved_id'];
771
// Get folder img, topic status/type related information
772
$folder_img = $folder_alt = $topic_type = '';
773
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
775
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id");
777
// Send vars to template
778
$template->assign_block_vars('topicrow', array(
779
'FORUM_ID' => $forum_id,
780
'TOPIC_ID' => $topic_id,
781
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
782
'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
783
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
784
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
786
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
787
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
788
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
789
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
791
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
792
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
793
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
794
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
796
'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false,
797
'S_GLOBAL_TOPIC' => (!$forum_id) ? true : false,
799
'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&t=$topic_id")),
800
'REPLIES' => $replies,
801
'VIEWS' => $row['topic_views'],
802
'TOPIC_TITLE' => censor_text($row['topic_title']),
803
'TOPIC_TYPE' => $topic_type,
804
'FORUM_NAME' => $row['forum_name'],
806
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
807
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
808
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
809
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
810
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
811
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
813
'S_TOPIC_TYPE' => $row['topic_type'],
814
'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false,
815
'S_UNREAD_TOPIC' => $unread_topic,
817
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread',
818
'U_LAST_POST' => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'],
819
'U_VIEW_TOPIC' => $view_topic_url,
820
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
b'\\ No newline at end of file'