|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package phpBB3
|
|
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 |
* Display Forums
|
|
indvdum@0
|
21 |
*/
|
|
indvdum@0
|
22 |
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
|
|
indvdum@0
|
23 |
{
|
|
indvdum@0
|
24 |
global $db, $auth, $user, $template;
|
|
indvdum@0
|
25 |
global $phpbb_root_path, $phpEx, $config;
|
|
indvdum@0
|
26 |
|
|
indvdum@0
|
27 |
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
|
|
indvdum@0
|
28 |
$parent_id = $visible_forums = 0;
|
|
indvdum@0
|
29 |
$sql_from = '';
|
|
indvdum@0
|
30 |
|
|
indvdum@0
|
31 |
// Mark forums read?
|
|
indvdum@0
|
32 |
$mark_read = request_var('mark', '');
|
|
indvdum@0
|
33 |
|
|
indvdum@0
|
34 |
if ($mark_read == 'all')
|
|
indvdum@0
|
35 |
{
|
|
indvdum@0
|
36 |
$mark_read = '';
|
|
indvdum@0
|
37 |
}
|
|
indvdum@0
|
38 |
|
|
indvdum@0
|
39 |
if (!$root_data)
|
|
indvdum@0
|
40 |
{
|
|
indvdum@0
|
41 |
if ($mark_read == 'forums')
|
|
indvdum@0
|
42 |
{
|
|
indvdum@0
|
43 |
$mark_read = 'all';
|
|
indvdum@0
|
44 |
}
|
|
indvdum@0
|
45 |
|
|
indvdum@0
|
46 |
$root_data = array('forum_id' => 0);
|
|
indvdum@0
|
47 |
$sql_where = '';
|
|
indvdum@0
|
48 |
}
|
|
indvdum@0
|
49 |
else
|
|
indvdum@0
|
50 |
{
|
|
indvdum@0
|
51 |
$sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
|
|
indvdum@0
|
52 |
}
|
|
indvdum@0
|
53 |
|
|
indvdum@0
|
54 |
// Handle marking everything read
|
|
indvdum@0
|
55 |
if ($mark_read == 'all')
|
|
indvdum@0
|
56 |
{
|
|
indvdum@0
|
57 |
$redirect = build_url(array('mark', 'hash'));
|
|
indvdum@0
|
58 |
meta_refresh(3, $redirect);
|
|
indvdum@0
|
59 |
|
|
indvdum@0
|
60 |
if (check_link_hash(request_var('hash', ''), 'global'))
|
|
indvdum@0
|
61 |
{
|
|
indvdum@0
|
62 |
markread('all');
|
|
indvdum@0
|
63 |
|
|
indvdum@0
|
64 |
trigger_error(
|
|
indvdum@0
|
65 |
$user->lang['FORUMS_MARKED'] . '<br /><br />' .
|
|
indvdum@0
|
66 |
sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>')
|
|
indvdum@0
|
67 |
);
|
|
indvdum@0
|
68 |
}
|
|
indvdum@0
|
69 |
else
|
|
indvdum@0
|
70 |
{
|
|
indvdum@0
|
71 |
trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
|
|
indvdum@0
|
72 |
}
|
|
indvdum@0
|
73 |
}
|
|
indvdum@0
|
74 |
|
|
indvdum@0
|
75 |
// Display list of active topics for this category?
|
|
indvdum@0
|
76 |
$show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;
|
|
indvdum@0
|
77 |
|
|
indvdum@0
|
78 |
$sql_array = array(
|
|
indvdum@0
|
79 |
'SELECT' => 'f.*',
|
|
indvdum@0
|
80 |
'FROM' => array(
|
|
indvdum@0
|
81 |
FORUMS_TABLE => 'f'
|
|
indvdum@0
|
82 |
),
|
|
indvdum@0
|
83 |
'LEFT_JOIN' => array(),
|
|
indvdum@0
|
84 |
);
|
|
indvdum@0
|
85 |
|
|
indvdum@0
|
86 |
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
|
indvdum@0
|
87 |
{
|
|
indvdum@0
|
88 |
$sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
|
|
indvdum@0
|
89 |
$sql_array['SELECT'] .= ', ft.mark_time';
|
|
indvdum@0
|
90 |
}
|
|
indvdum@0
|
91 |
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
|
indvdum@0
|
92 |
{
|
|
indvdum@0
|
93 |
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : '';
|
|
indvdum@0
|
94 |
$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
|
|
indvdum@0
|
95 |
|
|
indvdum@0
|
96 |
if (!$user->data['is_registered'])
|
|
indvdum@0
|
97 |
{
|
|
indvdum@0
|
98 |
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
|
|
indvdum@0
|
99 |
}
|
|
indvdum@0
|
100 |
}
|
|
indvdum@0
|
101 |
|
|
indvdum@0
|
102 |
if ($show_active)
|
|
indvdum@0
|
103 |
{
|
|
indvdum@0
|
104 |
$sql_array['LEFT_JOIN'][] = array(
|
|
indvdum@0
|
105 |
'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'),
|
|
indvdum@0
|
106 |
'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'"
|
|
indvdum@0
|
107 |
);
|
|
indvdum@0
|
108 |
|
|
indvdum@0
|
109 |
$sql_array['SELECT'] .= ', fa.user_id';
|
|
indvdum@0
|
110 |
}
|
|
indvdum@0
|
111 |
|
|
indvdum@0
|
112 |
$sql = $db->sql_build_query('SELECT', array(
|
|
indvdum@0
|
113 |
'SELECT' => $sql_array['SELECT'],
|
|
indvdum@0
|
114 |
'FROM' => $sql_array['FROM'],
|
|
indvdum@0
|
115 |
'LEFT_JOIN' => $sql_array['LEFT_JOIN'],
|
|
indvdum@0
|
116 |
|
|
indvdum@0
|
117 |
'WHERE' => $sql_where,
|
|
indvdum@0
|
118 |
|
|
indvdum@0
|
119 |
'ORDER_BY' => 'f.left_id',
|
|
indvdum@0
|
120 |
));
|
|
indvdum@0
|
121 |
|
|
indvdum@0
|
122 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
123 |
|
|
indvdum@0
|
124 |
$forum_tracking_info = array();
|
|
indvdum@0
|
125 |
$branch_root_id = $root_data['forum_id'];
|
|
indvdum@0
|
126 |
|
|
indvdum@0
|
127 |
// Check for unread global announcements (index page only)
|
|
indvdum@0
|
128 |
$ga_unread = false;
|
|
indvdum@0
|
129 |
if ($root_data['forum_id'] == 0)
|
|
indvdum@0
|
130 |
{
|
|
indvdum@0
|
131 |
$unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1);
|
|
indvdum@0
|
132 |
|
|
indvdum@0
|
133 |
if (!empty($unread_ga_list))
|
|
indvdum@0
|
134 |
{
|
|
indvdum@0
|
135 |
$ga_unread = true;
|
|
indvdum@0
|
136 |
}
|
|
indvdum@0
|
137 |
}
|
|
indvdum@0
|
138 |
|
|
indvdum@0
|
139 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
140 |
{
|
|
indvdum@0
|
141 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
142 |
|
|
indvdum@0
|
143 |
// Mark forums read?
|
|
indvdum@0
|
144 |
if ($mark_read == 'forums')
|
|
indvdum@0
|
145 |
{
|
|
indvdum@0
|
146 |
if ($auth->acl_get('f_list', $forum_id))
|
|
indvdum@0
|
147 |
{
|
|
indvdum@0
|
148 |
$forum_ids[] = $forum_id;
|
|
indvdum@0
|
149 |
}
|
|
indvdum@0
|
150 |
|
|
indvdum@0
|
151 |
continue;
|
|
indvdum@0
|
152 |
}
|
|
indvdum@0
|
153 |
|
|
indvdum@0
|
154 |
// Category with no members
|
|
indvdum@0
|
155 |
if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
|
|
indvdum@0
|
156 |
{
|
|
indvdum@0
|
157 |
continue;
|
|
indvdum@0
|
158 |
}
|
|
indvdum@0
|
159 |
|
|
indvdum@0
|
160 |
// Skip branch
|
|
indvdum@0
|
161 |
if (isset($right_id))
|
|
indvdum@0
|
162 |
{
|
|
indvdum@0
|
163 |
if ($row['left_id'] < $right_id)
|
|
indvdum@0
|
164 |
{
|
|
indvdum@0
|
165 |
continue;
|
|
indvdum@0
|
166 |
}
|
|
indvdum@0
|
167 |
unset($right_id);
|
|
indvdum@0
|
168 |
}
|
|
indvdum@0
|
169 |
|
|
indvdum@0
|
170 |
if (!$auth->acl_get('f_list', $forum_id))
|
|
indvdum@0
|
171 |
{
|
|
indvdum@0
|
172 |
// if the user does not have permissions to list this forum, skip everything until next branch
|
|
indvdum@0
|
173 |
$right_id = $row['right_id'];
|
|
indvdum@0
|
174 |
continue;
|
|
indvdum@0
|
175 |
}
|
|
indvdum@0
|
176 |
|
|
indvdum@0
|
177 |
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
|
indvdum@0
|
178 |
{
|
|
indvdum@0
|
179 |
$forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
|
|
indvdum@0
|
180 |
}
|
|
indvdum@0
|
181 |
else if ($config['load_anon_lastread'] || $user->data['is_registered'])
|
|
indvdum@0
|
182 |
{
|
|
indvdum@0
|
183 |
if (!$user->data['is_registered'])
|
|
indvdum@0
|
184 |
{
|
|
indvdum@0
|
185 |
$user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
|
|
indvdum@0
|
186 |
}
|
|
indvdum@0
|
187 |
$forum_tracking_info[$forum_id] = (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
|
188 |
}
|
|
indvdum@0
|
189 |
|
|
indvdum@0
|
190 |
// Count the difference of real to public topics, so we can display an information to moderators
|
|
indvdum@0
|
191 |
$row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0;
|
|
indvdum@0
|
192 |
$row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'];
|
|
indvdum@0
|
193 |
|
|
indvdum@0
|
194 |
// Display active topics from this forum?
|
|
indvdum@0
|
195 |
if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS))
|
|
indvdum@0
|
196 |
{
|
|
indvdum@0
|
197 |
if (!isset($active_forum_ary['forum_topics']))
|
|
indvdum@0
|
198 |
{
|
|
indvdum@0
|
199 |
$active_forum_ary['forum_topics'] = 0;
|
|
indvdum@0
|
200 |
}
|
|
indvdum@0
|
201 |
|
|
indvdum@0
|
202 |
if (!isset($active_forum_ary['forum_posts']))
|
|
indvdum@0
|
203 |
{
|
|
indvdum@0
|
204 |
$active_forum_ary['forum_posts'] = 0;
|
|
indvdum@0
|
205 |
}
|
|
indvdum@0
|
206 |
|
|
indvdum@0
|
207 |
$active_forum_ary['forum_id'][] = $forum_id;
|
|
indvdum@0
|
208 |
$active_forum_ary['enable_icons'][] = $row['enable_icons'];
|
|
indvdum@0
|
209 |
$active_forum_ary['forum_topics'] += $row['forum_topics'];
|
|
indvdum@0
|
210 |
$active_forum_ary['forum_posts'] += $row['forum_posts'];
|
|
indvdum@0
|
211 |
|
|
indvdum@0
|
212 |
// If this is a passworded forum we do not show active topics from it if the user is not authorised to view it...
|
|
indvdum@0
|
213 |
if ($row['forum_password'] && $row['user_id'] != $user->data['user_id'])
|
|
indvdum@0
|
214 |
{
|
|
indvdum@0
|
215 |
$active_forum_ary['exclude_forum_id'][] = $forum_id;
|
|
indvdum@0
|
216 |
}
|
|
indvdum@0
|
217 |
}
|
|
indvdum@0
|
218 |
|
|
indvdum@0
|
219 |
//
|
|
indvdum@0
|
220 |
if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id)
|
|
indvdum@0
|
221 |
{
|
|
indvdum@0
|
222 |
if ($row['forum_type'] != FORUM_CAT)
|
|
indvdum@0
|
223 |
{
|
|
indvdum@0
|
224 |
$forum_ids_moderator[] = (int) $forum_id;
|
|
indvdum@0
|
225 |
}
|
|
indvdum@0
|
226 |
|
|
indvdum@0
|
227 |
// Direct child of current branch
|
|
indvdum@0
|
228 |
$parent_id = $forum_id;
|
|
indvdum@0
|
229 |
$forum_rows[$forum_id] = $row;
|
|
indvdum@0
|
230 |
|
|
indvdum@0
|
231 |
if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id'])
|
|
indvdum@0
|
232 |
{
|
|
indvdum@0
|
233 |
$branch_root_id = $forum_id;
|
|
indvdum@0
|
234 |
}
|
|
indvdum@0
|
235 |
$forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
|
|
indvdum@0
|
236 |
$forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
|
|
indvdum@0
|
237 |
}
|
|
indvdum@0
|
238 |
else if ($row['forum_type'] != FORUM_CAT)
|
|
indvdum@0
|
239 |
{
|
|
indvdum@0
|
240 |
$subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false;
|
|
indvdum@0
|
241 |
$subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
|
|
indvdum@0
|
242 |
$subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
|
|
indvdum@0
|
243 |
$subforums[$parent_id][$forum_id]['children'] = array();
|
|
indvdum@0
|
244 |
|
|
indvdum@0
|
245 |
if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index'])
|
|
indvdum@0
|
246 |
{
|
|
indvdum@0
|
247 |
$subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id;
|
|
indvdum@0
|
248 |
}
|
|
indvdum@0
|
249 |
|
|
indvdum@0
|
250 |
if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics'])
|
|
indvdum@0
|
251 |
{
|
|
indvdum@0
|
252 |
$forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id;
|
|
indvdum@0
|
253 |
}
|
|
indvdum@0
|
254 |
|
|
indvdum@0
|
255 |
$forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
|
|
indvdum@0
|
256 |
|
|
indvdum@0
|
257 |
// Do not list redirects in LINK Forums as Posts.
|
|
indvdum@0
|
258 |
if ($row['forum_type'] != FORUM_LINK)
|
|
indvdum@0
|
259 |
{
|
|
indvdum@0
|
260 |
$forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
|
|
indvdum@0
|
261 |
}
|
|
indvdum@0
|
262 |
|
|
indvdum@0
|
263 |
if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time'])
|
|
indvdum@0
|
264 |
{
|
|
indvdum@0
|
265 |
$forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
|
|
indvdum@0
|
266 |
$forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject'];
|
|
indvdum@0
|
267 |
$forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
|
|
indvdum@0
|
268 |
$forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
|
|
indvdum@0
|
269 |
$forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
|
|
indvdum@0
|
270 |
$forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour'];
|
|
indvdum@0
|
271 |
$forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
|
|
indvdum@0
|
272 |
}
|
|
indvdum@0
|
273 |
}
|
|
indvdum@0
|
274 |
}
|
|
indvdum@0
|
275 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
276 |
|
|
indvdum@0
|
277 |
// Handle marking posts
|
|
indvdum@0
|
278 |
if ($mark_read == 'forums')
|
|
indvdum@0
|
279 |
{
|
|
indvdum@0
|
280 |
$redirect = build_url(array('mark', 'hash'));
|
|
indvdum@0
|
281 |
$token = request_var('hash', '');
|
|
indvdum@0
|
282 |
if (check_link_hash($token, 'global'))
|
|
indvdum@0
|
283 |
{
|
|
indvdum@0
|
284 |
// Add 0 to forums array to mark global announcements correctly
|
|
indvdum@0
|
285 |
$forum_ids[] = 0;
|
|
indvdum@0
|
286 |
markread('topics', $forum_ids);
|
|
indvdum@0
|
287 |
$message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
|
|
indvdum@0
|
288 |
meta_refresh(3, $redirect);
|
|
indvdum@0
|
289 |
trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
|
|
indvdum@0
|
290 |
}
|
|
indvdum@0
|
291 |
else
|
|
indvdum@0
|
292 |
{
|
|
indvdum@0
|
293 |
$message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
|
|
indvdum@0
|
294 |
meta_refresh(3, $redirect);
|
|
indvdum@0
|
295 |
trigger_error($message);
|
|
indvdum@0
|
296 |
}
|
|
indvdum@0
|
297 |
|
|
indvdum@0
|
298 |
}
|
|
indvdum@0
|
299 |
|
|
indvdum@0
|
300 |
// Grab moderators ... if necessary
|
|
indvdum@0
|
301 |
if ($display_moderators)
|
|
indvdum@0
|
302 |
{
|
|
indvdum@0
|
303 |
if ($return_moderators)
|
|
indvdum@0
|
304 |
{
|
|
indvdum@0
|
305 |
$forum_ids_moderator[] = $root_data['forum_id'];
|
|
indvdum@0
|
306 |
}
|
|
indvdum@0
|
307 |
get_moderators($forum_moderators, $forum_ids_moderator);
|
|
indvdum@0
|
308 |
}
|
|
indvdum@0
|
309 |
|
|
indvdum@0
|
310 |
// Used to tell whatever we have to create a dummy category or not.
|
|
indvdum@0
|
311 |
$last_catless = true;
|
|
indvdum@0
|
312 |
foreach ($forum_rows as $row)
|
|
indvdum@0
|
313 |
{
|
|
indvdum@0
|
314 |
// Empty category
|
|
indvdum@0
|
315 |
if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT)
|
|
indvdum@0
|
316 |
{
|
|
indvdum@0
|
317 |
$template->assign_block_vars('forumrow', array(
|
|
indvdum@0
|
318 |
'S_IS_CAT' => true,
|
|
indvdum@0
|
319 |
'FORUM_ID' => $row['forum_id'],
|
|
indvdum@0
|
320 |
'FORUM_NAME' => $row['forum_name'],
|
|
indvdum@0
|
321 |
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
|
|
indvdum@0
|
322 |
'FORUM_FOLDER_IMG' => '',
|
|
indvdum@0
|
323 |
'FORUM_FOLDER_IMG_SRC' => '',
|
|
indvdum@0
|
324 |
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '',
|
|
indvdum@0
|
325 |
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
|
|
indvdum@0
|
326 |
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
|
|
indvdum@0
|
327 |
);
|
|
indvdum@0
|
328 |
|
|
indvdum@0
|
329 |
continue;
|
|
indvdum@0
|
330 |
}
|
|
indvdum@0
|
331 |
|
|
indvdum@0
|
332 |
$visible_forums++;
|
|
indvdum@0
|
333 |
$forum_id = $row['forum_id'];
|
|
indvdum@0
|
334 |
|
|
indvdum@0
|
335 |
$forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;
|
|
indvdum@0
|
336 |
|
|
indvdum@0
|
337 |
// Mark the first visible forum on index as unread if there's any unread global announcement
|
|
indvdum@0
|
338 |
if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0])
|
|
indvdum@0
|
339 |
{
|
|
indvdum@0
|
340 |
$forum_unread = true;
|
|
indvdum@0
|
341 |
}
|
|
indvdum@0
|
342 |
|
|
indvdum@0
|
343 |
$folder_image = $folder_alt = $l_subforums = '';
|
|
indvdum@0
|
344 |
$subforums_list = array();
|
|
indvdum@0
|
345 |
|
|
indvdum@0
|
346 |
// Generate list of subforums if we need to
|
|
indvdum@0
|
347 |
if (isset($subforums[$forum_id]))
|
|
indvdum@0
|
348 |
{
|
|
indvdum@0
|
349 |
foreach ($subforums[$forum_id] as $subforum_id => $subforum_row)
|
|
indvdum@0
|
350 |
{
|
|
indvdum@0
|
351 |
$subforum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false;
|
|
indvdum@0
|
352 |
|
|
indvdum@0
|
353 |
if (!$subforum_unread && !empty($subforum_row['children']))
|
|
indvdum@0
|
354 |
{
|
|
indvdum@0
|
355 |
foreach ($subforum_row['children'] as $child_id)
|
|
indvdum@0
|
356 |
{
|
|
indvdum@0
|
357 |
if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id])
|
|
indvdum@0
|
358 |
{
|
|
indvdum@0
|
359 |
// Once we found an unread child forum, we can drop out of this loop
|
|
indvdum@0
|
360 |
$subforum_unread = true;
|
|
indvdum@0
|
361 |
break;
|
|
indvdum@0
|
362 |
}
|
|
indvdum@0
|
363 |
}
|
|
indvdum@0
|
364 |
}
|
|
indvdum@0
|
365 |
|
|
indvdum@0
|
366 |
if ($subforum_row['display'] && $subforum_row['name'])
|
|
indvdum@0
|
367 |
{
|
|
indvdum@0
|
368 |
$subforums_list[] = array(
|
|
indvdum@0
|
369 |
'link' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id),
|
|
indvdum@0
|
370 |
'name' => $subforum_row['name'],
|
|
indvdum@0
|
371 |
'unread' => $subforum_unread,
|
|
indvdum@0
|
372 |
);
|
|
indvdum@0
|
373 |
}
|
|
indvdum@0
|
374 |
else
|
|
indvdum@0
|
375 |
{
|
|
indvdum@0
|
376 |
unset($subforums[$forum_id][$subforum_id]);
|
|
indvdum@0
|
377 |
}
|
|
indvdum@0
|
378 |
|
|
indvdum@0
|
379 |
// If one subforum is unread the forum gets unread too...
|
|
indvdum@0
|
380 |
if ($subforum_unread)
|
|
indvdum@0
|
381 |
{
|
|
indvdum@0
|
382 |
$forum_unread = true;
|
|
indvdum@0
|
383 |
}
|
|
indvdum@0
|
384 |
}
|
|
indvdum@0
|
385 |
|
|
indvdum@0
|
386 |
$l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
|
|
indvdum@0
|
387 |
$folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum';
|
|
indvdum@0
|
388 |
}
|
|
indvdum@0
|
389 |
else
|
|
indvdum@0
|
390 |
{
|
|
indvdum@0
|
391 |
switch ($row['forum_type'])
|
|
indvdum@0
|
392 |
{
|
|
indvdum@0
|
393 |
case FORUM_POST:
|
|
indvdum@0
|
394 |
$folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read';
|
|
indvdum@0
|
395 |
break;
|
|
indvdum@0
|
396 |
|
|
indvdum@0
|
397 |
case FORUM_LINK:
|
|
indvdum@0
|
398 |
$folder_image = 'forum_link';
|
|
indvdum@0
|
399 |
break;
|
|
indvdum@0
|
400 |
}
|
|
indvdum@0
|
401 |
}
|
|
indvdum@0
|
402 |
|
|
indvdum@0
|
403 |
// Which folder should we display?
|
|
indvdum@0
|
404 |
if ($row['forum_status'] == ITEM_LOCKED)
|
|
indvdum@0
|
405 |
{
|
|
indvdum@0
|
406 |
$folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked';
|
|
indvdum@0
|
407 |
$folder_alt = 'FORUM_LOCKED';
|
|
indvdum@0
|
408 |
}
|
|
indvdum@0
|
409 |
else
|
|
indvdum@0
|
410 |
{
|
|
indvdum@0
|
411 |
$folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS';
|
|
indvdum@0
|
412 |
}
|
|
indvdum@0
|
413 |
|
|
indvdum@0
|
414 |
// Create last post link information, if appropriate
|
|
indvdum@0
|
415 |
if ($row['forum_last_post_id'])
|
|
indvdum@0
|
416 |
{
|
|
indvdum@0
|
417 |
$last_post_subject = $row['forum_last_post_subject'];
|
|
indvdum@0
|
418 |
$last_post_time = $user->format_date($row['forum_last_post_time']);
|
|
indvdum@0
|
419 |
$last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id_last_post'] . '&p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
|
|
indvdum@0
|
420 |
}
|
|
indvdum@0
|
421 |
else
|
|
indvdum@0
|
422 |
{
|
|
indvdum@0
|
423 |
$last_post_subject = $last_post_time = $last_post_url = '';
|
|
indvdum@0
|
424 |
}
|
|
indvdum@0
|
425 |
|
|
indvdum@0
|
426 |
// Output moderator listing ... if applicable
|
|
indvdum@0
|
427 |
$l_moderator = $moderators_list = '';
|
|
indvdum@0
|
428 |
if ($display_moderators && !empty($forum_moderators[$forum_id]))
|
|
indvdum@0
|
429 |
{
|
|
indvdum@0
|
430 |
$l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
|
|
indvdum@0
|
431 |
$moderators_list = implode(', ', $forum_moderators[$forum_id]);
|
|
indvdum@0
|
432 |
}
|
|
indvdum@0
|
433 |
|
|
indvdum@0
|
434 |
$l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS';
|
|
indvdum@0
|
435 |
$post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : '';
|
|
indvdum@0
|
436 |
|
|
indvdum@0
|
437 |
$s_subforums_list = array();
|
|
indvdum@0
|
438 |
foreach ($subforums_list as $subforum)
|
|
indvdum@0
|
439 |
{
|
|
indvdum@0
|
440 |
$s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '" title="' . (($subforum['unread']) ? $user->lang['UNREAD_POSTS'] : $user->lang['NO_UNREAD_POSTS']) . '">' . $subforum['name'] . '</a>';
|
|
indvdum@0
|
441 |
}
|
|
indvdum@0
|
442 |
$s_subforums_list = (string) implode(', ', $s_subforums_list);
|
|
indvdum@0
|
443 |
$catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false;
|
|
indvdum@0
|
444 |
|
|
indvdum@0
|
445 |
if ($row['forum_type'] != FORUM_LINK)
|
|
indvdum@0
|
446 |
{
|
|
indvdum@0
|
447 |
$u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
|
|
indvdum@0
|
448 |
}
|
|
indvdum@0
|
449 |
else
|
|
indvdum@0
|
450 |
{
|
|
indvdum@0
|
451 |
// If the forum is a link and we count redirects we need to visit it
|
|
indvdum@0
|
452 |
// If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum
|
|
indvdum@0
|
453 |
if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id))
|
|
indvdum@0
|
454 |
{
|
|
indvdum@0
|
455 |
$u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
|
|
indvdum@0
|
456 |
}
|
|
indvdum@0
|
457 |
else
|
|
indvdum@0
|
458 |
{
|
|
indvdum@0
|
459 |
$u_viewforum = $row['forum_link'];
|
|
indvdum@0
|
460 |
}
|
|
indvdum@0
|
461 |
}
|
|
indvdum@0
|
462 |
|
|
indvdum@0
|
463 |
$template->assign_block_vars('forumrow', array(
|
|
indvdum@0
|
464 |
'S_IS_CAT' => false,
|
|
indvdum@0
|
465 |
'S_NO_CAT' => $catless && !$last_catless,
|
|
indvdum@0
|
466 |
'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false,
|
|
indvdum@0
|
467 |
'S_UNREAD_FORUM' => $forum_unread,
|
|
indvdum@0
|
468 |
'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']),
|
|
indvdum@0
|
469 |
'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false,
|
|
indvdum@0
|
470 |
'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false,
|
|
indvdum@0
|
471 |
'S_SUBFORUMS' => (sizeof($subforums_list)) ? true : false,
|
|
indvdum@0
|
472 |
'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false,
|
|
indvdum@0
|
473 |
|
|
indvdum@0
|
474 |
'FORUM_ID' => $row['forum_id'],
|
|
indvdum@0
|
475 |
'FORUM_NAME' => $row['forum_name'],
|
|
indvdum@0
|
476 |
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
|
|
indvdum@0
|
477 |
'TOPICS' => $row['forum_topics'],
|
|
indvdum@0
|
478 |
$l_post_click_count => $post_click_count,
|
|
indvdum@0
|
479 |
'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
|
|
indvdum@0
|
480 |
'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'),
|
|
indvdum@0
|
481 |
'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '',
|
|
indvdum@0
|
482 |
'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',
|
|
indvdum@0
|
483 |
'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
|
|
indvdum@0
|
484 |
'LAST_POST_SUBJECT' => censor_text($last_post_subject),
|
|
indvdum@0
|
485 |
'LAST_POST_TIME' => $last_post_time,
|
|
indvdum@0
|
486 |
'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
487 |
'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
488 |
'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
489 |
'MODERATORS' => $moderators_list,
|
|
indvdum@0
|
490 |
'SUBFORUMS' => $s_subforums_list,
|
|
indvdum@0
|
491 |
|
|
indvdum@0
|
492 |
'L_SUBFORUM_STR' => $l_subforums,
|
|
indvdum@0
|
493 |
'L_MODERATOR_STR' => $l_moderator,
|
|
indvdum@0
|
494 |
|
|
indvdum@0
|
495 |
'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '',
|
|
indvdum@0
|
496 |
'U_VIEWFORUM' => $u_viewforum,
|
|
indvdum@0
|
497 |
'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
|
|
indvdum@0
|
498 |
'U_LAST_POST' => $last_post_url)
|
|
indvdum@0
|
499 |
);
|
|
indvdum@0
|
500 |
|
|
indvdum@0
|
501 |
// Assign subforums loop for style authors
|
|
indvdum@0
|
502 |
foreach ($subforums_list as $subforum)
|
|
indvdum@0
|
503 |
{
|
|
indvdum@0
|
504 |
$template->assign_block_vars('forumrow.subforum', array(
|
|
indvdum@0
|
505 |
'U_SUBFORUM' => $subforum['link'],
|
|
indvdum@0
|
506 |
'SUBFORUM_NAME' => $subforum['name'],
|
|
indvdum@0
|
507 |
'S_UNREAD' => $subforum['unread'])
|
|
indvdum@0
|
508 |
);
|
|
indvdum@0
|
509 |
}
|
|
indvdum@0
|
510 |
|
|
indvdum@0
|
511 |
$last_catless = $catless;
|
|
indvdum@0
|
512 |
}
|
|
indvdum@0
|
513 |
|
|
indvdum@0
|
514 |
$template->assign_vars(array(
|
|
indvdum@0
|
515 |
'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums') : '',
|
|
indvdum@0
|
516 |
'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
|
|
indvdum@0
|
517 |
'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'],
|
|
indvdum@0
|
518 |
'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
|
|
indvdum@0
|
519 |
'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'),
|
|
indvdum@0
|
520 |
));
|
|
indvdum@0
|
521 |
|
|
indvdum@0
|
522 |
if ($return_moderators)
|
|
indvdum@0
|
523 |
{
|
|
indvdum@0
|
524 |
return array($active_forum_ary, $forum_moderators);
|
|
indvdum@0
|
525 |
}
|
|
indvdum@0
|
526 |
|
|
indvdum@0
|
527 |
return array($active_forum_ary, array());
|
|
indvdum@0
|
528 |
}
|
|
indvdum@0
|
529 |
|
|
indvdum@0
|
530 |
/**
|
|
indvdum@0
|
531 |
* Create forum rules for given forum
|
|
indvdum@0
|
532 |
*/
|
|
indvdum@0
|
533 |
function generate_forum_rules(&$forum_data)
|
|
indvdum@0
|
534 |
{
|
|
indvdum@0
|
535 |
if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link'])
|
|
indvdum@0
|
536 |
{
|
|
indvdum@0
|
537 |
return;
|
|
indvdum@0
|
538 |
}
|
|
indvdum@0
|
539 |
|
|
indvdum@0
|
540 |
global $template, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
541 |
|
|
indvdum@0
|
542 |
if ($forum_data['forum_rules'])
|
|
indvdum@0
|
543 |
{
|
|
indvdum@0
|
544 |
$forum_data['forum_rules'] = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']);
|
|
indvdum@0
|
545 |
}
|
|
indvdum@0
|
546 |
|
|
indvdum@0
|
547 |
$template->assign_vars(array(
|
|
indvdum@0
|
548 |
'S_FORUM_RULES' => true,
|
|
indvdum@0
|
549 |
'U_FORUM_RULES' => $forum_data['forum_rules_link'],
|
|
indvdum@0
|
550 |
'FORUM_RULES' => $forum_data['forum_rules'])
|
|
indvdum@0
|
551 |
);
|
|
indvdum@0
|
552 |
}
|
|
indvdum@0
|
553 |
|
|
indvdum@0
|
554 |
/**
|
|
indvdum@0
|
555 |
* Create forum navigation links for given forum, create parent
|
|
indvdum@0
|
556 |
* list if currently null, assign basic forum info to template
|
|
indvdum@0
|
557 |
*/
|
|
indvdum@0
|
558 |
function generate_forum_nav(&$forum_data)
|
|
indvdum@0
|
559 |
{
|
|
indvdum@0
|
560 |
global $db, $user, $template, $auth, $config;
|
|
indvdum@0
|
561 |
global $phpEx, $phpbb_root_path;
|
|
indvdum@0
|
562 |
|
|
indvdum@0
|
563 |
if (!$auth->acl_get('f_list', $forum_data['forum_id']))
|
|
indvdum@0
|
564 |
{
|
|
indvdum@0
|
565 |
return;
|
|
indvdum@0
|
566 |
}
|
|
indvdum@0
|
567 |
|
|
indvdum@0
|
568 |
// Get forum parents
|
|
indvdum@0
|
569 |
$forum_parents = get_forum_parents($forum_data);
|
|
indvdum@0
|
570 |
|
|
indvdum@0
|
571 |
// Build navigation links
|
|
indvdum@0
|
572 |
if (!empty($forum_parents))
|
|
indvdum@0
|
573 |
{
|
|
indvdum@0
|
574 |
foreach ($forum_parents as $parent_forum_id => $parent_data)
|
|
indvdum@0
|
575 |
{
|
|
indvdum@0
|
576 |
list($parent_name, $parent_type) = array_values($parent_data);
|
|
indvdum@0
|
577 |
|
|
indvdum@0
|
578 |
// Skip this parent if the user does not have the permission to view it
|
|
indvdum@0
|
579 |
if (!$auth->acl_get('f_list', $parent_forum_id))
|
|
indvdum@0
|
580 |
{
|
|
indvdum@0
|
581 |
continue;
|
|
indvdum@0
|
582 |
}
|
|
indvdum@0
|
583 |
|
|
indvdum@0
|
584 |
$template->assign_block_vars('navlinks', array(
|
|
indvdum@0
|
585 |
'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false,
|
|
indvdum@0
|
586 |
'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false,
|
|
indvdum@0
|
587 |
'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false,
|
|
indvdum@0
|
588 |
'FORUM_NAME' => $parent_name,
|
|
indvdum@0
|
589 |
'FORUM_ID' => $parent_forum_id,
|
|
indvdum@0
|
590 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id))
|
|
indvdum@0
|
591 |
);
|
|
indvdum@0
|
592 |
}
|
|
indvdum@0
|
593 |
}
|
|
indvdum@0
|
594 |
|
|
indvdum@0
|
595 |
$template->assign_block_vars('navlinks', array(
|
|
indvdum@0
|
596 |
'S_IS_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
|
|
indvdum@0
|
597 |
'S_IS_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
|
|
indvdum@0
|
598 |
'S_IS_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
|
|
indvdum@0
|
599 |
'FORUM_NAME' => $forum_data['forum_name'],
|
|
indvdum@0
|
600 |
'FORUM_ID' => $forum_data['forum_id'],
|
|
indvdum@0
|
601 |
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data['forum_id']))
|
|
indvdum@0
|
602 |
);
|
|
indvdum@0
|
603 |
|
|
indvdum@0
|
604 |
$template->assign_vars(array(
|
|
indvdum@0
|
605 |
'FORUM_ID' => $forum_data['forum_id'],
|
|
indvdum@0
|
606 |
'FORUM_NAME' => $forum_data['forum_name'],
|
|
indvdum@0
|
607 |
'FORUM_DESC' => generate_text_for_display($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options']),
|
|
indvdum@0
|
608 |
|
|
indvdum@0
|
609 |
'S_ENABLE_FEEDS_FORUM' => ($config['feed_forum'] && $forum_data['forum_type'] == FORUM_POST && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $forum_data['forum_options'])) ? true : false,
|
|
indvdum@0
|
610 |
));
|
|
indvdum@0
|
611 |
|
|
indvdum@0
|
612 |
return;
|
|
indvdum@0
|
613 |
}
|
|
indvdum@0
|
614 |
|
|
indvdum@0
|
615 |
/**
|
|
indvdum@0
|
616 |
* Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise
|
|
indvdum@0
|
617 |
*/
|
|
indvdum@0
|
618 |
function get_forum_parents(&$forum_data)
|
|
indvdum@0
|
619 |
{
|
|
indvdum@0
|
620 |
global $db;
|
|
indvdum@0
|
621 |
|
|
indvdum@0
|
622 |
$forum_parents = array();
|
|
indvdum@0
|
623 |
|
|
indvdum@0
|
624 |
if ($forum_data['parent_id'] > 0)
|
|
indvdum@0
|
625 |
{
|
|
indvdum@0
|
626 |
if ($forum_data['forum_parents'] == '')
|
|
indvdum@0
|
627 |
{
|
|
indvdum@0
|
628 |
$sql = 'SELECT forum_id, forum_name, forum_type
|
|
indvdum@0
|
629 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
630 |
WHERE left_id < ' . $forum_data['left_id'] . '
|
|
indvdum@0
|
631 |
AND right_id > ' . $forum_data['right_id'] . '
|
|
indvdum@0
|
632 |
ORDER BY left_id ASC';
|
|
indvdum@0
|
633 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
634 |
|
|
indvdum@0
|
635 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
636 |
{
|
|
indvdum@0
|
637 |
$forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']);
|
|
indvdum@0
|
638 |
}
|
|
indvdum@0
|
639 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
640 |
|
|
indvdum@0
|
641 |
$forum_data['forum_parents'] = serialize($forum_parents);
|
|
indvdum@0
|
642 |
|
|
indvdum@0
|
643 |
$sql = 'UPDATE ' . FORUMS_TABLE . "
|
|
indvdum@0
|
644 |
SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "'
|
|
indvdum@0
|
645 |
WHERE parent_id = " . $forum_data['parent_id'];
|
|
indvdum@0
|
646 |
$db->sql_query($sql);
|
|
indvdum@0
|
647 |
}
|
|
indvdum@0
|
648 |
else
|
|
indvdum@0
|
649 |
{
|
|
indvdum@0
|
650 |
$forum_parents = unserialize($forum_data['forum_parents']);
|
|
indvdum@0
|
651 |
}
|
|
indvdum@0
|
652 |
}
|
|
indvdum@0
|
653 |
|
|
indvdum@0
|
654 |
return $forum_parents;
|
|
indvdum@0
|
655 |
}
|
|
indvdum@0
|
656 |
|
|
indvdum@0
|
657 |
/**
|
|
indvdum@0
|
658 |
* Generate topic pagination
|
|
indvdum@0
|
659 |
*/
|
|
indvdum@0
|
660 |
function topic_generate_pagination($replies, $url)
|
|
indvdum@0
|
661 |
{
|
|
indvdum@0
|
662 |
global $config, $user;
|
|
indvdum@0
|
663 |
|
|
indvdum@0
|
664 |
// Make sure $per_page is a valid value
|
|
indvdum@0
|
665 |
$per_page = ($config['posts_per_page'] <= 0) ? 1 : $config['posts_per_page'];
|
|
indvdum@0
|
666 |
|
|
indvdum@0
|
667 |
if (($replies + 1) > $per_page)
|
|
indvdum@0
|
668 |
{
|
|
indvdum@0
|
669 |
$total_pages = ceil(($replies + 1) / $per_page);
|
|
indvdum@0
|
670 |
$pagination = '';
|
|
indvdum@0
|
671 |
|
|
indvdum@0
|
672 |
$times = 1;
|
|
indvdum@0
|
673 |
for ($j = 0; $j < $replies + 1; $j += $per_page)
|
|
indvdum@0
|
674 |
{
|
|
indvdum@0
|
675 |
$pagination .= '<a href="' . $url . ($j == 0 ? '' : '&start=' . $j) . '">' . $times . '</a>';
|
|
indvdum@0
|
676 |
if ($times == 1 && $total_pages > 5)
|
|
indvdum@0
|
677 |
{
|
|
indvdum@0
|
678 |
$pagination .= '<span class="page-dots"> ... </span>';
|
|
indvdum@0
|
679 |
|
|
indvdum@0
|
680 |
// Display the last three pages
|
|
indvdum@0
|
681 |
$times = $total_pages - 3;
|
|
indvdum@0
|
682 |
$j += ($total_pages - 4) * $per_page;
|
|
indvdum@0
|
683 |
}
|
|
indvdum@0
|
684 |
else if ($times < $total_pages)
|
|
indvdum@0
|
685 |
{
|
|
indvdum@0
|
686 |
$pagination .= '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
|
|
indvdum@0
|
687 |
}
|
|
indvdum@0
|
688 |
$times++;
|
|
indvdum@0
|
689 |
}
|
|
indvdum@0
|
690 |
}
|
|
indvdum@0
|
691 |
else
|
|
indvdum@0
|
692 |
{
|
|
indvdum@0
|
693 |
$pagination = '';
|
|
indvdum@0
|
694 |
}
|
|
indvdum@0
|
695 |
|
|
indvdum@0
|
696 |
return $pagination;
|
|
indvdum@0
|
697 |
}
|
|
indvdum@0
|
698 |
|
|
indvdum@0
|
699 |
/**
|
|
indvdum@0
|
700 |
* Obtain list of moderators of each forum
|
|
indvdum@0
|
701 |
*/
|
|
indvdum@0
|
702 |
function get_moderators(&$forum_moderators, $forum_id = false)
|
|
indvdum@0
|
703 |
{
|
|
indvdum@0
|
704 |
global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth;
|
|
indvdum@0
|
705 |
|
|
indvdum@0
|
706 |
$forum_id_ary = array();
|
|
indvdum@0
|
707 |
|
|
indvdum@0
|
708 |
if ($forum_id !== false)
|
|
indvdum@0
|
709 |
{
|
|
indvdum@0
|
710 |
if (!is_array($forum_id))
|
|
indvdum@0
|
711 |
{
|
|
indvdum@0
|
712 |
$forum_id = array($forum_id);
|
|
indvdum@0
|
713 |
}
|
|
indvdum@0
|
714 |
|
|
indvdum@0
|
715 |
// Exchange key/value pair to be able to faster check for the forum id existence
|
|
indvdum@0
|
716 |
$forum_id_ary = array_flip($forum_id);
|
|
indvdum@0
|
717 |
}
|
|
indvdum@0
|
718 |
|
|
indvdum@0
|
719 |
$sql_array = array(
|
|
indvdum@0
|
720 |
'SELECT' => 'm.*, u.user_colour, g.group_colour, g.group_type',
|
|
indvdum@0
|
721 |
|
|
indvdum@0
|
722 |
'FROM' => array(
|
|
indvdum@0
|
723 |
MODERATOR_CACHE_TABLE => 'm',
|
|
indvdum@0
|
724 |
),
|
|
indvdum@0
|
725 |
|
|
indvdum@0
|
726 |
'LEFT_JOIN' => array(
|
|
indvdum@0
|
727 |
array(
|
|
indvdum@0
|
728 |
'FROM' => array(USERS_TABLE => 'u'),
|
|
indvdum@0
|
729 |
'ON' => 'm.user_id = u.user_id',
|
|
indvdum@0
|
730 |
),
|
|
indvdum@0
|
731 |
array(
|
|
indvdum@0
|
732 |
'FROM' => array(GROUPS_TABLE => 'g'),
|
|
indvdum@0
|
733 |
'ON' => 'm.group_id = g.group_id',
|
|
indvdum@0
|
734 |
),
|
|
indvdum@0
|
735 |
),
|
|
indvdum@0
|
736 |
|
|
indvdum@0
|
737 |
'WHERE' => 'm.display_on_index = 1',
|
|
indvdum@0
|
738 |
);
|
|
indvdum@0
|
739 |
|
|
indvdum@0
|
740 |
// We query every forum here because for caching we should not have any parameter.
|
|
indvdum@0
|
741 |
$sql = $db->sql_build_query('SELECT', $sql_array);
|
|
indvdum@0
|
742 |
$result = $db->sql_query($sql, 3600);
|
|
indvdum@0
|
743 |
|
|
indvdum@0
|
744 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
745 |
{
|
|
indvdum@0
|
746 |
$f_id = (int) $row['forum_id'];
|
|
indvdum@0
|
747 |
|
|
indvdum@0
|
748 |
if (!isset($forum_id_ary[$f_id]))
|
|
indvdum@0
|
749 |
{
|
|
indvdum@0
|
750 |
continue;
|
|
indvdum@0
|
751 |
}
|
|
indvdum@0
|
752 |
|
|
indvdum@0
|
753 |
if (!empty($row['user_id']))
|
|
indvdum@0
|
754 |
{
|
|
indvdum@0
|
755 |
$forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
|
|
indvdum@0
|
756 |
}
|
|
indvdum@0
|
757 |
else
|
|
indvdum@0
|
758 |
{
|
|
indvdum@0
|
759 |
$group_name = (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']);
|
|
indvdum@0
|
760 |
|
|
indvdum@0
|
761 |
if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))
|
|
indvdum@0
|
762 |
{
|
|
indvdum@0
|
763 |
$forum_moderators[$f_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>';
|
|
indvdum@0
|
764 |
}
|
|
indvdum@0
|
765 |
else
|
|
indvdum@0
|
766 |
{
|
|
indvdum@0
|
767 |
$forum_moderators[$f_id][] = '<a' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&g=' . $row['group_id']) . '">' . $group_name . '</a>';
|
|
indvdum@0
|
768 |
}
|
|
indvdum@0
|
769 |
}
|
|
indvdum@0
|
770 |
}
|
|
indvdum@0
|
771 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
772 |
|
|
indvdum@0
|
773 |
return;
|
|
indvdum@0
|
774 |
}
|
|
indvdum@0
|
775 |
|
|
indvdum@0
|
776 |
/**
|
|
indvdum@0
|
777 |
* User authorisation levels output
|
|
indvdum@0
|
778 |
*
|
|
indvdum@0
|
779 |
* @param string $mode Can be forum or topic. Not in use at the moment.
|
|
indvdum@0
|
780 |
* @param int $forum_id The current forum the user is in.
|
|
indvdum@0
|
781 |
* @param int $forum_status The forums status bit.
|
|
indvdum@0
|
782 |
*/
|
|
indvdum@0
|
783 |
function gen_forum_auth_level($mode, $forum_id, $forum_status)
|
|
indvdum@0
|
784 |
{
|
|
indvdum@0
|
785 |
global $template, $auth, $user, $config;
|
|
indvdum@0
|
786 |
|
|
indvdum@0
|
787 |
$locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false;
|
|
indvdum@0
|
788 |
|
|
indvdum@0
|
789 |
$rules = array(
|
|
indvdum@0
|
790 |
($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'],
|
|
indvdum@0
|
791 |
($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'],
|
|
indvdum@0
|
792 |
($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'],
|
|
indvdum@0
|
793 |
($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'],
|
|
indvdum@0
|
794 |
);
|
|
indvdum@0
|
795 |
|
|
indvdum@0
|
796 |
if ($config['allow_attachments'])
|
|
indvdum@0
|
797 |
{
|
|
indvdum@0
|
798 |
$rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT'];
|
|
indvdum@0
|
799 |
}
|
|
indvdum@0
|
800 |
|
|
indvdum@0
|
801 |
foreach ($rules as $rule)
|
|
indvdum@0
|
802 |
{
|
|
indvdum@0
|
803 |
$template->assign_block_vars('rules', array('RULE' => $rule));
|
|
indvdum@0
|
804 |
}
|
|
indvdum@0
|
805 |
|
|
indvdum@0
|
806 |
return;
|
|
indvdum@0
|
807 |
}
|
|
indvdum@0
|
808 |
|
|
indvdum@0
|
809 |
/**
|
|
indvdum@0
|
810 |
* Generate topic status
|
|
indvdum@0
|
811 |
*/
|
|
indvdum@0
|
812 |
function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type)
|
|
indvdum@0
|
813 |
{
|
|
indvdum@0
|
814 |
global $user, $config;
|
|
indvdum@0
|
815 |
|
|
indvdum@0
|
816 |
$folder = $folder_new = '';
|
|
indvdum@0
|
817 |
|
|
indvdum@0
|
818 |
if ($topic_row['topic_status'] == ITEM_MOVED)
|
|
indvdum@0
|
819 |
{
|
|
indvdum@0
|
820 |
$topic_type = $user->lang['VIEW_TOPIC_MOVED'];
|
|
indvdum@0
|
821 |
$folder_img = 'topic_moved';
|
|
indvdum@0
|
822 |
$folder_alt = 'TOPIC_MOVED';
|
|
indvdum@0
|
823 |
}
|
|
indvdum@0
|
824 |
else
|
|
indvdum@0
|
825 |
{
|
|
indvdum@0
|
826 |
switch ($topic_row['topic_type'])
|
|
indvdum@0
|
827 |
{
|
|
indvdum@0
|
828 |
case POST_GLOBAL:
|
|
indvdum@0
|
829 |
$topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
|
|
indvdum@0
|
830 |
$folder = 'global_read';
|
|
indvdum@0
|
831 |
$folder_new = 'global_unread';
|
|
indvdum@0
|
832 |
break;
|
|
indvdum@0
|
833 |
|
|
indvdum@0
|
834 |
case POST_ANNOUNCE:
|
|
indvdum@0
|
835 |
$topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
|
|
indvdum@0
|
836 |
$folder = 'announce_read';
|
|
indvdum@0
|
837 |
$folder_new = 'announce_unread';
|
|
indvdum@0
|
838 |
break;
|
|
indvdum@0
|
839 |
|
|
indvdum@0
|
840 |
case POST_STICKY:
|
|
indvdum@0
|
841 |
$topic_type = $user->lang['VIEW_TOPIC_STICKY'];
|
|
indvdum@0
|
842 |
$folder = 'sticky_read';
|
|
indvdum@0
|
843 |
$folder_new = 'sticky_unread';
|
|
indvdum@0
|
844 |
break;
|
|
indvdum@0
|
845 |
|
|
indvdum@0
|
846 |
default:
|
|
indvdum@0
|
847 |
$topic_type = '';
|
|
indvdum@0
|
848 |
$folder = 'topic_read';
|
|
indvdum@0
|
849 |
$folder_new = 'topic_unread';
|
|
indvdum@0
|
850 |
|
|
indvdum@0
|
851 |
// Hot topic threshold is for posts in a topic, which is replies + the first post. ;)
|
|
indvdum@0
|
852 |
if ($config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED)
|
|
indvdum@0
|
853 |
{
|
|
indvdum@0
|
854 |
$folder .= '_hot';
|
|
indvdum@0
|
855 |
$folder_new .= '_hot';
|
|
indvdum@0
|
856 |
}
|
|
indvdum@0
|
857 |
break;
|
|
indvdum@0
|
858 |
}
|
|
indvdum@0
|
859 |
|
|
indvdum@0
|
860 |
if ($topic_row['topic_status'] == ITEM_LOCKED)
|
|
indvdum@0
|
861 |
{
|
|
indvdum@0
|
862 |
$topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
|
|
indvdum@0
|
863 |
$folder .= '_locked';
|
|
indvdum@0
|
864 |
$folder_new .= '_locked';
|
|
indvdum@0
|
865 |
}
|
|
indvdum@0
|
866 |
|
|
indvdum@0
|
867 |
|
|
indvdum@0
|
868 |
$folder_img = ($unread_topic) ? $folder_new : $folder;
|
|
indvdum@0
|
869 |
$folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS');
|
|
indvdum@0
|
870 |
|
|
indvdum@0
|
871 |
// Posted image?
|
|
indvdum@0
|
872 |
if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted'])
|
|
indvdum@0
|
873 |
{
|
|
indvdum@0
|
874 |
$folder_img .= '_mine';
|
|
indvdum@0
|
875 |
}
|
|
indvdum@0
|
876 |
}
|
|
indvdum@0
|
877 |
|
|
indvdum@0
|
878 |
if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED)
|
|
indvdum@0
|
879 |
{
|
|
indvdum@0
|
880 |
$topic_type = $user->lang['VIEW_TOPIC_POLL'];
|
|
indvdum@0
|
881 |
}
|
|
indvdum@0
|
882 |
}
|
|
indvdum@0
|
883 |
|
|
indvdum@0
|
884 |
/**
|
|
indvdum@0
|
885 |
* Assign/Build custom bbcodes for display in screens supporting using of bbcodes
|
|
indvdum@0
|
886 |
* The custom bbcodes buttons will be placed within the template block 'custom_codes'
|
|
indvdum@0
|
887 |
*/
|
|
indvdum@0
|
888 |
function display_custom_bbcodes()
|
|
indvdum@0
|
889 |
{
|
|
indvdum@0
|
890 |
global $db, $template, $user;
|
|
indvdum@0
|
891 |
|
|
indvdum@0
|
892 |
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
|
|
indvdum@0
|
893 |
$num_predefined_bbcodes = 22;
|
|
indvdum@0
|
894 |
|
|
indvdum@0
|
895 |
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
|
|
indvdum@0
|
896 |
FROM ' . BBCODES_TABLE . '
|
|
indvdum@0
|
897 |
WHERE display_on_posting = 1
|
|
indvdum@0
|
898 |
ORDER BY bbcode_tag';
|
|
indvdum@0
|
899 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
900 |
|
|
indvdum@0
|
901 |
$i = 0;
|
|
indvdum@0
|
902 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
903 |
{
|
|
indvdum@0
|
904 |
// If the helpline is defined within the language file, we will use the localised version, else just use the database entry...
|
|
indvdum@0
|
905 |
if (isset($user->lang[strtoupper($row['bbcode_helpline'])]))
|
|
indvdum@0
|
906 |
{
|
|
indvdum@0
|
907 |
$row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])];
|
|
indvdum@0
|
908 |
}
|
|
indvdum@0
|
909 |
|
|
indvdum@0
|
910 |
$template->assign_block_vars('custom_tags', array(
|
|
indvdum@0
|
911 |
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
|
|
indvdum@0
|
912 |
'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2),
|
|
indvdum@0
|
913 |
'BBCODE_TAG' => $row['bbcode_tag'],
|
|
indvdum@0
|
914 |
'BBCODE_HELPLINE' => $row['bbcode_helpline'],
|
|
indvdum@0
|
915 |
'A_BBCODE_HELPLINE' => str_replace(array('&', '"', "'", '<', '>'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
|
|
indvdum@0
|
916 |
));
|
|
indvdum@0
|
917 |
|
|
indvdum@0
|
918 |
$i++;
|
|
indvdum@0
|
919 |
}
|
|
indvdum@0
|
920 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
921 |
}
|
|
indvdum@0
|
922 |
|
|
indvdum@0
|
923 |
/**
|
|
indvdum@0
|
924 |
* Display reasons
|
|
indvdum@0
|
925 |
*/
|
|
indvdum@0
|
926 |
function display_reasons($reason_id = 0)
|
|
indvdum@0
|
927 |
{
|
|
indvdum@0
|
928 |
global $db, $user, $template;
|
|
indvdum@0
|
929 |
|
|
indvdum@0
|
930 |
$sql = 'SELECT *
|
|
indvdum@0
|
931 |
FROM ' . REPORTS_REASONS_TABLE . '
|
|
indvdum@0
|
932 |
ORDER BY reason_order ASC';
|
|
indvdum@0
|
933 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
934 |
|
|
indvdum@0
|
935 |
while ($row = $db->sql_fetchrow($result))
|
|
indvdum@0
|
936 |
{
|
|
indvdum@0
|
937 |
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
|
|
indvdum@0
|
938 |
if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
|
|
indvdum@0
|
939 |
{
|
|
indvdum@0
|
940 |
$row['reason_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
|
|
indvdum@0
|
941 |
$row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
|
|
indvdum@0
|
942 |
}
|
|
indvdum@0
|
943 |
|
|
indvdum@0
|
944 |
$template->assign_block_vars('reason', array(
|
|
indvdum@0
|
945 |
'ID' => $row['reason_id'],
|
|
indvdum@0
|
946 |
'TITLE' => $row['reason_title'],
|
|
indvdum@0
|
947 |
'DESCRIPTION' => $row['reason_description'],
|
|
indvdum@0
|
948 |
'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false)
|
|
indvdum@0
|
949 |
);
|
|
indvdum@0
|
950 |
}
|
|
indvdum@0
|
951 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
952 |
}
|
|
indvdum@0
|
953 |
|
|
indvdum@0
|
954 |
/**
|
|
indvdum@0
|
955 |
* Display user activity (action forum/topic)
|
|
indvdum@0
|
956 |
*/
|
|
indvdum@0
|
957 |
function display_user_activity(&$userdata)
|
|
indvdum@0
|
958 |
{
|
|
indvdum@0
|
959 |
global $auth, $template, $db, $user;
|
|
indvdum@0
|
960 |
global $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
961 |
|
|
indvdum@0
|
962 |
// Do not display user activity for users having more than 5000 posts...
|
|
indvdum@0
|
963 |
if ($userdata['user_posts'] > 5000)
|
|
indvdum@0
|
964 |
{
|
|
indvdum@0
|
965 |
return;
|
|
indvdum@0
|
966 |
}
|
|
indvdum@0
|
967 |
|
|
indvdum@0
|
968 |
$forum_ary = array();
|
|
indvdum@0
|
969 |
|
|
indvdum@0
|
970 |
// Do not include those forums the user is not having read access to...
|
|
indvdum@0
|
971 |
$forum_read_ary = $auth->acl_getf('!f_read');
|
|
indvdum@0
|
972 |
|
|
indvdum@0
|
973 |
foreach ($forum_read_ary as $forum_id => $not_allowed)
|
|
indvdum@0
|
974 |
{
|
|
indvdum@0
|
975 |
if ($not_allowed['f_read'])
|
|
indvdum@0
|
976 |
{
|
|
indvdum@0
|
977 |
$forum_ary[] = (int) $forum_id;
|
|
indvdum@0
|
978 |
}
|
|
indvdum@0
|
979 |
}
|
|
indvdum@0
|
980 |
|
|
indvdum@0
|
981 |
$forum_ary = array_unique($forum_ary);
|
|
indvdum@0
|
982 |
$forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : '';
|
|
indvdum@0
|
983 |
|
|
indvdum@0
|
984 |
$fid_m_approve = $auth->acl_getf('m_approve', true);
|
|
indvdum@0
|
985 |
$sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', array_keys($fid_m_approve)) : '';
|
|
indvdum@0
|
986 |
|
|
indvdum@0
|
987 |
// Obtain active forum
|
|
indvdum@0
|
988 |
$sql = 'SELECT forum_id, COUNT(post_id) AS num_posts
|
|
indvdum@0
|
989 |
FROM ' . POSTS_TABLE . '
|
|
indvdum@0
|
990 |
WHERE poster_id = ' . $userdata['user_id'] . "
|
|
indvdum@0
|
991 |
AND post_postcount = 1
|
|
indvdum@0
|
992 |
AND (post_approved = 1
|
|
indvdum@0
|
993 |
$sql_m_approve)
|
|
indvdum@0
|
994 |
$forum_sql
|
|
indvdum@0
|
995 |
GROUP BY forum_id
|
|
indvdum@0
|
996 |
ORDER BY num_posts DESC";
|
|
indvdum@0
|
997 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
998 |
$active_f_row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
999 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1000 |
|
|
indvdum@0
|
1001 |
if (!empty($active_f_row))
|
|
indvdum@0
|
1002 |
{
|
|
indvdum@0
|
1003 |
$sql = 'SELECT forum_name
|
|
indvdum@0
|
1004 |
FROM ' . FORUMS_TABLE . '
|
|
indvdum@0
|
1005 |
WHERE forum_id = ' . $active_f_row['forum_id'];
|
|
indvdum@0
|
1006 |
$result = $db->sql_query($sql, 3600);
|
|
indvdum@0
|
1007 |
$active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');
|
|
indvdum@0
|
1008 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1009 |
}
|
|
indvdum@0
|
1010 |
|
|
indvdum@0
|
1011 |
// Obtain active topic
|
|
indvdum@0
|
1012 |
// We need to exclude passworded forums here so we do not leak the topic title
|
|
indvdum@0
|
1013 |
$forum_ary_topic = array_unique(array_merge($forum_ary, $user->get_passworded_forums()));
|
|
indvdum@0
|
1014 |
$forum_sql_topic = (!empty($forum_ary_topic)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary_topic, true) : '';
|
|
indvdum@0
|
1015 |
|
|
indvdum@0
|
1016 |
$sql = 'SELECT topic_id, COUNT(post_id) AS num_posts
|
|
indvdum@0
|
1017 |
FROM ' . POSTS_TABLE . '
|
|
indvdum@0
|
1018 |
WHERE poster_id = ' . $userdata['user_id'] . "
|
|
indvdum@0
|
1019 |
AND post_postcount = 1
|
|
indvdum@0
|
1020 |
AND (post_approved = 1
|
|
indvdum@0
|
1021 |
$sql_m_approve)
|
|
indvdum@0
|
1022 |
$forum_sql_topic
|
|
indvdum@0
|
1023 |
GROUP BY topic_id
|
|
indvdum@0
|
1024 |
ORDER BY num_posts DESC";
|
|
indvdum@0
|
1025 |
$result = $db->sql_query_limit($sql, 1);
|
|
indvdum@0
|
1026 |
$active_t_row = $db->sql_fetchrow($result);
|
|
indvdum@0
|
1027 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1028 |
|
|
indvdum@0
|
1029 |
if (!empty($active_t_row))
|
|
indvdum@0
|
1030 |
{
|
|
indvdum@0
|
1031 |
$sql = 'SELECT topic_title
|
|
indvdum@0
|
1032 |
FROM ' . TOPICS_TABLE . '
|
|
indvdum@0
|
1033 |
WHERE topic_id = ' . $active_t_row['topic_id'];
|
|
indvdum@0
|
1034 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1035 |
$active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title');
|
|
indvdum@0
|
1036 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1037 |
}
|
|
indvdum@0
|
1038 |
|
|
indvdum@0
|
1039 |
$userdata['active_t_row'] = $active_t_row;
|
|
indvdum@0
|
1040 |
$userdata['active_f_row'] = $active_f_row;
|
|
indvdum@0
|
1041 |
|
|
indvdum@0
|
1042 |
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
|
|
indvdum@0
|
1043 |
if (!empty($active_f_row['num_posts']))
|
|
indvdum@0
|
1044 |
{
|
|
indvdum@0
|
1045 |
$active_f_name = $active_f_row['forum_name'];
|
|
indvdum@0
|
1046 |
$active_f_id = $active_f_row['forum_id'];
|
|
indvdum@0
|
1047 |
$active_f_count = $active_f_row['num_posts'];
|
|
indvdum@0
|
1048 |
$active_f_pct = ($userdata['user_posts']) ? ($active_f_count / $userdata['user_posts']) * 100 : 0;
|
|
indvdum@0
|
1049 |
}
|
|
indvdum@0
|
1050 |
|
|
indvdum@0
|
1051 |
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
|
indvdum@0
|
1052 |
if (!empty($active_t_row['num_posts']))
|
|
indvdum@0
|
1053 |
{
|
|
indvdum@0
|
1054 |
$active_t_name = $active_t_row['topic_title'];
|
|
indvdum@0
|
1055 |
$active_t_id = $active_t_row['topic_id'];
|
|
indvdum@0
|
1056 |
$active_t_count = $active_t_row['num_posts'];
|
|
indvdum@0
|
1057 |
$active_t_pct = ($userdata['user_posts']) ? ($active_t_count / $userdata['user_posts']) * 100 : 0;
|
|
indvdum@0
|
1058 |
}
|
|
indvdum@0
|
1059 |
|
|
indvdum@0
|
1060 |
$l_active_pct = ($userdata['user_id'] != ANONYMOUS && $userdata['user_id'] == $user->data['user_id']) ? $user->lang['POST_PCT_ACTIVE_OWN'] : $user->lang['POST_PCT_ACTIVE'];
|
|
indvdum@0
|
1061 |
|
|
indvdum@0
|
1062 |
$template->assign_vars(array(
|
|
indvdum@0
|
1063 |
'ACTIVE_FORUM' => $active_f_name,
|
|
indvdum@0
|
1064 |
'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
|
indvdum@0
|
1065 |
'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct),
|
|
indvdum@0
|
1066 |
'ACTIVE_TOPIC' => censor_text($active_t_name),
|
|
indvdum@0
|
1067 |
'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
|
indvdum@0
|
1068 |
'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct),
|
|
indvdum@0
|
1069 |
'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id),
|
|
indvdum@0
|
1070 |
'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id),
|
|
indvdum@0
|
1071 |
'S_SHOW_ACTIVITY' => true)
|
|
indvdum@0
|
1072 |
);
|
|
indvdum@0
|
1073 |
}
|
|
indvdum@0
|
1074 |
|
|
indvdum@0
|
1075 |
/**
|
|
indvdum@0
|
1076 |
* Topic and forum watching common code
|
|
indvdum@0
|
1077 |
*/
|
|
indvdum@0
|
1078 |
function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '')
|
|
indvdum@0
|
1079 |
{
|
|
indvdum@0
|
1080 |
global $template, $db, $user, $phpEx, $start, $phpbb_root_path;
|
|
indvdum@0
|
1081 |
|
|
indvdum@0
|
1082 |
$table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
|
|
indvdum@0
|
1083 |
$where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
|
|
indvdum@0
|
1084 |
$match_id = ($mode == 'forum') ? $forum_id : $topic_id;
|
|
indvdum@0
|
1085 |
$u_url = "uid={$user->data['user_id']}";
|
|
indvdum@0
|
1086 |
$u_url .= ($mode == 'forum') ? '&f' : '&f=' . $forum_id . '&t';
|
|
indvdum@0
|
1087 |
$is_watching = 0;
|
|
indvdum@0
|
1088 |
|
|
indvdum@0
|
1089 |
// Is user watching this thread?
|
|
indvdum@0
|
1090 |
if ($user_id != ANONYMOUS)
|
|
indvdum@0
|
1091 |
{
|
|
indvdum@0
|
1092 |
$can_watch = true;
|
|
indvdum@0
|
1093 |
|
|
indvdum@0
|
1094 |
if ($notify_status == 'unset')
|
|
indvdum@0
|
1095 |
{
|
|
indvdum@0
|
1096 |
$sql = "SELECT notify_status
|
|
indvdum@0
|
1097 |
FROM $table_sql
|
|
indvdum@0
|
1098 |
WHERE $where_sql = $match_id
|
|
indvdum@0
|
1099 |
AND user_id = $user_id";
|
|
indvdum@0
|
1100 |
$result = $db->sql_query($sql);
|
|
indvdum@0
|
1101 |
|
|
indvdum@0
|
1102 |
$notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
|
|
indvdum@0
|
1103 |
$db->sql_freeresult($result);
|
|
indvdum@0
|
1104 |
}
|
|
indvdum@0
|
1105 |
|
|
indvdum@0
|
1106 |
if (!is_null($notify_status) && $notify_status !== '')
|
|
indvdum@0
|
1107 |
{
|
|
indvdum@0
|
1108 |
|
|
indvdum@0
|
1109 |
if (isset($_GET['unwatch']))
|
|
indvdum@0
|
1110 |
{
|
|
indvdum@0
|
1111 |
$uid = request_var('uid', 0);
|
|
indvdum@0
|
1112 |
$token = request_var('hash', '');
|
|
indvdum@0
|
1113 |
|
|
indvdum@0
|
1114 |
if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true))
|
|
indvdum@0
|
1115 |
{
|
|
indvdum@0
|
1116 |
if ($uid != $user_id || $_GET['unwatch'] != $mode)
|
|
indvdum@0
|
1117 |
{
|
|
indvdum@0
|
1118 |
$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
|
|
indvdum@0
|
1119 |
$message = $user->lang['ERR_UNWATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
|
indvdum@0
|
1120 |
trigger_error($message);
|
|
indvdum@0
|
1121 |
}
|
|
indvdum@0
|
1122 |
|
|
indvdum@0
|
1123 |
$sql = 'DELETE FROM ' . $table_sql . "
|
|
indvdum@0
|
1124 |
WHERE $where_sql = $match_id
|
|
indvdum@0
|
1125 |
AND user_id = $user_id";
|
|
indvdum@0
|
1126 |
$db->sql_query($sql);
|
|
indvdum@0
|
1127 |
|
|
indvdum@0
|
1128 |
$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
|
|
indvdum@0
|
1129 |
$message = $user->lang['NOT_WATCHING_' . strtoupper($mode)] . '<br /><br />';
|
|
indvdum@0
|
1130 |
$message .= sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
|
indvdum@0
|
1131 |
meta_refresh(3, $redirect_url);
|
|
indvdum@0
|
1132 |
trigger_error($message);
|
|
indvdum@0
|
1133 |
}
|
|
indvdum@0
|
1134 |
else
|
|
indvdum@0
|
1135 |
{
|
|
indvdum@0
|
1136 |
$s_hidden_fields = array(
|
|
indvdum@0
|
1137 |
'uid' => $user->data['user_id'],
|
|
indvdum@0
|
1138 |
'unwatch' => $mode,
|
|
indvdum@0
|
1139 |
'start' => $start,
|
|
indvdum@0
|
1140 |
'f' => $forum_id,
|
|
indvdum@0
|
1141 |
);
|
|
indvdum@0
|
1142 |
if ($mode != 'forum')
|
|
indvdum@0
|
1143 |
{
|
|
indvdum@0
|
1144 |
$s_hidden_fields['t'] = $topic_id;
|
|
indvdum@0
|
1145 |
}
|
|
indvdum@0
|
1146 |
|
|
indvdum@0
|
1147 |
if ($item_title == '')
|
|
indvdum@0
|
1148 |
{
|
|
indvdum@0
|
1149 |
$confirm_box_message = 'UNWATCH_' . strtoupper($mode);
|
|
indvdum@0
|
1150 |
}
|
|
indvdum@0
|
1151 |
else
|
|
indvdum@0
|
1152 |
{
|
|
indvdum@0
|
1153 |
$confirm_box_message = $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title);
|
|
indvdum@0
|
1154 |
}
|
|
indvdum@0
|
1155 |
confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields));
|
|
indvdum@0
|
1156 |
}
|
|
indvdum@0
|
1157 |
}
|
|
indvdum@0
|
1158 |
else
|
|
indvdum@0
|
1159 |
{
|
|
indvdum@0
|
1160 |
$is_watching = true;
|
|
indvdum@0
|
1161 |
|
|
indvdum@0
|
1162 |
if ($notify_status != NOTIFY_YES)
|
|
indvdum@0
|
1163 |
{
|
|
indvdum@0
|
1164 |
$sql = 'UPDATE ' . $table_sql . "
|
|
indvdum@0
|
1165 |
SET notify_status = " . NOTIFY_YES . "
|
|
indvdum@0
|
1166 |
WHERE $where_sql = $match_id
|
|
indvdum@0
|
1167 |
AND user_id = $user_id";
|
|
indvdum@0
|
1168 |
$db->sql_query($sql);
|
|
indvdum@0
|
1169 |
}
|
|
indvdum@0
|
1170 |
}
|
|
indvdum@0
|
1171 |
}
|
|
indvdum@0
|
1172 |
else
|
|
indvdum@0
|
1173 |
{
|
|
indvdum@0
|
1174 |
if (isset($_GET['watch']))
|
|
indvdum@0
|
1175 |
{
|
|
indvdum@0
|
1176 |
$uid = request_var('uid', 0);
|
|
indvdum@0
|
1177 |
$token = request_var('hash', '');
|
|
indvdum@0
|
1178 |
|
|
indvdum@0
|
1179 |
if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true))
|
|
indvdum@0
|
1180 |
{
|
|
indvdum@0
|
1181 |
if ($uid != $user_id || $_GET['watch'] != $mode)
|
|
indvdum@0
|
1182 |
{
|
|
indvdum@0
|
1183 |
$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
|
|
indvdum@0
|
1184 |
$message = $user->lang['ERR_WATCHING'] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
|
indvdum@0
|
1185 |
trigger_error($message);
|
|
indvdum@0
|
1186 |
}
|
|
indvdum@0
|
1187 |
|
|
indvdum@0
|
1188 |
$is_watching = true;
|
|
indvdum@0
|
1189 |
|
|
indvdum@0
|
1190 |
$sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
|
|
indvdum@0
|
1191 |
VALUES ($user_id, $match_id, " . NOTIFY_YES . ')';
|
|
indvdum@0
|
1192 |
$db->sql_query($sql);
|
|
indvdum@0
|
1193 |
|
|
indvdum@0
|
1194 |
$redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
|
|
indvdum@0
|
1195 |
$message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '<br /><br />' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '<a href="' . $redirect_url . '">', '</a>');
|
|
indvdum@0
|
1196 |
meta_refresh(3, $redirect_url);
|
|
indvdum@0
|
1197 |
trigger_error($message);
|
|
indvdum@0
|
1198 |
}
|
|
indvdum@0
|
1199 |
else
|
|
indvdum@0
|
1200 |
{
|
|
indvdum@0
|
1201 |
$s_hidden_fields = array(
|
|
indvdum@0
|
1202 |
'uid' => $user->data['user_id'],
|
|
indvdum@0
|
1203 |
'watch' => $mode,
|
|
indvdum@0
|
1204 |
'start' => $start,
|
|
indvdum@0
|
1205 |
'f' => $forum_id,
|
|
indvdum@0
|
1206 |
);
|
|
indvdum@0
|
1207 |
if ($mode != 'forum')
|
|
indvdum@0
|
1208 |
{
|
|
indvdum@0
|
1209 |
$s_hidden_fields['t'] = $topic_id;
|
|
indvdum@0
|
1210 |
}
|
|
indvdum@0
|
1211 |
|
|
indvdum@0
|
1212 |
$confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title));
|
|
indvdum@0
|
1213 |
confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields));
|
|
indvdum@0
|
1214 |
}
|
|
indvdum@0
|
1215 |
}
|
|
indvdum@0
|
1216 |
else
|
|
indvdum@0
|
1217 |
{
|
|
indvdum@0
|
1218 |
$is_watching = 0;
|
|
indvdum@0
|
1219 |
}
|
|
indvdum@0
|
1220 |
}
|
|
indvdum@0
|
1221 |
}
|
|
indvdum@0
|
1222 |
else
|
|
indvdum@0
|
1223 |
{
|
|
indvdum@0
|
1224 |
if ((isset($_GET['unwatch']) && $_GET['unwatch'] == $mode) || (isset($_GET['watch']) && $_GET['watch'] == $mode))
|
|
indvdum@0
|
1225 |
{
|
|
indvdum@0
|
1226 |
login_box();
|
|
indvdum@0
|
1227 |
}
|
|
indvdum@0
|
1228 |
else
|
|
indvdum@0
|
1229 |
{
|
|
indvdum@0
|
1230 |
$can_watch = 0;
|
|
indvdum@0
|
1231 |
$is_watching = 0;
|
|
indvdum@0
|
1232 |
}
|
|
indvdum@0
|
1233 |
}
|
|
indvdum@0
|
1234 |
|
|
indvdum@0
|
1235 |
if ($can_watch)
|
|
indvdum@0
|
1236 |
{
|
|
indvdum@0
|
1237 |
$s_watching['link'] = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&" . (($is_watching) ? 'unwatch' : 'watch') . "=$mode&start=$start&hash=" . generate_link_hash("{$mode}_$match_id"));
|
|
indvdum@0
|
1238 |
$s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
|
|
indvdum@0
|
1239 |
$s_watching['is_watching'] = $is_watching;
|
|
indvdum@0
|
1240 |
}
|
|
indvdum@0
|
1241 |
|
|
indvdum@0
|
1242 |
return;
|
|
indvdum@0
|
1243 |
}
|
|
indvdum@0
|
1244 |
|
|
indvdum@0
|
1245 |
/**
|
|
indvdum@0
|
1246 |
* Get user rank title and image
|
|
indvdum@0
|
1247 |
*
|
|
indvdum@0
|
1248 |
* @param int $user_rank the current stored users rank id
|
|
indvdum@0
|
1249 |
* @param int $user_posts the users number of posts
|
|
indvdum@0
|
1250 |
* @param string &$rank_title the rank title will be stored here after execution
|
|
indvdum@0
|
1251 |
* @param string &$rank_img the rank image as full img tag is stored here after execution
|
|
indvdum@0
|
1252 |
* @param string &$rank_img_src the rank image source is stored here after execution
|
|
indvdum@0
|
1253 |
*
|
|
indvdum@0
|
1254 |
* Note: since we do not want to break backwards-compatibility, this function will only properly assign ranks to guests if you call it for them with user_posts == false
|
|
indvdum@0
|
1255 |
*/
|
|
indvdum@0
|
1256 |
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
|
|
indvdum@0
|
1257 |
{
|
|
indvdum@0
|
1258 |
global $ranks, $config, $phpbb_root_path;
|
|
indvdum@0
|
1259 |
|
|
indvdum@0
|
1260 |
if (empty($ranks))
|
|
indvdum@0
|
1261 |
{
|
|
indvdum@0
|
1262 |
global $cache;
|
|
indvdum@0
|
1263 |
$ranks = $cache->obtain_ranks();
|
|
indvdum@0
|
1264 |
}
|
|
indvdum@0
|
1265 |
|
|
indvdum@0
|
1266 |
if (!empty($user_rank))
|
|
indvdum@0
|
1267 |
{
|
|
indvdum@0
|
1268 |
$rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : '';
|
|
indvdum@0
|
1269 |
$rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';
|
|
indvdum@0
|
1270 |
$rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : '';
|
|
indvdum@0
|
1271 |
}
|
|
indvdum@0
|
1272 |
else if ($user_posts !== false)
|
|
indvdum@0
|
1273 |
{
|
|
indvdum@0
|
1274 |
if (!empty($ranks['normal']))
|
|
indvdum@0
|
1275 |
{
|
|
indvdum@0
|
1276 |
foreach ($ranks['normal'] as $rank)
|
|
indvdum@0
|
1277 |
{
|
|
indvdum@0
|
1278 |
if ($user_posts >= $rank['rank_min'])
|
|
indvdum@0
|
1279 |
{
|
|
indvdum@0
|
1280 |
$rank_title = $rank['rank_title'];
|
|
indvdum@0
|
1281 |
$rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
|
|
indvdum@0
|
1282 |
$rank_img_src = (!empty($rank['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] : '';
|
|
indvdum@0
|
1283 |
break;
|
|
indvdum@0
|
1284 |
}
|
|
indvdum@0
|
1285 |
}
|
|
indvdum@0
|
1286 |
}
|
|
indvdum@0
|
1287 |
}
|
|
indvdum@0
|
1288 |
}
|
|
indvdum@0
|
1289 |
|
|
indvdum@0
|
1290 |
/**
|
|
indvdum@0
|
1291 |
* Get user avatar
|
|
indvdum@0
|
1292 |
*
|
|
indvdum@0
|
1293 |
* @param string $avatar Users assigned avatar name
|
|
indvdum@0
|
1294 |
* @param int $avatar_type Type of avatar
|
|
indvdum@0
|
1295 |
* @param string $avatar_width Width of users avatar
|
|
indvdum@0
|
1296 |
* @param string $avatar_height Height of users avatar
|
|
indvdum@0
|
1297 |
* @param string $alt Optional language string for alt tag within image, can be a language key or text
|
|
indvdum@0
|
1298 |
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
|
|
indvdum@0
|
1299 |
*
|
|
indvdum@0
|
1300 |
* @return string Avatar image
|
|
indvdum@0
|
1301 |
*/
|
|
indvdum@0
|
1302 |
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
|
|
indvdum@0
|
1303 |
{
|
|
indvdum@0
|
1304 |
global $user, $config, $phpbb_root_path, $phpEx;
|
|
indvdum@0
|
1305 |
|
|
indvdum@0
|
1306 |
if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
|
|
indvdum@0
|
1307 |
{
|
|
indvdum@0
|
1308 |
return '';
|
|
indvdum@0
|
1309 |
}
|
|
indvdum@0
|
1310 |
|
|
indvdum@0
|
1311 |
$avatar_img = '';
|
|
indvdum@0
|
1312 |
|
|
indvdum@0
|
1313 |
switch ($avatar_type)
|
|
indvdum@0
|
1314 |
{
|
|
indvdum@0
|
1315 |
case AVATAR_UPLOAD:
|
|
indvdum@0
|
1316 |
if (!$config['allow_avatar_upload'] && !$ignore_config)
|
|
indvdum@0
|
1317 |
{
|
|
indvdum@0
|
1318 |
return '';
|
|
indvdum@0
|
1319 |
}
|
|
indvdum@0
|
1320 |
$avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
|
|
indvdum@0
|
1321 |
break;
|
|
indvdum@0
|
1322 |
|
|
indvdum@0
|
1323 |
case AVATAR_GALLERY:
|
|
indvdum@0
|
1324 |
if (!$config['allow_avatar_local'] && !$ignore_config)
|
|
indvdum@0
|
1325 |
{
|
|
indvdum@0
|
1326 |
return '';
|
|
indvdum@0
|
1327 |
}
|
|
indvdum@0
|
1328 |
$avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
|
|
indvdum@0
|
1329 |
break;
|
|
indvdum@0
|
1330 |
|
|
indvdum@0
|
1331 |
case AVATAR_REMOTE:
|
|
indvdum@0
|
1332 |
if (!$config['allow_avatar_remote'] && !$ignore_config)
|
|
indvdum@0
|
1333 |
{
|
|
indvdum@0
|
1334 |
return '';
|
|
indvdum@0
|
1335 |
}
|
|
indvdum@0
|
1336 |
break;
|
|
indvdum@0
|
1337 |
}
|
|
indvdum@0
|
1338 |
|
|
indvdum@0
|
1339 |
$avatar_img .= $avatar;
|
|
indvdum@0
|
1340 |
return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
|
|
indvdum@0
|
1341 |
}
|
|
indvdum@0
|
1342 |
|
|
indvdum@0
|
1343 |
?> |