Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
functions_display.php
0001 <?php
0002 /**
0003 *
0004 * This file is part of the phpBB Forum Software package.
0005 *
0006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
0007 * @license GNU General Public License, version 2 (GPL-2.0)
0008 *
0009 * For full copyright and license information, please see
0010 * the docs/CREDITS.txt file.
0011 *
0012 */
0013
0014 /**
0015 * @ignore
0016 */
0017 if (!defined('IN_PHPBB'))
0018 {
0019 exit;
0020 }
0021
0022 /**
0023 * Display Forums
0024 */
0025 function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
0026 {
0027 global $db, $auth, $user, $template;
0028 global $phpbb_root_path, $phpEx, $config;
0029 global $request, $phpbb_dispatcher, $phpbb_container;
0030
0031 $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
0032 $parent_id = $visible_forums = 0;
0033 $sql_from = '';
0034
0035 // Mark forums read?
0036 $mark_read = request_var('mark', '');
0037
0038 if ($mark_read == 'all')
0039 {
0040 $mark_read = '';
0041 }
0042
0043 if (!$root_data)
0044 {
0045 if ($mark_read == 'forums')
0046 {
0047 $mark_read = 'all';
0048 }
0049
0050 $root_data = array('forum_id' => 0);
0051 $sql_where = '';
0052 }
0053 else
0054 {
0055 $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
0056 }
0057
0058 // Handle marking everything read
0059 if ($mark_read == 'all')
0060 {
0061 $redirect = build_url(array('mark', 'hash', 'mark_time'));
0062 meta_refresh(3, $redirect);
0063
0064 if (check_link_hash(request_var('hash', ''), 'global'))
0065 {
0066 markread('all', false, false, request_var('mark_time', 0));
0067
0068 if ($request->is_ajax())
0069 {
0070 // Tell the ajax script what language vars and URL need to be replaced
0071 $data = array(
0072 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'],
0073 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'],
0074 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '',
0075 'MESSAGE_TITLE' => $user->lang['INFORMATION'],
0076 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED']
0077 );
0078 $json_response = new \phpbb\json_response();
0079 $json_response->send($data);
0080 }
0081
0082 trigger_error(
0083 $user->lang['FORUMS_MARKED'] . '<br /><br />' .
0084 sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>')
0085 );
0086 }
0087 else
0088 {
0089 trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
0090 }
0091 }
0092
0093 // Display list of active topics for this category?
0094 $show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false;
0095
0096 $sql_array = array(
0097 'SELECT' => 'f.*',
0098 'FROM' => array(
0099 FORUMS_TABLE => 'f'
0100 ),
0101 'LEFT_JOIN' => array(),
0102 );
0103
0104 if ($config['load_db_lastread'] && $user->data['is_registered'])
0105 {
0106 $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');
0107 $sql_array['SELECT'] .= ', ft.mark_time';
0108 }
0109 else if ($config['load_anon_lastread'] || $user->data['is_registered'])
0110 {
0111 $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
0112 $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();
0113
0114 if (!$user->data['is_registered'])
0115 {
0116 $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
0117 }
0118 }
0119
0120 if ($show_active)
0121 {
0122 $sql_array['LEFT_JOIN'][] = array(
0123 'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'),
0124 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'"
0125 );
0126
0127 $sql_array['SELECT'] .= ', fa.user_id';
0128 }
0129
0130 $sql_ary = array(
0131 'SELECT' => $sql_array['SELECT'],
0132 'FROM' => $sql_array['FROM'],
0133 'LEFT_JOIN' => $sql_array['LEFT_JOIN'],
0134
0135 'WHERE' => $sql_where,
0136
0137 'ORDER_BY' => 'f.left_id',
0138 );
0139
0140 /**
0141 * Event to modify the SQL query before the forum data is queried
0142 *
0143 * @event core.display_forums_modify_sql
0144 * @var array sql_ary The SQL array to get the data of the forums
0145 * @since 3.1.0-a1
0146 */
0147 $vars = array('sql_ary');
0148 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars)));
0149
0150 $sql = $db->sql_build_query('SELECT', $sql_ary);
0151 $result = $db->sql_query($sql);
0152
0153 $forum_tracking_info = array();
0154 $branch_root_id = $root_data['forum_id'];
0155
0156 $phpbb_content_visibility = $phpbb_container->get('content.visibility');
0157
0158 while ($row = $db->sql_fetchrow($result))
0159 {
0160 /**
0161 * Event to modify the data set of a forum
0162 *
0163 * This event is triggered once per forum
0164 *
0165 * @event core.display_forums_modify_row
0166 * @var int branch_root_id Last top-level forum
0167 * @var array row The data of the forum
0168 * @since 3.1.0-a1
0169 */
0170 $vars = array('branch_root_id', 'row');
0171 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars)));
0172
0173 $forum_id = $row['forum_id'];
0174
0175 // Mark forums read?
0176 if ($mark_read == 'forums')
0177 {
0178 if ($auth->acl_get('f_list', $forum_id))
0179 {
0180 $forum_ids[] = $forum_id;
0181 }
0182
0183 continue;
0184 }
0185
0186 // Category with no members
0187 if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id']))
0188 {
0189 continue;
0190 }
0191
0192 // Skip branch
0193 if (isset($right_id))
0194 {
0195 if ($row['left_id'] < $right_id)
0196 {
0197 continue;
0198 }
0199 unset($right_id);
0200 }
0201
0202 if (!$auth->acl_get('f_list', $forum_id))
0203 {
0204 // if the user does not have permissions to list this forum, skip everything until next branch
0205 $right_id = $row['right_id'];
0206 continue;
0207 }
0208
0209 if ($config['load_db_lastread'] && $user->data['is_registered'])
0210 {
0211 $forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark'];
0212 }
0213 else if ($config['load_anon_lastread'] || $user->data['is_registered'])
0214 {
0215 if (!$user->data['is_registered'])
0216 {
0217 $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
0218 }
0219 $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'];
0220 }
0221
0222 // Lets check whether there are unapproved topics/posts, so we can display an information to moderators
0223 $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0;
0224 $row['forum_id_unapproved_posts'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_posts_unapproved']) ? $forum_id : 0;
0225 $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id);
0226 $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id);
0227
0228 // Display active topics from this forum?
0229 if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS))
0230 {
0231 if (!isset($active_forum_ary['forum_topics']))
0232 {
0233 $active_forum_ary['forum_topics'] = 0;
0234 }
0235
0236 if (!isset($active_forum_ary['forum_posts']))
0237 {
0238 $active_forum_ary['forum_posts'] = 0;
0239 }
0240
0241 $active_forum_ary['forum_id'][] = $forum_id;
0242 $active_forum_ary['enable_icons'][] = $row['enable_icons'];
0243 $active_forum_ary['forum_topics'] += $row['forum_topics'];
0244 $active_forum_ary['forum_posts'] += $row['forum_posts'];
0245
0246 // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it...
0247 if ($row['forum_password'] && $row['user_id'] != $user->data['user_id'])
0248 {
0249 $active_forum_ary['exclude_forum_id'][] = $forum_id;
0250 }
0251 }
0252
0253 //
0254 if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id)
0255 {
0256 if ($row['forum_type'] != FORUM_CAT)
0257 {
0258 $forum_ids_moderator[] = (int) $forum_id;
0259 }
0260
0261 // Direct child of current branch
0262 $parent_id = $forum_id;
0263 $forum_rows[$forum_id] = $row;
0264
0265 if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id'])
0266 {
0267 $branch_root_id = $forum_id;
0268 }
0269 $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
0270 $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
0271 }
0272 else if ($row['forum_type'] != FORUM_CAT)
0273 {
0274 $subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false;
0275 $subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
0276 $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
0277 $subforums[$parent_id][$forum_id]['children'] = array();
0278
0279 if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index'])
0280 {
0281 $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id;
0282 }
0283
0284 if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics'])
0285 {
0286 $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id;
0287 }
0288
0289 if (!$forum_rows[$parent_id]['forum_id_unapproved_posts'] && $row['forum_id_unapproved_posts'])
0290 {
0291 $forum_rows[$parent_id]['forum_id_unapproved_posts'] = $forum_id;
0292 }
0293
0294 $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
0295
0296 // Do not list redirects in LINK Forums as Posts.
0297 if ($row['forum_type'] != FORUM_LINK)
0298 {
0299 $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
0300 }
0301
0302 if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time'])
0303 {
0304 $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
0305 $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject'];
0306 $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
0307 $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
0308 $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
0309 $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour'];
0310 $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
0311 }
0312 }
0313
0314 /**
0315 * Event to modify the forum rows data set
0316 *
0317 * This event is triggered once per forum
0318 *
0319 * @event core.display_forums_modify_forum_rows
0320 * @var array forum_rows Data array of all forums we display
0321 * @var array subforums Data array of all subforums we display
0322 * @var int branch_root_id Current top-level forum
0323 * @var int parent_id Current parent forum
0324 * @var array row The data of the forum
0325 * @since 3.1.0-a1
0326 */
0327 $vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row');
0328 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars)));
0329 }
0330 $db->sql_freeresult($result);
0331
0332 // Handle marking posts
0333 if ($mark_read == 'forums')
0334 {
0335 $redirect = build_url(array('mark', 'hash', 'mark_time'));
0336 $token = request_var('hash', '');
0337 if (check_link_hash($token, 'global'))
0338 {
0339 markread('topics', $forum_ids, false, request_var('mark_time', 0));
0340 $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
0341 meta_refresh(3, $redirect);
0342
0343 if ($request->is_ajax())
0344 {
0345 // Tell the ajax script what language vars and URL need to be replaced
0346 $data = array(
0347 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'],
0348 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'],
0349 '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&mark_time=' . time()) : '',
0350 'MESSAGE_TITLE' => $user->lang['INFORMATION'],
0351 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED']
0352 );
0353 $json_response = new \phpbb\json_response();
0354 $json_response->send($data);
0355 }
0356
0357 trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
0358 }
0359 else
0360 {
0361 $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
0362 meta_refresh(3, $redirect);
0363 trigger_error($message);
0364 }
0365
0366 }
0367
0368 // Grab moderators ... if necessary
0369 if ($display_moderators)
0370 {
0371 if ($return_moderators)
0372 {
0373 $forum_ids_moderator[] = $root_data['forum_id'];
0374 }
0375 get_moderators($forum_moderators, $forum_ids_moderator);
0376 }
0377
0378 // Used to tell whatever we have to create a dummy category or not.
0379 $last_catless = true;
0380 foreach ($forum_rows as $row)
0381 {
0382 // Category
0383 if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT)
0384 {
0385 $cat_row = array(
0386 'S_IS_CAT' => true,
0387 'FORUM_ID' => $row['forum_id'],
0388 'FORUM_NAME' => $row['forum_name'],
0389 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
0390 'FORUM_FOLDER_IMG' => '',
0391 'FORUM_FOLDER_IMG_SRC' => '',
0392 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '',
0393 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
0394 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
0395 );
0396
0397 /**
0398 * Modify the template data block of the 'category'
0399 *
0400 * This event is triggered once per 'category'
0401 *
0402 * @event core.display_forums_modify_category_template_vars
0403 * @var array cat_row Template data of the 'category'
0404 * @var bool catless The flag indicating whether the 'category' has a parent category
0405 * @var bool last_catless The flag indicating whether the last forum had a parent category
0406 * @var array root_data Array with the root forum data
0407 * @var array row The data of the 'category'
0408 * @since 3.1.0-RC4
0409 */
0410 $vars = array(
0411 'cat_row',
0412 'catless',
0413 'last_catless',
0414 'root_data',
0415 'row',
0416 );
0417 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_category_template_vars', compact($vars)));
0418
0419 $template->assign_block_vars('forumrow', $cat_row);
0420
0421 continue;
0422 }
0423
0424 $visible_forums++;
0425 $forum_id = $row['forum_id'];
0426
0427 $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false;
0428
0429 $folder_image = $folder_alt = $l_subforums = '';
0430 $subforums_list = array();
0431
0432 // Generate list of subforums if we need to
0433 if (isset($subforums[$forum_id]))
0434 {
0435 foreach ($subforums[$forum_id] as $subforum_id => $subforum_row)
0436 {
0437 $subforum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false;
0438
0439 if (!$subforum_unread && !empty($subforum_row['children']))
0440 {
0441 foreach ($subforum_row['children'] as $child_id)
0442 {
0443 if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id])
0444 {
0445 // Once we found an unread child forum, we can drop out of this loop
0446 $subforum_unread = true;
0447 break;
0448 }
0449 }
0450 }
0451
0452 if ($subforum_row['display'] && $subforum_row['name'])
0453 {
0454 $subforums_list[] = array(
0455 'link' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id),
0456 'name' => $subforum_row['name'],
0457 'unread' => $subforum_unread,
0458 );
0459 }
0460 else
0461 {
0462 unset($subforums[$forum_id][$subforum_id]);
0463 }
0464
0465 // If one subforum is unread the forum gets unread too...
0466 if ($subforum_unread)
0467 {
0468 $forum_unread = true;
0469 }
0470 }
0471
0472 $l_subforums = (sizeof($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'];
0473 $folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum';
0474 }
0475 else
0476 {
0477 switch ($row['forum_type'])
0478 {
0479 case FORUM_POST:
0480 $folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read';
0481 break;
0482
0483 case FORUM_LINK:
0484 $folder_image = 'forum_link';
0485 break;
0486 }
0487 }
0488
0489 // Which folder should we display?
0490 if ($row['forum_status'] == ITEM_LOCKED)
0491 {
0492 $folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked';
0493 $folder_alt = 'FORUM_LOCKED';
0494 }
0495 else
0496 {
0497 $folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS';
0498 }
0499
0500 // Create last post link information, if appropriate
0501 if ($row['forum_last_post_id'])
0502 {
0503 $last_post_subject = $row['forum_last_post_subject'];
0504 $last_post_subject_truncated = truncate_string(censor_text($last_post_subject), 30, 255, false, $user->lang['ELLIPSIS']);
0505 $last_post_time = $user->format_date($row['forum_last_post_time']);
0506 $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'];
0507 }
0508 else
0509 {
0510 $last_post_subject = $last_post_time = $last_post_url = $last_post_subject_truncated = '';
0511 }
0512
0513 // Output moderator listing ... if applicable
0514 $l_moderator = $moderators_list = '';
0515 if ($display_moderators && !empty($forum_moderators[$forum_id]))
0516 {
0517 $l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
0518 $moderators_list = implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]);
0519 }
0520
0521 $l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS';
0522 $post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : '';
0523
0524 $s_subforums_list = $subforums_row = array();
0525 foreach ($subforums_list as $subforum)
0526 {
0527 $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>';
0528 $subforums_row[] = array(
0529 'U_SUBFORUM' => $subforum['link'],
0530 'SUBFORUM_NAME' => $subforum['name'],
0531 'S_UNREAD' => $subforum['unread'],
0532 );
0533 }
0534 $s_subforums_list = (string) implode($user->lang['COMMA_SEPARATOR'], $s_subforums_list);
0535 $catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false;
0536
0537 if ($row['forum_type'] != FORUM_LINK)
0538 {
0539 $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
0540 }
0541 else
0542 {
0543 // If the forum is a link and we count redirects we need to visit it
0544 // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum
0545 if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id))
0546 {
0547 $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
0548 }
0549 else
0550 {
0551 $u_viewforum = $row['forum_link'];
0552 }
0553 }
0554
0555 $forum_row = array(
0556 'S_IS_CAT' => false,
0557 'S_NO_CAT' => $catless && !$last_catless,
0558 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false,
0559 'S_UNREAD_FORUM' => $forum_unread,
0560 'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']),
0561 'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false,
0562 'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false,
0563 'S_SUBFORUMS' => (sizeof($subforums_list)) ? true : false,
0564 'S_DISPLAY_SUBJECT' => ($last_post_subject && $config['display_last_subject'] && !$row['forum_password'] && $auth->acl_get('f_read', $row['forum_id'])) ? true : false,
0565 'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false,
0566
0567 'FORUM_ID' => $row['forum_id'],
0568 'FORUM_NAME' => $row['forum_name'],
0569 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
0570 'TOPICS' => $row['forum_topics'],
0571 $l_post_click_count => $post_click_count,
0572 'FORUM_IMG_STYLE' => $folder_image,
0573 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt),
0574 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '',
0575 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '',
0576 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
0577 'LAST_POST_SUBJECT' => (!$row['forum_password'] && $auth->acl_get('f_read', $row['forum_id'])) ? censor_text($last_post_subject) : "",
0578 'LAST_POST_SUBJECT_TRUNCATED' => (!$row['forum_password'] && $auth->acl_get('f_read', $row['forum_id'])) ? $last_post_subject_truncated : "",
0579 'LAST_POST_TIME' => $last_post_time,
0580 'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
0581 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
0582 'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
0583 'MODERATORS' => $moderators_list,
0584 'SUBFORUMS' => $s_subforums_list,
0585
0586 'L_SUBFORUM_STR' => $l_subforums,
0587 'L_MODERATOR_STR' => $l_moderator,
0588
0589 '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']) : '',
0590 'U_UNAPPROVED_POSTS' => ($row['forum_id_unapproved_posts']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_posts&f=' . $row['forum_id_unapproved_posts']) : '',
0591 'U_VIEWFORUM' => $u_viewforum,
0592 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
0593 'U_LAST_POST' => $last_post_url,
0594 );
0595
0596 /**
0597 * Modify the template data block of the forum
0598 *
0599 * This event is triggered once per forum
0600 *
0601 * @event core.display_forums_modify_template_vars
0602 * @var array forum_row Template data of the forum
0603 * @var array row The data of the forum
0604 * @var array subforums_row Template data of subforums
0605 * @since 3.1.0-a1
0606 * @change 3.1.0-b5 Added var subforums_row
0607 */
0608 $vars = array('forum_row', 'row', 'subforums_row');
0609 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars)));
0610
0611 $template->assign_block_vars('forumrow', $forum_row);
0612
0613 // Assign subforums loop for style authors
0614 $template->assign_block_vars_array('forumrow.subforum', $subforums_row);
0615
0616 /**
0617 * Modify and/or assign additional template data for the forum
0618 * after forumrow loop has been assigned. This can be used
0619 * to create additional forumrow subloops in extensions.
0620 *
0621 * This event is triggered once per forum
0622 *
0623 * @event core.display_forums_add_template_data
0624 * @var array forum_row Template data of the forum
0625 * @var array row The data of the forum
0626 * @var array subforums_list The data of subforums
0627 * @var array subforums_row Template data of subforums
0628 * @var bool catless The flag indicating whether a forum has a parent category
0629 * @since 3.1.0-b5
0630 */
0631 $vars = array(
0632 'forum_row',
0633 'row',
0634 'subforums_list',
0635 'subforums_row',
0636 'catless',
0637 );
0638 extract($phpbb_dispatcher->trigger_event('core.display_forums_add_template_data', compact($vars)));
0639
0640 $last_catless = $catless;
0641 }
0642
0643 $template->assign_vars(array(
0644 '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&mark_time=' . time()) : '',
0645 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false,
0646 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'],
0647 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
0648 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'),
0649 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED_FORUM'),
0650 ));
0651
0652 /**
0653 * Event to perform additional actions after the forum list has been generated
0654 *
0655 * @event core.display_forums_after
0656 * @var array active_forum_ary Array with forum data to display active topics
0657 * @var bool display_moderators Flag indicating if we display forum moderators
0658 * @var array forum_moderators Array with forum moderators list
0659 * @var array forum_rows Data array of all forums we display
0660 * @var bool return_moderators Flag indicating if moderators list should be returned
0661 * @var array root_data Array with the root forum data
0662 * @since 3.1.0-RC5
0663 */
0664 $vars = array(
0665 'active_forum_ary',
0666 'display_moderators',
0667 'forum_moderators',
0668 'forum_rows',
0669 'return_moderators',
0670 'root_data',
0671 );
0672 extract($phpbb_dispatcher->trigger_event('core.display_forums_after', compact($vars)));
0673
0674 if ($return_moderators)
0675 {
0676 return array($active_forum_ary, $forum_moderators);
0677 }
0678
0679 return array($active_forum_ary, array());
0680 }
0681
0682 /**
0683 * Create forum rules for given forum
0684 */
0685 function generate_forum_rules(&$forum_data)
0686 {
0687 if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link'])
0688 {
0689 return;
0690 }
0691
0692 global $template, $phpbb_root_path, $phpEx;
0693
0694 if ($forum_data['forum_rules'])
0695 {
0696 $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']);
0697 }
0698
0699 $template->assign_vars(array(
0700 'S_FORUM_RULES' => true,
0701 'U_FORUM_RULES' => $forum_data['forum_rules_link'],
0702 'FORUM_RULES' => $forum_data['forum_rules'])
0703 );
0704 }
0705
0706 /**
0707 * Create forum navigation links for given forum, create parent
0708 * list if currently null, assign basic forum info to template
0709 */
0710 function generate_forum_nav(&$forum_data)
0711 {
0712 global $db, $user, $template, $auth, $config;
0713 global $phpEx, $phpbb_root_path;
0714
0715 if (!$auth->acl_get('f_list', $forum_data['forum_id']))
0716 {
0717 return;
0718 }
0719
0720 // Get forum parents
0721 $forum_parents = get_forum_parents($forum_data);
0722
0723 $microdata_attr = 'data-forum-id';
0724
0725 // Build navigation links
0726 if (!empty($forum_parents))
0727 {
0728 foreach ($forum_parents as $parent_forum_id => $parent_data)
0729 {
0730 list($parent_name, $parent_type) = array_values($parent_data);
0731
0732 // Skip this parent if the user does not have the permission to view it
0733 if (!$auth->acl_get('f_list', $parent_forum_id))
0734 {
0735 continue;
0736 }
0737
0738 $template->assign_block_vars('navlinks', array(
0739 'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false,
0740 'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false,
0741 'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false,
0742 'FORUM_NAME' => $parent_name,
0743 'FORUM_ID' => $parent_forum_id,
0744 'MICRODATA' => $microdata_attr . '="' . $parent_forum_id . '"',
0745 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id))
0746 );
0747 }
0748 }
0749
0750 $template->assign_block_vars('navlinks', array(
0751 'S_IS_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
0752 'S_IS_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
0753 'S_IS_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
0754 'FORUM_NAME' => $forum_data['forum_name'],
0755 'FORUM_ID' => $forum_data['forum_id'],
0756 'MICRODATA' => $microdata_attr . '="' . $forum_data['forum_id'] . '"',
0757 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data['forum_id']))
0758 );
0759
0760 $template->assign_vars(array(
0761 'FORUM_ID' => $forum_data['forum_id'],
0762 'FORUM_NAME' => $forum_data['forum_name'],
0763 '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']),
0764
0765 '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,
0766 ));
0767
0768 return;
0769 }
0770
0771 /**
0772 * Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise
0773 */
0774 function get_forum_parents(&$forum_data)
0775 {
0776 global $db;
0777
0778 $forum_parents = array();
0779
0780 if ($forum_data['parent_id'] > 0)
0781 {
0782 if ($forum_data['forum_parents'] == '')
0783 {
0784 $sql = 'SELECT forum_id, forum_name, forum_type
0785 FROM ' . FORUMS_TABLE . '
0786 WHERE left_id < ' . $forum_data['left_id'] . '
0787 AND right_id > ' . $forum_data['right_id'] . '
0788 ORDER BY left_id ASC';
0789 $result = $db->sql_query($sql);
0790
0791 while ($row = $db->sql_fetchrow($result))
0792 {
0793 $forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']);
0794 }
0795 $db->sql_freeresult($result);
0796
0797 $forum_data['forum_parents'] = serialize($forum_parents);
0798
0799 $sql = 'UPDATE ' . FORUMS_TABLE . "
0800 SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "'
0801 WHERE parent_id = " . $forum_data['parent_id'];
0802 $db->sql_query($sql);
0803 }
0804 else
0805 {
0806 $forum_parents = unserialize($forum_data['forum_parents']);
0807 }
0808 }
0809
0810 return $forum_parents;
0811 }
0812
0813 /**
0814 * Obtain list of moderators of each forum
0815 */
0816 function get_moderators(&$forum_moderators, $forum_id = false)
0817 {
0818 global $config, $template, $db, $phpbb_root_path, $phpEx, $user, $auth;
0819
0820 $forum_id_ary = array();
0821
0822 if ($forum_id !== false)
0823 {
0824 if (!is_array($forum_id))
0825 {
0826 $forum_id = array($forum_id);
0827 }
0828
0829 // Exchange key/value pair to be able to faster check for the forum id existence
0830 $forum_id_ary = array_flip($forum_id);
0831 }
0832
0833 $sql_array = array(
0834 'SELECT' => 'm.*, u.user_colour, g.group_colour, g.group_type',
0835
0836 'FROM' => array(
0837 MODERATOR_CACHE_TABLE => 'm',
0838 ),
0839
0840 'LEFT_JOIN' => array(
0841 array(
0842 'FROM' => array(USERS_TABLE => 'u'),
0843 'ON' => 'm.user_id = u.user_id',
0844 ),
0845 array(
0846 'FROM' => array(GROUPS_TABLE => 'g'),
0847 'ON' => 'm.group_id = g.group_id',
0848 ),
0849 ),
0850
0851 'WHERE' => 'm.display_on_index = 1',
0852 );
0853
0854 // We query every forum here because for caching we should not have any parameter.
0855 $sql = $db->sql_build_query('SELECT', $sql_array);
0856 $result = $db->sql_query($sql, 3600);
0857
0858 while ($row = $db->sql_fetchrow($result))
0859 {
0860 $f_id = (int) $row['forum_id'];
0861
0862 if (!isset($forum_id_ary[$f_id]))
0863 {
0864 continue;
0865 }
0866
0867 if (!empty($row['user_id']))
0868 {
0869 $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
0870 }
0871 else
0872 {
0873 $group_name = (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']);
0874
0875 if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile'))
0876 {
0877 $forum_moderators[$f_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>';
0878 }
0879 else
0880 {
0881 $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>';
0882 }
0883 }
0884 }
0885 $db->sql_freeresult($result);
0886
0887 return;
0888 }
0889
0890 /**
0891 * User authorisation levels output
0892 *
0893 * @param string $mode Can be forum or topic. Not in use at the moment.
0894 * @param int $forum_id The current forum the user is in.
0895 * @param int $forum_status The forums status bit.
0896 */
0897 function gen_forum_auth_level($mode, $forum_id, $forum_status)
0898 {
0899 global $template, $auth, $user, $config;
0900
0901 $locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false;
0902
0903 $rules = array(
0904 ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'],
0905 ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'],
0906 ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'],
0907 ($user->data['is_registered'] && ($auth->acl_gets('f_delete', 'm_delete', $forum_id) || $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) && !$locked) ? $user->lang['RULES_DELETE_CAN'] : $user->lang['RULES_DELETE_CANNOT'],
0908 );
0909
0910 if ($config['allow_attachments'])
0911 {
0912 $rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT'];
0913 }
0914
0915 foreach ($rules as $rule)
0916 {
0917 $template->assign_block_vars('rules', array('RULE' => $rule));
0918 }
0919
0920 return;
0921 }
0922
0923 /**
0924 * Generate topic status
0925 */
0926 function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type)
0927 {
0928 global $user, $config;
0929
0930 $folder = $folder_new = '';
0931
0932 if ($topic_row['topic_status'] == ITEM_MOVED)
0933 {
0934 $topic_type = $user->lang['VIEW_TOPIC_MOVED'];
0935 $folder_img = 'topic_moved';
0936 $folder_alt = 'TOPIC_MOVED';
0937 }
0938 else
0939 {
0940 switch ($topic_row['topic_type'])
0941 {
0942 case POST_GLOBAL:
0943 $topic_type = $user->lang['VIEW_TOPIC_GLOBAL'];
0944 $folder = 'global_read';
0945 $folder_new = 'global_unread';
0946 break;
0947
0948 case POST_ANNOUNCE:
0949 $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
0950 $folder = 'announce_read';
0951 $folder_new = 'announce_unread';
0952 break;
0953
0954 case POST_STICKY:
0955 $topic_type = $user->lang['VIEW_TOPIC_STICKY'];
0956 $folder = 'sticky_read';
0957 $folder_new = 'sticky_unread';
0958 break;
0959
0960 default:
0961 $topic_type = '';
0962 $folder = 'topic_read';
0963 $folder_new = 'topic_unread';
0964
0965 // Hot topic threshold is for posts in a topic, which is replies + the first post. ;)
0966 if ($config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED)
0967 {
0968 $folder .= '_hot';
0969 $folder_new .= '_hot';
0970 }
0971 break;
0972 }
0973
0974 if ($topic_row['topic_status'] == ITEM_LOCKED)
0975 {
0976 $topic_type = $user->lang['VIEW_TOPIC_LOCKED'];
0977 $folder .= '_locked';
0978 $folder_new .= '_locked';
0979 }
0980
0981 $folder_img = ($unread_topic) ? $folder_new : $folder;
0982 $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS');
0983
0984 // Posted image?
0985 if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted'])
0986 {
0987 $folder_img .= '_mine';
0988 }
0989 }
0990
0991 if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED)
0992 {
0993 $topic_type = $user->lang['VIEW_TOPIC_POLL'];
0994 }
0995 }
0996
0997 /**
0998 * Assign/Build custom bbcodes for display in screens supporting using of bbcodes
0999 * The custom bbcodes buttons will be placed within the template block 'custom_tags'
1000 */
1001 function display_custom_bbcodes()
1002 {
1003 global $db, $template, $user, $phpbb_dispatcher;
1004
1005 // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
1006 $num_predefined_bbcodes = 22;
1007
1008 $sql_ary = array(
1009 'SELECT' => 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline',
1010 'FROM' => array(BBCODES_TABLE => 'b'),
1011 'WHERE' => 'b.display_on_posting = 1',
1012 'ORDER_BY' => 'b.bbcode_tag',
1013 );
1014
1015 /**
1016 * Event to modify the SQL query before custom bbcode data is queried
1017 *
1018 * @event core.display_custom_bbcodes_modify_sql
1019 * @var array sql_ary The SQL array to get the bbcode data
1020 * @var int num_predefined_bbcodes The number of predefined core bbcodes
1021 * (multiplied by factor of 2)
1022 * @since 3.1.0-a3
1023 */
1024 $vars = array('sql_ary', 'num_predefined_bbcodes');
1025 extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_sql', compact($vars)));
1026
1027 $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
1028
1029 $i = 0;
1030 while ($row = $db->sql_fetchrow($result))
1031 {
1032 // If the helpline is defined within the language file, we will use the localised version, else just use the database entry...
1033 if (isset($user->lang[strtoupper($row['bbcode_helpline'])]))
1034 {
1035 $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])];
1036 }
1037
1038 $custom_tags = array(
1039 'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
1040 'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2),
1041 'BBCODE_TAG' => $row['bbcode_tag'],
1042 'BBCODE_TAG_CLEAN' => str_replace('=', '-', $row['bbcode_tag']),
1043 'BBCODE_HELPLINE' => $row['bbcode_helpline'],
1044 'A_BBCODE_HELPLINE' => str_replace(array('&', '"', "'", '<', '>'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
1045 );
1046
1047 /**
1048 * Event to modify the template data block of a custom bbcode
1049 *
1050 * This event is triggered once per bbcode
1051 *
1052 * @event core.display_custom_bbcodes_modify_row
1053 * @var array custom_tags Template data of the bbcode
1054 * @var array row The data of the bbcode
1055 * @since 3.1.0-a1
1056 */
1057 $vars = array('custom_tags', 'row');
1058 extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars)));
1059
1060 $template->assign_block_vars('custom_tags', $custom_tags);
1061
1062 $i++;
1063 }
1064 $db->sql_freeresult($result);
1065
1066 /**
1067 * Display custom bbcodes
1068 *
1069 * @event core.display_custom_bbcodes
1070 * @since 3.1.0-a1
1071 */
1072 $phpbb_dispatcher->dispatch('core.display_custom_bbcodes');
1073 }
1074
1075 /**
1076 * Display reasons
1077 */
1078 function display_reasons($reason_id = 0)
1079 {
1080 global $db, $user, $template;
1081
1082 $sql = 'SELECT *
1083 FROM ' . REPORTS_REASONS_TABLE . '
1084 ORDER BY reason_order ASC';
1085 $result = $db->sql_query($sql);
1086
1087 while ($row = $db->sql_fetchrow($result))
1088 {
1089 // If the reason is defined within the language file, we will use the localized version, else just use the database entry...
1090 if (isset($user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])]) && isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]))
1091 {
1092 $row['reason_description'] = $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])];
1093 $row['reason_title'] = $user->lang['report_reasons']['TITLE'][strtoupper($row['reason_title'])];
1094 }
1095
1096 $template->assign_block_vars('reason', array(
1097 'ID' => $row['reason_id'],
1098 'TITLE' => $row['reason_title'],
1099 'DESCRIPTION' => $row['reason_description'],
1100 'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false)
1101 );
1102 }
1103 $db->sql_freeresult($result);
1104 }
1105
1106 /**
1107 * Display user activity (action forum/topic)
1108 */
1109 function display_user_activity(&$userdata)
1110 {
1111 global $auth, $template, $db, $user;
1112 global $phpbb_root_path, $phpEx;
1113 global $phpbb_container, $phpbb_dispatcher;
1114
1115 // Do not display user activity for users having more than 5000 posts...
1116 if ($userdata['user_posts'] > 5000)
1117 {
1118 return;
1119 }
1120
1121 $forum_ary = array();
1122
1123 $forum_read_ary = $auth->acl_getf('f_read');
1124 foreach ($forum_read_ary as $forum_id => $allowed)
1125 {
1126 if ($allowed['f_read'])
1127 {
1128 $forum_ary[] = (int) $forum_id;
1129 }
1130 }
1131
1132 $forum_ary = array_diff($forum_ary, $user->get_passworded_forums());
1133
1134 $active_f_row = $active_t_row = array();
1135 if (!empty($forum_ary))
1136 {
1137 $phpbb_content_visibility = $phpbb_container->get('content.visibility');
1138
1139 // Obtain active forum
1140 $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts
1141 FROM ' . POSTS_TABLE . '
1142 WHERE poster_id = ' . $userdata['user_id'] . '
1143 AND post_postcount = 1
1144 AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . '
1145 GROUP BY forum_id
1146 ORDER BY num_posts DESC';
1147 $result = $db->sql_query_limit($sql, 1);
1148 $active_f_row = $db->sql_fetchrow($result);
1149 $db->sql_freeresult($result);
1150
1151 if (!empty($active_f_row))
1152 {
1153 $sql = 'SELECT forum_name
1154 FROM ' . FORUMS_TABLE . '
1155 WHERE forum_id = ' . $active_f_row['forum_id'];
1156 $result = $db->sql_query($sql, 3600);
1157 $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name');
1158 $db->sql_freeresult($result);
1159 }
1160
1161 // Obtain active topic
1162 $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts
1163 FROM ' . POSTS_TABLE . '
1164 WHERE poster_id = ' . $userdata['user_id'] . '
1165 AND post_postcount = 1
1166 AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . '
1167 GROUP BY topic_id
1168 ORDER BY num_posts DESC';
1169 $result = $db->sql_query_limit($sql, 1);
1170 $active_t_row = $db->sql_fetchrow($result);
1171 $db->sql_freeresult($result);
1172
1173 if (!empty($active_t_row))
1174 {
1175 $sql = 'SELECT topic_title
1176 FROM ' . TOPICS_TABLE . '
1177 WHERE topic_id = ' . $active_t_row['topic_id'];
1178 $result = $db->sql_query($sql);
1179 $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title');
1180 $db->sql_freeresult($result);
1181 }
1182 }
1183
1184 /**
1185 * Alter list of forums and topics to display as active
1186 *
1187 * @event core.display_user_activity_modify_actives
1188 * @var array userdata User's data
1189 * @var array active_f_row List of active forums
1190 * @var array active_t_row List of active posts
1191 * @since 3.1.0-RC3
1192 */
1193 $vars = array('userdata', 'active_f_row', 'active_t_row');
1194 extract($phpbb_dispatcher->trigger_event('core.display_user_activity_modify_actives', compact($vars)));
1195
1196 $userdata['active_t_row'] = $active_t_row;
1197 $userdata['active_f_row'] = $active_f_row;
1198
1199 $active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
1200 if (!empty($active_f_row['num_posts']))
1201 {
1202 $active_f_name = $active_f_row['forum_name'];
1203 $active_f_id = $active_f_row['forum_id'];
1204 $active_f_count = $active_f_row['num_posts'];
1205 $active_f_pct = ($userdata['user_posts']) ? ($active_f_count / $userdata['user_posts']) * 100 : 0;
1206 }
1207
1208 $active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
1209 if (!empty($active_t_row['num_posts']))
1210 {
1211 $active_t_name = $active_t_row['topic_title'];
1212 $active_t_id = $active_t_row['topic_id'];
1213 $active_t_count = $active_t_row['num_posts'];
1214 $active_t_pct = ($userdata['user_posts']) ? ($active_t_count / $userdata['user_posts']) * 100 : 0;
1215 }
1216
1217 $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'];
1218
1219 $template->assign_vars(array(
1220 'ACTIVE_FORUM' => $active_f_name,
1221 'ACTIVE_FORUM_POSTS' => $user->lang('USER_POSTS', (int) $active_f_count),
1222 'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct),
1223 'ACTIVE_TOPIC' => censor_text($active_t_name),
1224 'ACTIVE_TOPIC_POSTS' => $user->lang('USER_POSTS', (int) $active_t_count),
1225 'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct),
1226 'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id),
1227 'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id),
1228 'S_SHOW_ACTIVITY' => true)
1229 );
1230 }
1231
1232 /**
1233 * Topic and forum watching common code
1234 */
1235 function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '')
1236 {
1237 global $template, $db, $user, $phpEx, $start, $phpbb_root_path;
1238 global $request;
1239
1240 $table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE;
1241 $where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id';
1242 $match_id = ($mode == 'forum') ? $forum_id : $topic_id;
1243 $u_url = "uid={$user->data['user_id']}";
1244 $u_url .= ($mode == 'forum') ? '&f' : '&f=' . $forum_id . '&t';
1245 $is_watching = 0;
1246
1247 // Is user watching this topic?
1248 if ($user_id != ANONYMOUS)
1249 {
1250 $can_watch = true;
1251
1252 if ($notify_status == 'unset')
1253 {
1254 $sql = "SELECT notify_status
1255 FROM $table_sql
1256 WHERE $where_sql = $match_id
1257 AND user_id = $user_id";
1258 $result = $db->sql_query($sql);
1259
1260 $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL;
1261 $db->sql_freeresult($result);
1262 }
1263
1264 if (!is_null($notify_status) && $notify_status !== '')
1265 {
1266 if (isset($_GET['unwatch']))
1267 {
1268 $uid = request_var('uid', 0);
1269 $token = request_var('hash', '');
1270
1271 if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true))
1272 {
1273 if ($uid != $user_id || $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) != $mode)
1274 {
1275 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
1276 $message = $user->lang['ERR_UNWATCHING'];
1277
1278 if (!$request->is_ajax())
1279 {
1280 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>');
1281 }
1282 trigger_error($message);
1283 }
1284
1285 $sql = 'DELETE FROM ' . $table_sql . "
1286 WHERE $where_sql = $match_id
1287 AND user_id = $user_id";
1288 $db->sql_query($sql);
1289
1290 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
1291 $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)];
1292
1293 if (!$request->is_ajax())
1294 {
1295 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>');
1296 }
1297 meta_refresh(3, $redirect_url);
1298 trigger_error($message);
1299 }
1300 else
1301 {
1302 $s_hidden_fields = array(
1303 'uid' => $user->data['user_id'],
1304 'unwatch' => $mode,
1305 'start' => $start,
1306 'f' => $forum_id,
1307 );
1308 if ($mode != 'forum')
1309 {
1310 $s_hidden_fields['t'] = $topic_id;
1311 }
1312
1313 if ($item_title == '')
1314 {
1315 $confirm_box_message = 'UNWATCH_' . strtoupper($mode);
1316 }
1317 else
1318 {
1319 $confirm_box_message = $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title);
1320 }
1321 confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields));
1322 }
1323 }
1324 else
1325 {
1326 $is_watching = true;
1327
1328 if ($notify_status != NOTIFY_YES)
1329 {
1330 $sql = 'UPDATE ' . $table_sql . "
1331 SET notify_status = " . NOTIFY_YES . "
1332 WHERE $where_sql = $match_id
1333 AND user_id = $user_id";
1334 $db->sql_query($sql);
1335 }
1336 }
1337 }
1338 else
1339 {
1340 if (isset($_GET['watch']))
1341 {
1342 $uid = request_var('uid', 0);
1343 $token = request_var('hash', '');
1344
1345 if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true))
1346 {
1347 if ($uid != $user_id || $request->variable('watch', '', false, \phpbb\request\request_interface::GET) != $mode)
1348 {
1349 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
1350 $message = $user->lang['ERR_WATCHING'];
1351
1352 if (!$request->is_ajax())
1353 {
1354 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>');
1355 }
1356 trigger_error($message);
1357 }
1358
1359 $is_watching = true;
1360
1361 $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status)
1362 VALUES ($user_id, $match_id, " . NOTIFY_YES . ')';
1363 $db->sql_query($sql);
1364
1365 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start");
1366 $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)];
1367
1368 if (!$request->is_ajax())
1369 {
1370 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>');
1371 }
1372 meta_refresh(3, $redirect_url);
1373 trigger_error($message);
1374 }
1375 else
1376 {
1377 $s_hidden_fields = array(
1378 'uid' => $user->data['user_id'],
1379 'watch' => $mode,
1380 'start' => $start,
1381 'f' => $forum_id,
1382 );
1383 if ($mode != 'forum')
1384 {
1385 $s_hidden_fields['t'] = $topic_id;
1386 }
1387
1388 $confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title));
1389 confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields));
1390 }
1391 }
1392 else
1393 {
1394 $is_watching = 0;
1395 }
1396 }
1397 }
1398 else
1399 {
1400 if ((isset($_GET['unwatch']) && $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) == $mode) ||
1401 (isset($_GET['watch']) && $request->variable('watch', '', false, \phpbb\request\request_interface::GET) == $mode))
1402 {
1403 login_box();
1404 }
1405 else
1406 {
1407 $can_watch = 0;
1408 $is_watching = 0;
1409 }
1410 }
1411
1412 if ($can_watch)
1413 {
1414 $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"));
1415 $s_watching['link_toggle'] = 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"));
1416 $s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
1417 $s_watching['title_toggle'] = $user->lang[((!$is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
1418 $s_watching['is_watching'] = $is_watching;
1419 }
1420
1421 return;
1422 }
1423
1424 /**
1425 * Get user rank title and image
1426 *
1427 * @param array $user_data the current stored users data
1428 * @param int $user_posts the users number of posts
1429 *
1430 * @return array An associative array containing the rank title (title), the rank image source (img) and the rank image as full img tag (img)
1431 *
1432 * 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
1433 */
1434 function phpbb_get_user_rank($user_data, $user_posts)
1435 {
1436 global $ranks, $config, $phpbb_root_path, $phpbb_path_helper, $phpbb_dispatcher;
1437
1438 $user_rank_data = array(
1439 'title' => null,
1440 'img' => null,
1441 'img_src' => null,
1442 );
1443
1444 /**
1445 * Preparing a user's rank before displaying
1446 *
1447 * @event core.modify_user_rank
1448 * @var array user_data Array with user's data
1449 * @var int user_posts User_posts to change
1450 * @since 3.1.0-RC4
1451 */
1452
1453 $vars = array('user_data', 'user_posts');
1454 extract($phpbb_dispatcher->trigger_event('core.modify_user_rank', compact($vars)));
1455
1456 if (empty($ranks))
1457 {
1458 global $cache;
1459 $ranks = $cache->obtain_ranks();
1460 }
1461
1462 if (!empty($user_data['user_rank']))
1463 {
1464
1465 $user_rank_data['title'] = (isset($ranks['special'][$user_data['user_rank']]['rank_title'])) ? $ranks['special'][$user_data['user_rank']]['rank_title'] : '';
1466
1467 $user_rank_data['img_src'] = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_data['user_rank']]['rank_image']) : '';
1468
1469 $user_rank_data['img'] = (!empty($ranks['special'][$user_data['user_rank']]['rank_image'])) ? '<img src="' . $user_rank_data['img_src'] . '" alt="' . $ranks['special'][$user_data['user_rank']]['rank_title'] . '" title="' . $ranks['special'][$user_data['user_rank']]['rank_title'] . '" />' : '';
1470 }
1471 else if ($user_posts !== false)
1472 {
1473 if (!empty($ranks['normal']))
1474 {
1475 foreach ($ranks['normal'] as $rank)
1476 {
1477 if ($user_posts >= $rank['rank_min'])
1478 {
1479 $user_rank_data['title'] = $rank['rank_title'];
1480 $user_rank_data['img_src'] = (!empty($rank['rank_image'])) ? $phpbb_path_helper->update_web_root_path($phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image']) : '';
1481 $user_rank_data['img'] = (!empty($rank['rank_image'])) ? '<img src="' . $user_rank_data['img_src'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
1482 break;
1483 }
1484 }
1485 }
1486 }
1487
1488 return $user_rank_data;
1489 }
1490
1491 /**
1492 * Prepare profile data
1493 */
1494 function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true)
1495 {
1496 global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
1497
1498 $username = $data['username'];
1499 $user_id = $data['user_id'];
1500
1501 $user_rank_data = phpbb_get_user_rank($data, (($user_id == ANONYMOUS) ? false : $data['user_posts']));
1502
1503 if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user'))
1504 {
1505 $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']);
1506 }
1507 else
1508 {
1509 $email = '';
1510 }
1511
1512 if ($config['load_onlinetrack'])
1513 {
1514 $update_time = $config['load_online_time'] * 60;
1515 $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
1516 }
1517 else
1518 {
1519 $online = false;
1520 }
1521
1522 if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline'))
1523 {
1524 $last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit'];
1525 }
1526 else
1527 {
1528 $last_active = '';
1529 }
1530
1531 $age = '';
1532
1533 if ($config['allow_birthdays'] && $data['user_birthday'])
1534 {
1535 list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday']));
1536
1537 if ($bday_year)
1538 {
1539 $now = $user->create_datetime();
1540 $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
1541
1542 $diff = $now['mon'] - $bday_month;
1543 if ($diff == 0)
1544 {
1545 $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
1546 }
1547 else
1548 {
1549 $diff = ($diff < 0) ? 1 : 0;
1550 }
1551
1552 $age = max(0, (int) ($now['year'] - $bday_year - $diff));
1553 }
1554 }
1555
1556 if (!function_exists('phpbb_get_banned_user_ids'))
1557 {
1558 include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1559 }
1560
1561 // Can this user receive a Private Message?
1562 $can_receive_pm = $check_can_receive_pm && (
1563 // They must be a "normal" user
1564 $data['user_type'] != USER_IGNORE &&
1565
1566 // They must not be deactivated by the administrator
1567 ($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) &&
1568
1569 // They must be able to read PMs
1570 sizeof($auth->acl_get_list($user_id, 'u_readpm')) &&
1571
1572 // They must not be permanently banned
1573 !sizeof(phpbb_get_banned_user_ids($user_id, false)) &&
1574
1575 // They must allow users to contact via PM
1576 (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm'])
1577 );
1578
1579 // Dump it out to the template
1580 $template_data = array(
1581 'AGE' => $age,
1582 'RANK_TITLE' => $user_rank_data['title'],
1583 'JOINED' => $user->format_date($data['user_regdate']),
1584 'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active),
1585 'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0,
1586 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0,
1587
1588 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']),
1589 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']),
1590 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']),
1591 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']),
1592
1593 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])),
1594
1595 'AVATAR_IMG' => phpbb_get_user_avatar($data),
1596 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
1597 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false,
1598 'RANK_IMG' => $user_rank_data['img'],
1599 'RANK_IMG_SRC' => $user_rank_data['img_src'],
1600 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false,
1601
1602 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false,
1603
1604 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '',
1605 'U_NOTES' => ($user_notes_enabled && $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $user_id, true, $user->session_id) : '',
1606 'U_WARN' => ($warn_user_enabled && $auth->acl_get('m_warn')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user&u=' . $user_id, true, $user->session_id) : '',
1607 'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && $can_receive_pm) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $user_id) : '',
1608 'U_EMAIL' => $email,
1609 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '',
1610
1611 'USER_JABBER' => $data['user_jabber'],
1612 'USER_JABBER_IMG' => ($data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '',
1613
1614 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username),
1615 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username),
1616 'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username),
1617 );
1618
1619 /**
1620 * Preparing a user's data before displaying it in profile and memberlist
1621 *
1622 * @event core.memberlist_prepare_profile_data
1623 * @var array data Array with user's data
1624 * @var array template_data Template array with user's data
1625 * @since 3.1.0-a1
1626 */
1627 $vars = array('data', 'template_data');
1628 extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
1629
1630 return $template_data;
1631 }
1632
1633 function phpbb_sort_last_active($first, $second)
1634 {
1635 global $id_cache, $sort_dir;
1636
1637 $lesser_than = ($sort_dir === 'd') ? -1 : 1;
1638
1639 if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader']))
1640 {
1641 return -1;
1642 }
1643 else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader'])
1644 {
1645 return 1;
1646 }
1647 else
1648 {
1649 return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']);
1650 }
1651 }
1652