|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package ucp
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
if (!defined('IN_PHPBB'))
|
|
indvdum@0
|
15 |
{
|
|
indvdum@0
|
16 |
exit;
|
|
indvdum@0
|
17 |
}
|
|
indvdum@0
|
18 |
|
|
indvdum@0
|
19 |
/**
|
|
indvdum@0
|
20 |
* ucp_main
|
|
indvdum@0
|
21 |
* UCP Front Panel
|
|
indvdum@0
|
22 |
* @package ucp
|
|
indvdum@0
|
23 |
*/
|
|
indvdum@0
|
24 |
class ucp_main
|
|
indvdum@0
|
25 |
{
|
|
indvdum@0
|
26 |
var $p_master;
|
|
indvdum@0
|
27 |
var $u_action;
|
|
indvdum@0
|
28 |
|
|
indvdum@0
|
29 |
function ucp_main(&$p_master)
|
|
indvdum@0
|
30 |
{
|
|
indvdum@0
|
31 |
$this->p_master = &$p_master;
|
|
indvdum@0
|
32 |
}
|
|
indvdum@0
|
33 |
|
|
indvdum@0
|
34 |
function main($id, $mode)
|
|
indvdum@0
|
35 |
{
|
|
indvdum@0
|
36 |
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
37 |
|
|
indvdum@0
|
38 |
switch ($mode)
|
|
indvdum@0
|
39 |
{
|
|
indvdum@0
|
40 |
case 'front':
|
|
indvdum@0
|
41 |
|
|
indvdum@0
|
42 |
$user->add_lang('memberlist');
|
|
indvdum@0
|
43 |
|
|
indvdum@0
|
44 |
$sql_from = TOPICS_TABLE . ' t ';
|
|
indvdum@0
|
45 |
$sql_select = '';
|
|
indvdum@0
|
46 |
|
|
indvdum@0
|
47 |
if ($config['load_db_track'])
|
|
indvdum@0
|
48 |
{
|
|
indvdum@0
|
49 |
$sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.topic_id = t.topic_id
|
|
indvdum@0
|
50 |
AND tp.user_id = ' . $user->data['user_id'] . ')';
|
|
indvdum@0
|
51 |
$sql_select .= ', tp.topic_posted';
|
|
indvdum@0
|
52 |
}
|
|
indvdum@0
|
53 |
|
|
indvdum@0
|
54 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
55 |
{
|
|
indvdum@0
|
56 |
$sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id
|
|
indvdum@0
|
57 |
AND tt.user_id = ' . $user->data['user_id'] . ')';
|
|
indvdum@0
|
58 |
$sql_select .= ', tt.mark_time';
|
|
indvdum@0
|
59 |
}
|
|
indvdum@0
|
60 |
|
|
indvdum@0
|
61 |
$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
|
|
indvdum@0
|
62 |
$folder = 'global_read';
|
|
indvdum@0
|
63 |
$folder_new = 'global_unread';
|
|
indvdum@0
|
64 |
|
|
indvdum@0
|
65 |
// Get cleaned up list... return only those forums not having the f_read permission
|
|
indvdum@0
|
66 |
$forum_ary = $auth->acl_getf('!f_read', true);
|
|
indvdum@0
|
67 |
$forum_ary = array_unique(array_keys($forum_ary));
|
|
indvdum@0
|
68 |
|
|
indvdum@0
|
69 |
// Determine first forum the user is able to read into - for global announcement link
|
|
indvdum@0
|
70 |
$sql = 'SELECT forum_id
|
|
indvdum@0
|
71 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
72 |
WHERE forum_type = ' . FORUM_POST;
|
|
indvdum@0
|
73 |
|
|
indvdum@0
|
74 |
if (sizeof($forum_ary))
|
|
indvdum@0
|
75 |
{
|
|
indvdum@0
|
76 |
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
|
|
indvdum@0
|
77 |
}
|
|
indvdum@0
|
78 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
79 |
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
|
|
indvdum@0
|
80 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
81 |
|
|
indvdum@0
|
82 |
$sql = "SELECT t.* $sql_select
|
|
indvdum@0
|
83 |
FROM $sql_from
|
|
indvdum@0
|
84 |
WHERE t.forum_id = 0
|
|
indvdum@0
|
85 |
AND t.topic_type = " . POST_GLOBAL . '
|
|
indvdum@0
|
86 |
ORDER BY t.topic_last_post_time DESC';
|
|
indvdum@0
|
87 |
|
|
indvdum@0
|
88 |
$topic_list = $rowset = array();
|
|
indvdum@0
|
89 |
// If the user can't see any forums, he can't read any posts because fid of 0 is invalid
|
|
indvdum@0
|
90 |
if ($g_forum_id)
|
|
indvdum@0
|
91 |
{
|
|
indvdum@0
|
92 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
93 |
|
|
indvdum@0
|
94 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
95 |
{
|
|
indvdum@0
|
96 |
$topic_list[] = $row['topic_id'];
|
|
indvdum@0
|
97 |
$rowset[$row['topic_id']] = $row;
|
|
indvdum@0
|
98 |
}
|
|
indvdum@0
|
99 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
100 |
}
|
|
indvdum@0
|
101 |
|
|
indvdum@0
|
102 |
$topic_tracking_info = array();
|
|
indvdum@0
|
103 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
104 |
{
|
|
indvdum@0
|
105 |
$topic_tracking_info = get_topic_tracking(0, $topic_list, $rowset, false, $topic_list);
|
|
indvdum@0
|
106 |
}
|
|
indvdum@0
|
107 |
else
|
|
indvdum@0
|
108 |
{
|
|
indvdum@0
|
109 |
$topic_tracking_info = get_complete_topic_tracking(0, $topic_list, $topic_list);
|
|
indvdum@0
|
110 |
}
|
|
indvdum@0
|
111 |
|
|
indvdum@0
|
112 |
foreach ($topic_list as $topic_id)
|
|
indvdum@0
|
113 |
{
|
|
indvdum@0
|
114 |
$row = &$rowset[$topic_id];
|
|
indvdum@0
|
115 |
|
|
indvdum@0
|
116 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
117 |
$topic_id = $row['topic_id'];
|
|
indvdum@0
|
118 |
|
|
indvdum@0
|
119 |
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
|
indvdum@0
|
120 |
|
|
indvdum@0
|
121 |
$folder_img = ($unread_topic) ? $folder_new : $folder;
|
|
indvdum@0
|
122 |
$folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS');
|
|
indvdum@0
|
123 |
|
|
indvdum@0
|
124 |
if ($row['topic_status'] == ITEM_LOCKED)
|
|
indvdum@0
|
125 |
{
|
|
indvdum@0
|
126 |
$folder_img .= '_locked';
|
|
indvdum@0
|
127 |
}
|
|
indvdum@0
|
128 |
|
|
indvdum@0
|
129 |
// Posted image?
|
|
indvdum@0
|
130 |
if (!empty($row['topic_posted']) && $row['topic_posted'])
|
|
indvdum@0
|
131 |
{
|
|
indvdum@0
|
132 |
$folder_img .= '_mine';
|
|
indvdum@0
|
133 |
}
|
|
indvdum@0
|
134 |
|
|
indvdum@0
|
135 |
$template->assign_block_vars('topicrow', array(
|
|
indvdum@0
|
136 |
'FORUM_ID' => $forum_id,
|
|
indvdum@0
|
137 |
'TOPIC_ID' => $topic_id,
|
|
indvdum@0
|
138 |
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
139 |
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
140 |
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
141 |
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
|
indvdum@0
|
142 |
'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']),
|
|
indvdum@0
|
143 |
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
|
indvdum@0
|
144 |
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
|
indvdum@0
|
145 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
146 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
147 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
148 |
'TOPIC_TITLE' => censor_text($row['topic_title']),
|
|
indvdum@0
|
149 |
'TOPIC_TYPE' => $topic_type,
|
|
indvdum@0
|
150 |
|
|
indvdum@0
|
151 |
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
|
indvdum@0
|
152 |
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
|
|
indvdum@0
|
153 |
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', '') : '',
|
|
indvdum@0
|
154 |
|
|
indvdum@0
|
155 |
'S_USER_POSTED' => (!empty($row['topic_posted']) && $row['topic_posted']) ? true : false,
|
|
indvdum@0
|
156 |
'S_UNREAD' => $unread_topic,
|
|
indvdum@0
|
157 |
|
|
indvdum@0
|
158 |
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
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'],
|
|
indvdum@0
|
160 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
161 |
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id&view=unread") . '#unread',
|
|
indvdum@0
|
162 |
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$g_forum_id&t=$topic_id"))
|
|
indvdum@0
|
163 |
);
|
|
indvdum@0
|
164 |
}
|
|
indvdum@0
|
165 |
|
|
indvdum@0
|
166 |
if ($config['load_user_activity'])
|
|
indvdum@0
|
167 |
{
|
|
indvdum@0
|
168 |
if (!function_exists('display_user_activity'))
|
|
indvdum@0
|
169 |
{
|
|
indvdum@0
|
170 |
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
indvdum@0
|
171 |
}
|
|
indvdum@0
|
172 |
display_user_activity($user->data);
|
|
indvdum@0
|
173 |
}
|
|
indvdum@0
|
174 |
|
|
indvdum@0
|
175 |
// Do the relevant calculations
|
|
indvdum@0
|
176 |
$memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400));
|
|
indvdum@0
|
177 |
$posts_per_day = $user->data['user_posts'] / $memberdays;
|
|
indvdum@0
|
178 |
$percentage = ($config['num_posts']) ? min(100, ($user->data['user_posts'] / $config['num_posts']) * 100) : 0;
|
|
indvdum@0
|
179 |
|
|
indvdum@0
|
180 |
$template->assign_vars(array(
|
|
indvdum@0
|
181 |
'USER_COLOR' => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '',
|
|
indvdum@0
|
182 |
'JOINED' => $user->format_date($user->data['user_regdate']),
|
|
indvdum@0
|
183 |
'VISITED' => (empty($last_visit)) ? ' - ' : $user->format_date($last_visit),
|
|
indvdum@0
|
184 |
'WARNINGS' => ($user->data['user_warnings']) ? $user->data['user_warnings'] : 0,
|
|
indvdum@0
|
185 |
'POSTS' => ($user->data['user_posts']) ? $user->data['user_posts'] : 0,
|
|
indvdum@0
|
186 |
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
|
indvdum@0
|
187 |
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
|
indvdum@0
|
188 |
|
|
indvdum@0
|
189 |
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
|
|
indvdum@0
|
190 |
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
|
|
indvdum@0
|
191 |
|
|
indvdum@0
|
192 |
// 'S_GROUP_OPTIONS' => $group_options,
|
|
indvdum@0
|
193 |
|
|
indvdum@0
|
194 |
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user->data['user_id'] . '&sr=posts') : '',
|
|
indvdum@0
|
195 |
));
|
|
indvdum@0
|
196 |
|
|
indvdum@0
|
197 |
break;
|
|
indvdum@0
|
198 |
|
|
indvdum@0
|
199 |
case 'subscribed':
|
|
indvdum@0
|
200 |
|
|
indvdum@0
|
201 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
indvdum@0
|
202 |
|
|
indvdum@0
|
203 |
$user->add_lang('viewforum');
|
|
indvdum@0
|
204 |
|
|
indvdum@0
|
205 |
add_form_key('ucp_front_subscribed');
|
|
indvdum@0
|
206 |
|
|
indvdum@0
|
207 |
$unwatch = (isset($_POST['unwatch'])) ? true : false;
|
|
indvdum@0
|
208 |
|
|
indvdum@0
|
209 |
if ($unwatch)
|
|
indvdum@0
|
210 |
{
|
|
indvdum@0
|
211 |
if (check_form_key('ucp_front_subscribed'))
|
|
indvdum@0
|
212 |
{
|
|
indvdum@0
|
213 |
$forums = array_keys(request_var('f', array(0 => 0)));
|
|
indvdum@0
|
214 |
$topics = array_keys(request_var('t', array(0 => 0)));
|
|
indvdum@0
|
215 |
$msg = '';
|
|
indvdum@0
|
216 |
|
|
indvdum@0
|
217 |
if (sizeof($forums) || sizeof($topics))
|
|
indvdum@0
|
218 |
{
|
|
indvdum@0
|
219 |
$l_unwatch = '';
|
|
indvdum@0
|
220 |
if (sizeof($forums))
|
|
indvdum@0
|
221 |
{
|
|
indvdum@0
|
222 |
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . '
|
|
indvdum@0
|
223 |
WHERE ' . $db->sql_in_set('forum_id', $forums) . '
|
|
indvdum@0
|
224 |
AND user_id = ' . $user->data['user_id'];
|
|
indvdum@0
|
225 |
$db->sql_query($sql);
|
|
indvdum@0
|
226 |
|
|
indvdum@0
|
227 |
$l_unwatch .= '_FORUMS';
|
|
indvdum@0
|
228 |
}
|
|
indvdum@0
|
229 |
|
|
indvdum@0
|
230 |
if (sizeof($topics))
|
|
indvdum@0
|
231 |
{
|
|
indvdum@0
|
232 |
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . '
|
|
indvdum@0
|
233 |
WHERE ' . $db->sql_in_set('topic_id', $topics) . '
|
|
indvdum@0
|
234 |
AND user_id = ' . $user->data['user_id'];
|
|
indvdum@0
|
235 |
$db->sql_query($sql);
|
|
indvdum@0
|
236 |
|
|
indvdum@0
|
237 |
$l_unwatch .= '_TOPICS';
|
|
indvdum@0
|
238 |
}
|
|
indvdum@0
|
239 |
$msg = $user->lang['UNWATCHED' . $l_unwatch];
|
|
indvdum@0
|
240 |
}
|
|
indvdum@0
|
241 |
else
|
|
indvdum@0
|
242 |
{
|
|
indvdum@0
|
243 |
$msg = $user->lang['NO_WATCHED_SELECTED'];
|
|
indvdum@0
|
244 |
}
|
|
indvdum@0
|
245 |
}
|
|
indvdum@0
|
246 |
else
|
|
indvdum@0
|
247 |
{
|
|
indvdum@0
|
248 |
$msg = $user->lang['FORM_INVALID'];
|
|
indvdum@0
|
249 |
}
|
|
indvdum@0
|
250 |
$message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=subscribed") . '">', '</a>');
|
|
indvdum@0
|
251 |
meta_refresh(3, append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=subscribed"));
|
|
indvdum@0
|
252 |
trigger_error($message);
|
|
indvdum@0
|
253 |
}
|
|
indvdum@0
|
254 |
|
|
indvdum@0
|
255 |
$forbidden_forums = array();
|
|
indvdum@0
|
256 |
|
|
indvdum@0
|
257 |
if ($config['allow_forum_notify'])
|
|
indvdum@0
|
258 |
{
|
|
indvdum@0
|
259 |
$forbidden_forums = $auth->acl_getf('!f_read', true);
|
|
indvdum@0
|
260 |
$forbidden_forums = array_unique(array_keys($forbidden_forums));
|
|
indvdum@0
|
261 |
|
|
indvdum@0
|
262 |
$sql_array = array(
|
|
indvdum@0
|
263 |
'SELECT' => 'f.*',
|
|
indvdum@0
|
264 |
|
|
indvdum@0
|
265 |
'FROM' => array(
|
|
indvdum@0
|
266 |
FORUMS_WATCH_TABLE => 'fw',
|
|
indvdum@0
|
267 |
FORUMS_TABLE => 'f'
|
|
indvdum@0
|
268 |
),
|
|
indvdum@0
|
269 |
|
|
indvdum@0
|
270 |
'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
271 |
AND f.forum_id = fw.forum_id
|
|
indvdum@0
|
272 |
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true),
|
|
indvdum@0
|
273 |
|
|
indvdum@0
|
274 |
'ORDER_BY' => 'left_id'
|
|
indvdum@0
|
275 |
);
|
|
indvdum@0
|
276 |
|
|
indvdum@0
|
277 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
278 |
{
|
|
indvdum@0
|
279 |
$sql_array['LEFT_JOIN'] = array(
|
|
indvdum@0
|
280 |
array(
|
|
indvdum@0
|
281 |
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
|
indvdum@0
|
282 |
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'
|
|
indvdum@0
|
283 |
)
|
|
indvdum@0
|
284 |
);
|
|
indvdum@0
|
285 |
|
|
indvdum@0
|
286 |
$sql_array['SELECT'] .= ', ft.mark_time ';
|
|
indvdum@0
|
287 |
}
|
|
indvdum@0
|
288 |
else
|
|
indvdum@0
|
289 |
{
|
|
indvdum@0
|
290 |
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
|
|
indvdum@0
|
291 |
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
|
|
indvdum@0
|
292 |
}
|
|
indvdum@0
|
293 |
|
|
indvdum@0
|
294 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
indvdum@0
|
295 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
296 |
|
|
indvdum@0
|
297 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
298 |
{
|
|
indvdum@0
|
299 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
300 |
|
|
indvdum@0
|
301 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
302 |
{
|
|
indvdum@0
|
303 |
$forum_check = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
|
|
indvdum@0
|
304 |
}
|
|
indvdum@0
|
305 |
else
|
|
indvdum@0
|
306 |
{
|
|
indvdum@0
|
307 |
$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'];
|
|
indvdum@0
|
308 |
}
|
|
indvdum@0
|
309 |
|
|
indvdum@0
|
310 |
$unread_forum = ($row['forum_last_post_time'] > $forum_check) ? true : false;
|
|
indvdum@0
|
311 |
|
|
indvdum@0
|
312 |
// Which folder should we display?
|
|
indvdum@0
|
313 |
if ($row['forum_status'] == ITEM_LOCKED)
|
|
indvdum@0
|
314 |
{
|
|
indvdum@0
|
315 |
$folder_image = ($unread_forum) ? 'forum_unread_locked' : 'forum_read_locked';
|
|
indvdum@0
|
316 |
$folder_alt = 'FORUM_LOCKED';
|
|
indvdum@0
|
317 |
}
|
|
indvdum@0
|
318 |
else
|
|
indvdum@0
|
319 |
{
|
|
indvdum@0
|
320 |
$folder_image = ($unread_forum) ? 'forum_unread' : 'forum_read';
|
|
indvdum@0
|
321 |
$folder_alt = ($unread_forum) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS';
|
|
indvdum@0
|
322 |
}
|
|
indvdum@0
|
323 |
|
|
indvdum@0
|
324 |
// Create last post link information, if appropriate
|
|
indvdum@0
|
325 |
if ($row['forum_last_post_id'])
|
|
indvdum@0
|
326 |
{
|
|
indvdum@0
|
327 |
$last_post_time = $user->format_date($row['forum_last_post_time']);
|
|
indvdum@0
|
328 |
$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'];
|
|
indvdum@0
|
329 |
}
|
|
indvdum@0
|
330 |
else
|
|
indvdum@0
|
331 |
{
|
|
indvdum@0
|
332 |
$last_post_time = $last_post_url = '';
|
|
indvdum@0
|
333 |
}
|
|
indvdum@0
|
334 |
|
|
indvdum@0
|
335 |
$template->assign_block_vars('forumrow', array(
|
|
indvdum@0
|
336 |
'FORUM_ID' => $forum_id,
|
|
indvdum@0
|
337 |
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
|
|
indvdum@0
|
338 |
'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'),
|
|
indvdum@0
|
339 |
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',
|
|
indvdum@0
|
340 |
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
|
|
indvdum@0
|
341 |
'FORUM_NAME' => $row['forum_name'],
|
|
indvdum@0
|
342 |
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
|
|
indvdum@0
|
343 |
'LAST_POST_SUBJECT' => $row['forum_last_post_subject'],
|
|
indvdum@0
|
344 |
'LAST_POST_TIME' => $last_post_time,
|
|
indvdum@0
|
345 |
|
|
indvdum@0
|
346 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
347 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
348 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
349 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
350 |
|
|
indvdum@0
|
351 |
'U_LAST_POST' => $last_post_url,
|
|
indvdum@0
|
352 |
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
|
|
indvdum@0
|
353 |
);
|
|
indvdum@0
|
354 |
}
|
|
indvdum@0
|
355 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
356 |
}
|
|
indvdum@0
|
357 |
|
|
indvdum@0
|
358 |
// Subscribed Topics
|
|
indvdum@0
|
359 |
if ($config['allow_topic_notify'])
|
|
indvdum@0
|
360 |
{
|
|
indvdum@0
|
361 |
if (empty($forbidden_forums))
|
|
indvdum@0
|
362 |
{
|
|
indvdum@0
|
363 |
$forbidden_forums = $auth->acl_getf('!f_read', true);
|
|
indvdum@0
|
364 |
$forbidden_forums = array_unique(array_keys($forbidden_forums));
|
|
indvdum@0
|
365 |
}
|
|
indvdum@0
|
366 |
$this->assign_topiclist('subscribed', $forbidden_forums);
|
|
indvdum@0
|
367 |
}
|
|
indvdum@0
|
368 |
|
|
indvdum@0
|
369 |
$template->assign_vars(array(
|
|
indvdum@0
|
370 |
'S_TOPIC_NOTIFY' => $config['allow_topic_notify'],
|
|
indvdum@0
|
371 |
'S_FORUM_NOTIFY' => $config['allow_forum_notify'],
|
|
indvdum@0
|
372 |
));
|
|
indvdum@0
|
373 |
|
|
indvdum@0
|
374 |
break;
|
|
indvdum@0
|
375 |
|
|
indvdum@0
|
376 |
case 'bookmarks':
|
|
indvdum@0
|
377 |
|
|
indvdum@0
|
378 |
if (!$config['allow_bookmarks'])
|
|
indvdum@0
|
379 |
{
|
|
indvdum@0
|
380 |
$template->assign_vars(array(
|
|
indvdum@0
|
381 |
'S_NO_DISPLAY_BOOKMARKS' => true)
|
|
indvdum@0
|
382 |
);
|
|
indvdum@0
|
383 |
break;
|
|
indvdum@0
|
384 |
}
|
|
indvdum@0
|
385 |
|
|
indvdum@0
|
386 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
indvdum@0
|
387 |
|
|
indvdum@0
|
388 |
$user->add_lang('viewforum');
|
|
indvdum@0
|
389 |
|
|
indvdum@0
|
390 |
if (isset($_POST['unbookmark']))
|
|
indvdum@0
|
391 |
{
|
|
indvdum@0
|
392 |
$s_hidden_fields = array('unbookmark' => 1);
|
|
indvdum@0
|
393 |
$topics = (isset($_POST['t'])) ? array_keys(request_var('t', array(0 => 0))) : array();
|
|
indvdum@0
|
394 |
$url = $this->u_action;
|
|
indvdum@0
|
395 |
|
|
indvdum@0
|
396 |
if (!sizeof($topics))
|
|
indvdum@0
|
397 |
{
|
|
indvdum@0
|
398 |
trigger_error('NO_BOOKMARKS_SELECTED');
|
|
indvdum@0
|
399 |
}
|
|
indvdum@0
|
400 |
|
|
indvdum@0
|
401 |
foreach ($topics as $topic_id)
|
|
indvdum@0
|
402 |
{
|
|
indvdum@0
|
403 |
$s_hidden_fields['t'][$topic_id] = 1;
|
|
indvdum@0
|
404 |
}
|
|
indvdum@0
|
405 |
|
|
indvdum@0
|
406 |
if (confirm_box(true))
|
|
indvdum@0
|
407 |
{
|
|
indvdum@0
|
408 |
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
|
|
indvdum@0
|
409 |
WHERE user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
410 |
AND ' . $db->sql_in_set('topic_id', $topics);
|
|
indvdum@0
|
411 |
$db->sql_query($sql);
|
|
indvdum@0
|
412 |
|
|
indvdum@0
|
413 |
meta_refresh(3, $url);
|
|
indvdum@0
|
414 |
$message = $user->lang['BOOKMARKS_REMOVED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
|
|
indvdum@0
|
415 |
trigger_error($message);
|
|
indvdum@0
|
416 |
}
|
|
indvdum@0
|
417 |
else
|
|
indvdum@0
|
418 |
{
|
|
indvdum@0
|
419 |
confirm_box(false, 'REMOVE_SELECTED_BOOKMARKS', build_hidden_fields($s_hidden_fields));
|
|
indvdum@0
|
420 |
}
|
|
indvdum@0
|
421 |
}
|
|
indvdum@0
|
422 |
$forbidden_forums = $auth->acl_getf('!f_read', true);
|
|
indvdum@0
|
423 |
$forbidden_forums = array_unique(array_keys($forbidden_forums));
|
|
indvdum@0
|
424 |
|
|
indvdum@0
|
425 |
$this->assign_topiclist('bookmarks', $forbidden_forums);
|
|
indvdum@0
|
426 |
|
|
indvdum@0
|
427 |
break;
|
|
indvdum@0
|
428 |
|
|
indvdum@0
|
429 |
case 'drafts':
|
|
indvdum@0
|
430 |
|
|
indvdum@0
|
431 |
$pm_drafts = ($this->p_master->p_name == 'pm') ? true : false;
|
|
indvdum@0
|
432 |
$template->assign_var('S_SHOW_DRAFTS', true);
|
|
indvdum@0
|
433 |
|
|
indvdum@0
|
434 |
$user->add_lang('posting');
|
|
indvdum@0
|
435 |
|
|
indvdum@0
|
436 |
$edit = (isset($_REQUEST['edit'])) ? true : false;
|
|
indvdum@0
|
437 |
$submit = (isset($_POST['submit'])) ? true : false;
|
|
indvdum@0
|
438 |
$draft_id = ($edit) ? intval($_REQUEST['edit']) : 0;
|
|
indvdum@0
|
439 |
$delete = (isset($_POST['delete'])) ? true : false;
|
|
indvdum@0
|
440 |
|
|
indvdum@0
|
441 |
$s_hidden_fields = ($edit) ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : '';
|
|
indvdum@0
|
442 |
$draft_subject = $draft_message = '';
|
|
indvdum@0
|
443 |
add_form_key('ucp_draft');
|
|
indvdum@0
|
444 |
|
|
indvdum@0
|
445 |
if ($delete)
|
|
indvdum@0
|
446 |
{
|
|
indvdum@0
|
447 |
if (check_form_key('ucp_draft'))
|
|
indvdum@0
|
448 |
{
|
|
indvdum@0
|
449 |
$drafts = array_keys(request_var('d', array(0 => 0)));
|
|
indvdum@0
|
450 |
|
|
indvdum@0
|
451 |
if (sizeof($drafts))
|
|
indvdum@0
|
452 |
{
|
|
indvdum@0
|
453 |
$sql = 'DELETE FROM ' . DRAFTS_TABLE . '
|
|
indvdum@0
|
454 |
WHERE ' . $db->sql_in_set('draft_id', $drafts) . '
|
|
indvdum@0
|
455 |
AND user_id = ' . $user->data['user_id'];
|
|
indvdum@0
|
456 |
$db->sql_query($sql);
|
|
indvdum@0
|
457 |
}
|
|
indvdum@0
|
458 |
$msg = $user->lang['DRAFTS_DELETED'];
|
|
indvdum@0
|
459 |
unset($drafts);
|
|
indvdum@0
|
460 |
}
|
|
indvdum@0
|
461 |
else
|
|
indvdum@0
|
462 |
{
|
|
indvdum@0
|
463 |
$msg = $user->lang['FORM_INVALID'];
|
|
indvdum@0
|
464 |
}
|
|
indvdum@0
|
465 |
$message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
|
indvdum@0
|
466 |
meta_refresh(3, $this->u_action);
|
|
indvdum@0
|
467 |
trigger_error($message);
|
|
indvdum@0
|
468 |
}
|
|
indvdum@0
|
469 |
|
|
indvdum@0
|
470 |
if ($submit && $edit)
|
|
indvdum@0
|
471 |
{
|
|
indvdum@0
|
472 |
$draft_subject = utf8_normalize_nfc(request_var('subject', '', true));
|
|
indvdum@0
|
473 |
$draft_message = utf8_normalize_nfc(request_var('message', '', true));
|
|
indvdum@0
|
474 |
if (check_form_key('ucp_draft'))
|
|
indvdum@0
|
475 |
{
|
|
indvdum@0
|
476 |
if ($draft_message && $draft_subject)
|
|
indvdum@0
|
477 |
{
|
|
indvdum@0
|
478 |
$draft_row = array(
|
|
indvdum@0
|
479 |
'draft_subject' => $draft_subject,
|
|
indvdum@0
|
480 |
'draft_message' => $draft_message
|
|
indvdum@0
|
481 |
);
|
|
indvdum@0
|
482 |
|
|
indvdum@0
|
483 |
$sql = 'UPDATE ' . DRAFTS_TABLE . '
|
|
indvdum@0
|
484 |
SET ' . $db->sql_build_array('UPDATE', $draft_row) . "
|
|
indvdum@0
|
485 |
WHERE draft_id = $draft_id
|
|
indvdum@0
|
486 |
AND user_id = " . $user->data['user_id'];
|
|
indvdum@0
|
487 |
$db->sql_query($sql);
|
|
indvdum@0
|
488 |
|
|
indvdum@0
|
489 |
$message = $user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
|
|
indvdum@0
|
490 |
|
|
indvdum@0
|
491 |
meta_refresh(3, $this->u_action);
|
|
indvdum@0
|
492 |
trigger_error($message);
|
|
indvdum@0
|
493 |
}
|
|
indvdum@0
|
494 |
else
|
|
indvdum@0
|
495 |
{
|
|
indvdum@0
|
496 |
$template->assign_var('ERROR', ($draft_message == '') ? $user->lang['EMPTY_DRAFT'] : (($draft_subject == '') ? $user->lang['EMPTY_DRAFT_TITLE'] : ''));
|
|
indvdum@0
|
497 |
}
|
|
indvdum@0
|
498 |
}
|
|
indvdum@0
|
499 |
else
|
|
indvdum@0
|
500 |
{
|
|
indvdum@0
|
501 |
$template->assign_var('ERROR', $user->lang['FORM_INVALID']);
|
|
indvdum@0
|
502 |
}
|
|
indvdum@0
|
503 |
}
|
|
indvdum@0
|
504 |
|
|
indvdum@0
|
505 |
if (!$pm_drafts)
|
|
indvdum@0
|
506 |
{
|
|
indvdum@0
|
507 |
$sql = 'SELECT d.*, f.forum_name
|
|
indvdum@0
|
508 |
FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f
|
|
indvdum@0
|
509 |
WHERE d.user_id = ' . $user->data['user_id'] . ' ' .
|
|
indvdum@0
|
510 |
(($edit) ? "AND d.draft_id = $draft_id" : '') . '
|
|
indvdum@0
|
511 |
AND f.forum_id = d.forum_id
|
|
indvdum@0
|
512 |
ORDER BY d.save_time DESC';
|
|
indvdum@0
|
513 |
}
|
|
indvdum@0
|
514 |
else
|
|
indvdum@0
|
515 |
{
|
|
indvdum@0
|
516 |
$sql = 'SELECT * FROM ' . DRAFTS_TABLE . '
|
|
indvdum@0
|
517 |
WHERE user_id = ' . $user->data['user_id'] . ' ' .
|
|
indvdum@0
|
518 |
(($edit) ? "AND draft_id = $draft_id" : '') . '
|
|
indvdum@0
|
519 |
AND forum_id = 0
|
|
indvdum@0
|
520 |
AND topic_id = 0
|
|
indvdum@0
|
521 |
ORDER BY save_time DESC';
|
|
indvdum@0
|
522 |
}
|
|
indvdum@0
|
523 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
524 |
|
|
indvdum@0
|
525 |
$draftrows = $topic_ids = array();
|
|
indvdum@0
|
526 |
|
|
indvdum@0
|
527 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
528 |
{
|
|
indvdum@0
|
529 |
if ($row['topic_id'])
|
|
indvdum@0
|
530 |
{
|
|
indvdum@0
|
531 |
$topic_ids[] = (int) $row['topic_id'];
|
|
indvdum@0
|
532 |
}
|
|
indvdum@0
|
533 |
$draftrows[] = $row;
|
|
indvdum@0
|
534 |
}
|
|
indvdum@0
|
535 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
536 |
|
|
indvdum@0
|
537 |
if (sizeof($topic_ids))
|
|
indvdum@0
|
538 |
{
|
|
indvdum@0
|
539 |
$sql = 'SELECT topic_id, forum_id, topic_title
|
|
indvdum@0
|
540 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
541 |
WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids));
|
|
indvdum@0
|
542 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
543 |
|
|
indvdum@0
|
544 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
545 |
{
|
|
indvdum@0
|
546 |
$topic_rows[$row['topic_id']] = $row;
|
|
indvdum@0
|
547 |
}
|
|
indvdum@0
|
548 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
549 |
}
|
|
indvdum@0
|
550 |
unset($topic_ids);
|
|
indvdum@0
|
551 |
|
|
indvdum@0
|
552 |
$template->assign_var('S_EDIT_DRAFT', $edit);
|
|
indvdum@0
|
553 |
|
|
indvdum@0
|
554 |
$row_count = 0;
|
|
indvdum@0
|
555 |
foreach ($draftrows as $draft)
|
|
indvdum@0
|
556 |
{
|
|
indvdum@0
|
557 |
$link_topic = $link_forum = $link_pm = false;
|
|
indvdum@0
|
558 |
$insert_url = $view_url = $title = '';
|
|
indvdum@0
|
559 |
|
|
indvdum@0
|
560 |
if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id']))
|
|
indvdum@0
|
561 |
{
|
|
indvdum@0
|
562 |
$link_topic = true;
|
|
indvdum@0
|
563 |
$view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id']);
|
|
indvdum@0
|
564 |
$title = $topic_rows[$draft['topic_id']]['topic_title'];
|
|
indvdum@0
|
565 |
|
|
indvdum@0
|
566 |
$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']);
|
|
indvdum@0
|
567 |
}
|
|
indvdum@0
|
568 |
else if ($auth->acl_get('f_read', $draft['forum_id']))
|
|
indvdum@0
|
569 |
{
|
|
indvdum@0
|
570 |
$link_forum = true;
|
|
indvdum@0
|
571 |
$view_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $draft['forum_id']);
|
|
indvdum@0
|
572 |
$title = $draft['forum_name'];
|
|
indvdum@0
|
573 |
|
|
indvdum@0
|
574 |
$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']);
|
|
indvdum@0
|
575 |
}
|
|
indvdum@0
|
576 |
else if ($pm_drafts)
|
|
indvdum@0
|
577 |
{
|
|
indvdum@0
|
578 |
$link_pm = true;
|
|
indvdum@0
|
579 |
$insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d=" . $draft['draft_id']);
|
|
indvdum@0
|
580 |
}
|
|
indvdum@0
|
581 |
|
|
indvdum@0
|
582 |
$template_row = array(
|
|
indvdum@0
|
583 |
'DATE' => $user->format_date($draft['save_time']),
|
|
indvdum@0
|
584 |
'DRAFT_MESSAGE' => ($submit) ? $draft_message : $draft['draft_message'],
|
|
indvdum@0
|
585 |
'DRAFT_SUBJECT' => ($submit) ? $draft_subject : $draft['draft_subject'],
|
|
indvdum@0
|
586 |
'TITLE' => $title,
|
|
indvdum@0
|
587 |
|
|
indvdum@0
|
588 |
'DRAFT_ID' => $draft['draft_id'],
|
|
indvdum@0
|
589 |
'FORUM_ID' => $draft['forum_id'],
|
|
indvdum@0
|
590 |
'TOPIC_ID' => $draft['topic_id'],
|
|
indvdum@0
|
591 |
|
|
indvdum@0
|
592 |
'U_VIEW' => $view_url,
|
|
indvdum@0
|
593 |
'U_VIEW_EDIT' => $this->u_action . '&edit=' . $draft['draft_id'],
|
|
indvdum@0
|
594 |
'U_INSERT' => $insert_url,
|
|
indvdum@0
|
595 |
|
|
indvdum@0
|
596 |
'S_LINK_TOPIC' => $link_topic,
|
|
indvdum@0
|
597 |
'S_LINK_FORUM' => $link_forum,
|
|
indvdum@0
|
598 |
'S_LINK_PM' => $link_pm,
|
|
indvdum@0
|
599 |
'S_HIDDEN_FIELDS' => $s_hidden_fields
|
|
indvdum@0
|
600 |
);
|
|
indvdum@0
|
601 |
$row_count++;
|
|
indvdum@0
|
602 |
|
|
indvdum@0
|
603 |
($edit) ? $template->assign_vars($template_row) : $template->assign_block_vars('draftrow', $template_row);
|
|
indvdum@0
|
604 |
}
|
|
indvdum@0
|
605 |
|
|
indvdum@0
|
606 |
if (!$edit)
|
|
indvdum@0
|
607 |
{
|
|
indvdum@0
|
608 |
$template->assign_var('S_DRAFT_ROWS', $row_count);
|
|
indvdum@0
|
609 |
}
|
|
indvdum@0
|
610 |
|
|
indvdum@0
|
611 |
break;
|
|
indvdum@0
|
612 |
}
|
|
indvdum@0
|
613 |
|
|
indvdum@0
|
614 |
|
|
indvdum@0
|
615 |
$template->assign_vars(array(
|
|
indvdum@0
|
616 |
'L_TITLE' => $user->lang['UCP_MAIN_' . strtoupper($mode)],
|
|
indvdum@0
|
617 |
|
|
indvdum@0
|
618 |
'S_DISPLAY_MARK_ALL' => ($mode == 'watched' || ($mode == 'drafts' && !isset($_GET['edit']))) ? true : false,
|
|
indvdum@0
|
619 |
'S_HIDDEN_FIELDS' => (isset($s_hidden_fields)) ? $s_hidden_fields : '',
|
|
indvdum@0
|
620 |
'S_UCP_ACTION' => $this->u_action,
|
|
indvdum@0
|
621 |
|
|
indvdum@0
|
622 |
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
|
|
indvdum@0
|
623 |
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
|
indvdum@0
|
624 |
));
|
|
indvdum@0
|
625 |
|
|
indvdum@0
|
626 |
// Set desired template
|
|
indvdum@0
|
627 |
$this->tpl_name = 'ucp_main_' . $mode;
|
|
indvdum@0
|
628 |
$this->page_title = 'UCP_MAIN_' . strtoupper($mode);
|
|
indvdum@0
|
629 |
}
|
|
indvdum@0
|
630 |
|
|
indvdum@0
|
631 |
/**
|
|
indvdum@0
|
632 |
* Build and assign topiclist for bookmarks/subscribed topics
|
|
indvdum@0
|
633 |
*/
|
|
indvdum@0
|
634 |
function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array())
|
|
indvdum@0
|
635 |
{
|
|
indvdum@0
|
636 |
global $user, $db, $template, $config, $cache, $auth, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
637 |
|
|
indvdum@0
|
638 |
$table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE;
|
|
indvdum@0
|
639 |
$start = request_var('start', 0);
|
|
indvdum@0
|
640 |
|
|
indvdum@0
|
641 |
// Grab icons
|
|
indvdum@0
|
642 |
$icons = $cache->obtain_icons();
|
|
indvdum@0
|
643 |
|
|
indvdum@0
|
644 |
$sql_array = array(
|
|
indvdum@0
|
645 |
'SELECT' => 'COUNT(t.topic_id) as topics_count',
|
|
indvdum@0
|
646 |
|
|
indvdum@0
|
647 |
'FROM' => array(
|
|
indvdum@0
|
648 |
$table => 'i',
|
|
indvdum@0
|
649 |
TOPICS_TABLE => 't'
|
|
indvdum@0
|
650 |
),
|
|
indvdum@0
|
651 |
|
|
indvdum@0
|
652 |
'WHERE' => 'i.topic_id = t.topic_id
|
|
indvdum@0
|
653 |
AND i.user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
654 |
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
|
|
indvdum@0
|
655 |
);
|
|
indvdum@0
|
656 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
indvdum@0
|
657 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
658 |
$topics_count = (int) $db->sql_fetchfield('topics_count');
|
|
indvdum@0
|
659 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
660 |
|
|
indvdum@0
|
661 |
if ($topics_count)
|
|
indvdum@0
|
662 |
{
|
|
indvdum@0
|
663 |
$template->assign_vars(array(
|
|
indvdum@0
|
664 |
'PAGINATION' => generate_pagination($this->u_action, $topics_count, $config['topics_per_page'], $start),
|
|
indvdum@0
|
665 |
'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start),
|
|
indvdum@0
|
666 |
'TOTAL_TOPICS' => ($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count))
|
|
indvdum@0
|
667 |
);
|
|
indvdum@0
|
668 |
}
|
|
indvdum@0
|
669 |
|
|
indvdum@0
|
670 |
if ($mode == 'subscribed')
|
|
indvdum@0
|
671 |
{
|
|
indvdum@0
|
672 |
$sql_array = array(
|
|
indvdum@0
|
673 |
'SELECT' => 't.*, f.forum_name',
|
|
indvdum@0
|
674 |
|
|
indvdum@0
|
675 |
'FROM' => array(
|
|
indvdum@0
|
676 |
TOPICS_WATCH_TABLE => 'tw',
|
|
indvdum@0
|
677 |
TOPICS_TABLE => 't'
|
|
indvdum@0
|
678 |
),
|
|
indvdum@0
|
679 |
|
|
indvdum@0
|
680 |
'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
681 |
AND t.topic_id = tw.topic_id
|
|
indvdum@0
|
682 |
AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true),
|
|
indvdum@0
|
683 |
|
|
indvdum@0
|
684 |
|
|
indvdum@0
|
685 |
'ORDER_BY' => 't.topic_last_post_time DESC'
|
|
indvdum@0
|
686 |
);
|
|
indvdum@0
|
687 |
|
|
indvdum@0
|
688 |
$sql_array['LEFT_JOIN'] = array();
|
|
indvdum@0
|
689 |
}
|
|
indvdum@0
|
690 |
else
|
|
indvdum@0
|
691 |
{
|
|
indvdum@0
|
692 |
$sql_array = array(
|
|
indvdum@0
|
693 |
'SELECT' => 't.*, f.forum_name, b.topic_id as b_topic_id',
|
|
indvdum@0
|
694 |
|
|
indvdum@0
|
695 |
'FROM' => array(
|
|
indvdum@0
|
696 |
BOOKMARKS_TABLE => 'b',
|
|
indvdum@0
|
697 |
),
|
|
indvdum@0
|
698 |
|
|
indvdum@0
|
699 |
'WHERE' => 'b.user_id = ' . $user->data['user_id'] . '
|
|
indvdum@0
|
700 |
AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true),
|
|
indvdum@0
|
701 |
|
|
indvdum@0
|
702 |
'ORDER_BY' => 't.topic_last_post_time DESC'
|
|
indvdum@0
|
703 |
);
|
|
indvdum@0
|
704 |
|
|
indvdum@0
|
705 |
$sql_array['LEFT_JOIN'] = array();
|
|
indvdum@0
|
706 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'b.topic_id = t.topic_id');
|
|
indvdum@0
|
707 |
}
|
|
indvdum@0
|
708 |
|
|
indvdum@0
|
709 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id');
|
|
indvdum@0
|
710 |
|
|
indvdum@0
|
711 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
712 |
{
|
|
indvdum@0
|
713 |
$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']);
|
|
indvdum@0
|
714 |
$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']);
|
|
indvdum@0
|
715 |
$sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time AS forum_mark_time';
|
|
indvdum@0
|
716 |
}
|
|
indvdum@0
|
717 |
|
|
indvdum@0
|
718 |
if ($config['load_db_track'])
|
|
indvdum@0
|
719 |
{
|
|
indvdum@0
|
720 |
$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']);
|
|
indvdum@0
|
721 |
$sql_array['SELECT'] .= ', tp.topic_posted';
|
|
indvdum@0
|
722 |
}
|
|
indvdum@0
|
723 |
|
|
indvdum@0
|
724 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
indvdum@0
|
725 |
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
|
|
indvdum@0
|
726 |
|
|
indvdum@0
|
727 |
$topic_list = $topic_forum_list = $global_announce_list = $rowset = array();
|
|
indvdum@0
|
728 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
729 |
{
|
|
indvdum@0
|
730 |
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
|
|
indvdum@0
|
731 |
|
|
indvdum@0
|
732 |
$topic_list[] = $topic_id;
|
|
indvdum@0
|
733 |
$rowset[$topic_id] = $row;
|
|
indvdum@0
|
734 |
|
|
indvdum@0
|
735 |
$topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread']) ? $row['forum_mark_time'] : 0;
|
|
indvdum@0
|
736 |
$topic_forum_list[$row['forum_id']]['topics'][] = $topic_id;
|
|
indvdum@0
|
737 |
|
|
indvdum@0
|
738 |
if ($row['topic_type'] == POST_GLOBAL)
|
|
indvdum@0
|
739 |
{
|
|
indvdum@0
|
740 |
$global_announce_list[] = $topic_id;
|
|
indvdum@0
|
741 |
}
|
|
indvdum@0
|
742 |
}
|
|
indvdum@0
|
743 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
744 |
|
|
indvdum@0
|
745 |
$topic_tracking_info = array();
|
|
indvdum@0
|
746 |
if ($config['load_db_lastread'])
|
|
indvdum@0
|
747 |
{
|
|
indvdum@0
|
748 |
foreach ($topic_forum_list as $f_id => $topic_row)
|
|
indvdum@0
|
749 |
{
|
|
indvdum@0
|
750 |
$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);
|
|
indvdum@0
|
751 |
}
|
|
indvdum@0
|
752 |
}
|
|
indvdum@0
|
753 |
else
|
|
indvdum@0
|
754 |
{
|
|
indvdum@0
|
755 |
foreach ($topic_forum_list as $f_id => $topic_row)
|
|
indvdum@0
|
756 |
{
|
|
indvdum@0
|
757 |
$topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics'], $global_announce_list);
|
|
indvdum@0
|
758 |
}
|
|
indvdum@0
|
759 |
}
|
|
indvdum@0
|
760 |
|
|
indvdum@0
|
761 |
foreach ($topic_list as $topic_id)
|
|
indvdum@0
|
762 |
{
|
|
indvdum@0
|
763 |
$row = &$rowset[$topic_id];
|
|
indvdum@0
|
764 |
|
|
indvdum@0
|
765 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
766 |
$topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id'];
|
|
indvdum@0
|
767 |
|
|
indvdum@0
|
768 |
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
|
indvdum@0
|
769 |
|
|
indvdum@0
|
770 |
// Replies
|
|
indvdum@0
|
771 |
$replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
|
|
indvdum@0
|
772 |
|
|
indvdum@0
|
773 |
if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id']))
|
|
indvdum@0
|
774 |
{
|
|
indvdum@0
|
775 |
$topic_id = $row['topic_moved_id'];
|
|
indvdum@0
|
776 |
}
|
|
indvdum@0
|
777 |
|
|
indvdum@0
|
778 |
// Get folder img, topic status/type related information
|
|
indvdum@0
|
779 |
$folder_img = $folder_alt = $topic_type = '';
|
|
indvdum@0
|
780 |
topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
|
|
indvdum@0
|
781 |
|
|
indvdum@0
|
782 |
$view_topic_url_params = "f=$forum_id&t=$topic_id";
|
|
indvdum@0
|
783 |
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
|
|
indvdum@0
|
784 |
|
|
indvdum@0
|
785 |
// Send vars to template
|
|
indvdum@0
|
786 |
$template->assign_block_vars('topicrow', array(
|
|
indvdum@0
|
787 |
'FORUM_ID' => $forum_id,
|
|
indvdum@0
|
788 |
'TOPIC_ID' => $topic_id,
|
|
indvdum@0
|
789 |
'FIRST_POST_TIME' => $user->format_date($row['topic_time']),
|
|
indvdum@0
|
790 |
'LAST_POST_SUBJECT' => $row['topic_last_post_subject'],
|
|
indvdum@0
|
791 |
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
|
|
indvdum@0
|
792 |
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
|
|
indvdum@0
|
793 |
|
|
indvdum@0
|
794 |
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
795 |
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
796 |
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
797 |
'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
|
|
indvdum@0
|
798 |
|
|
indvdum@0
|
799 |
'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
800 |
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
801 |
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
802 |
'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
|
|
indvdum@0
|
803 |
|
|
indvdum@0
|
804 |
'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false,
|
|
indvdum@0
|
805 |
'S_GLOBAL_TOPIC' => (!$forum_id) ? true : false,
|
|
indvdum@0
|
806 |
|
|
indvdum@0
|
807 |
'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&t=$topic_id")),
|
|
indvdum@0
|
808 |
'REPLIES' => $replies,
|
|
indvdum@0
|
809 |
'VIEWS' => $row['topic_views'],
|
|
indvdum@0
|
810 |
'TOPIC_TITLE' => censor_text($row['topic_title']),
|
|
indvdum@0
|
811 |
'TOPIC_TYPE' => $topic_type,
|
|
indvdum@0
|
812 |
'FORUM_NAME' => $row['forum_name'],
|
|
indvdum@0
|
813 |
|
|
indvdum@0
|
814 |
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
|
|
indvdum@0
|
815 |
'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
|
|
indvdum@0
|
816 |
'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
|
|
indvdum@0
|
817 |
'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
|
|
indvdum@0
|
818 |
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
|
|
indvdum@0
|
819 |
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
|
|
indvdum@0
|
820 |
'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']) : '',
|
|
indvdum@0
|
821 |
|
|
indvdum@0
|
822 |
'S_TOPIC_TYPE' => $row['topic_type'],
|
|
indvdum@0
|
823 |
'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false,
|
|
indvdum@0
|
824 |
'S_UNREAD_TOPIC' => $unread_topic,
|
|
indvdum@0
|
825 |
|
|
indvdum@0
|
826 |
'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread',
|
|
indvdum@0
|
827 |
'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'],
|
|
indvdum@0
|
828 |
'U_VIEW_TOPIC' => $view_topic_url,
|
|
indvdum@0
|
829 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
|
|
indvdum@0
|
830 |
));
|
|
indvdum@0
|
831 |
}
|
|
indvdum@0
|
832 |
}
|
|
indvdum@0
|
833 |
}
|
|
indvdum@0
|
834 |
|
|
indvdum@0
|
835 |
?> |