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