[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 /** 23 * Display Forums 24 */ 25 function display_forums($root_data = '', $display_moderators = true, $return_moderators = false) 26 { 27 global $db, $auth, $user, $template; 28 global $phpbb_root_path, $phpEx, $config; 29 global $request, $phpbb_dispatcher, $phpbb_container; 30 31 $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array(); 32 $parent_id = $visible_forums = 0; 33 34 // Mark forums read? 35 $mark_read = $request->variable('mark', ''); 36 37 if ($mark_read == 'all') 38 { 39 $mark_read = ''; 40 } 41 42 if (!$root_data) 43 { 44 if ($mark_read == 'forums') 45 { 46 $mark_read = 'all'; 47 } 48 49 $root_data = array('forum_id' => 0); 50 $sql_where = ''; 51 } 52 else 53 { 54 $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id']; 55 } 56 57 // Handle marking everything read 58 if ($mark_read == 'all') 59 { 60 $redirect = build_url(array('mark', 'hash', 'mark_time')); 61 meta_refresh(3, $redirect); 62 63 if (check_link_hash($request->variable('hash', ''), 'global')) 64 { 65 markread('all', false, false, $request->variable('mark_time', 0)); 66 67 if ($request->is_ajax()) 68 { 69 // Tell the ajax script what language vars and URL need to be replaced 70 $data = array( 71 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 72 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], 73 '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(), false) : '', 74 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 75 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] 76 ); 77 $json_response = new \phpbb\json_response(); 78 $json_response->send($data); 79 } 80 81 trigger_error( 82 $user->lang['FORUMS_MARKED'] . '<br /><br />' . 83 sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>') 84 ); 85 } 86 else 87 { 88 trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>')); 89 } 90 } 91 92 // Display list of active topics for this category? 93 $show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; 94 95 $sql_array = array( 96 'SELECT' => 'f.*', 97 'FROM' => array( 98 FORUMS_TABLE => 'f' 99 ), 100 'LEFT_JOIN' => array(), 101 ); 102 103 if ($config['load_db_lastread'] && $user->data['is_registered']) 104 { 105 $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'); 106 $sql_array['SELECT'] .= ', ft.mark_time'; 107 } 108 else if ($config['load_anon_lastread'] || $user->data['is_registered']) 109 { 110 $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); 111 $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); 112 113 if (!$user->data['is_registered']) 114 { 115 $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; 116 } 117 } 118 119 if ($show_active) 120 { 121 $sql_array['LEFT_JOIN'][] = array( 122 'FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 123 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'" 124 ); 125 126 $sql_array['SELECT'] .= ', fa.user_id'; 127 } 128 129 $sql_ary = array( 130 'SELECT' => $sql_array['SELECT'], 131 'FROM' => $sql_array['FROM'], 132 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 133 134 'WHERE' => $sql_where, 135 136 'ORDER_BY' => 'f.left_id', 137 ); 138 139 /** 140 * Event to modify the SQL query before the forum data is queried 141 * 142 * @event core.display_forums_modify_sql 143 * @var array sql_ary The SQL array to get the data of the forums 144 * @since 3.1.0-a1 145 */ 146 $vars = array('sql_ary'); 147 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars))); 148 149 $sql = $db->sql_build_query('SELECT', $sql_ary); 150 $result = $db->sql_query($sql); 151 152 $forum_tracking_info = $valid_categories = array(); 153 $branch_root_id = $root_data['forum_id']; 154 155 /* @var $phpbb_content_visibility \phpbb\content_visibility */ 156 $phpbb_content_visibility = $phpbb_container->get('content.visibility'); 157 158 while ($row = $db->sql_fetchrow($result)) 159 { 160 /** 161 * Event to modify the data set of a forum 162 * 163 * This event is triggered once per forum 164 * 165 * @event core.display_forums_modify_row 166 * @var int branch_root_id Last top-level forum 167 * @var array row The data of the forum 168 * @since 3.1.0-a1 169 */ 170 $vars = array('branch_root_id', 'row'); 171 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars))); 172 173 $forum_id = $row['forum_id']; 174 175 // Mark forums read? 176 if ($mark_read == 'forums') 177 { 178 if ($auth->acl_get('f_list', $forum_id)) 179 { 180 $forum_ids[] = $forum_id; 181 } 182 183 continue; 184 } 185 186 // Category with no members 187 if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) 188 { 189 continue; 190 } 191 192 // Skip branch 193 if (isset($right_id)) 194 { 195 if ($row['left_id'] < $right_id) 196 { 197 continue; 198 } 199 unset($right_id); 200 } 201 202 if (!$auth->acl_get('f_list', $forum_id)) 203 { 204 // if the user does not have permissions to list this forum, skip everything until next branch 205 $right_id = $row['right_id']; 206 continue; 207 } 208 209 if ($config['load_db_lastread'] && $user->data['is_registered']) 210 { 211 $forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark']; 212 } 213 else if ($config['load_anon_lastread'] || $user->data['is_registered']) 214 { 215 if (!$user->data['is_registered']) 216 { 217 $user->data['user_lastmark'] = (isset($tracking_topics['l'])) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0; 218 } 219 $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']; 220 } 221 222 // Lets check whether there are unapproved topics/posts, so we can display an information to moderators 223 $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; 224 $row['forum_id_unapproved_posts'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_posts_unapproved']) ? $forum_id : 0; 225 $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); 226 $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); 227 228 // Display active topics from this forum? 229 if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) 230 { 231 if (!isset($active_forum_ary['forum_topics'])) 232 { 233 $active_forum_ary['forum_topics'] = 0; 234 } 235 236 if (!isset($active_forum_ary['forum_posts'])) 237 { 238 $active_forum_ary['forum_posts'] = 0; 239 } 240 241 $active_forum_ary['forum_id'][] = $forum_id; 242 $active_forum_ary['enable_icons'][] = $row['enable_icons']; 243 $active_forum_ary['forum_topics'] += $row['forum_topics']; 244 $active_forum_ary['forum_posts'] += $row['forum_posts']; 245 246 // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it... 247 if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) 248 { 249 $active_forum_ary['exclude_forum_id'][] = $forum_id; 250 } 251 } 252 253 // Fill list of categories with forums 254 if (isset($forum_rows[$row['parent_id']])) 255 { 256 $valid_categories[$row['parent_id']] = true; 257 } 258 259 // 260 if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) 261 { 262 if ($row['forum_type'] != FORUM_CAT) 263 { 264 $forum_ids_moderator[] = (int) $forum_id; 265 } 266 267 // Direct child of current branch 268 $parent_id = $forum_id; 269 $forum_rows[$forum_id] = $row; 270 271 if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) 272 { 273 $branch_root_id = $forum_id; 274 } 275 $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id']; 276 $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password']; 277 $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; 278 } 279 else if ($row['forum_type'] != FORUM_CAT) 280 { 281 $subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false; 282 $subforums[$parent_id][$forum_id]['name'] = $row['forum_name']; 283 $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time']; 284 $subforums[$parent_id][$forum_id]['children'] = array(); 285 $subforums[$parent_id][$forum_id]['type'] = $row['forum_type']; 286 287 if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) 288 { 289 $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id; 290 } 291 292 if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) 293 { 294 $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; 295 } 296 297 if (!$forum_rows[$parent_id]['forum_id_unapproved_posts'] && $row['forum_id_unapproved_posts']) 298 { 299 $forum_rows[$parent_id]['forum_id_unapproved_posts'] = $forum_id; 300 } 301 302 $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; 303 304 // Do not list redirects in LINK Forums as Posts. 305 if ($row['forum_type'] != FORUM_LINK) 306 { 307 $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts']; 308 } 309 310 if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) 311 { 312 $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id']; 313 $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject']; 314 $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time']; 315 $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id']; 316 $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name']; 317 $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour']; 318 $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id; 319 $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password']; 320 } 321 } 322 323 /** 324 * Event to modify the forum rows data set 325 * 326 * This event is triggered once per forum 327 * 328 * @event core.display_forums_modify_forum_rows 329 * @var array forum_rows Data array of all forums we display 330 * @var array subforums Data array of all subforums we display 331 * @var int branch_root_id Current top-level forum 332 * @var int parent_id Current parent forum 333 * @var array row The data of the forum 334 * @since 3.1.0-a1 335 */ 336 $vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row'); 337 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars))); 338 } 339 $db->sql_freeresult($result); 340 341 // Handle marking posts 342 if ($mark_read == 'forums') 343 { 344 $redirect = build_url(array('mark', 'hash', 'mark_time')); 345 $token = $request->variable('hash', ''); 346 if (check_link_hash($token, 'global')) 347 { 348 markread('topics', $forum_ids, false, $request->variable('mark_time', 0)); 349 $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>'); 350 meta_refresh(3, $redirect); 351 352 if ($request->is_ajax()) 353 { 354 // Tell the ajax script what language vars and URL need to be replaced 355 $data = array( 356 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 357 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], 358 '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(), false) : '', 359 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 360 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] 361 ); 362 $json_response = new \phpbb\json_response(); 363 $json_response->send($data); 364 } 365 366 trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message); 367 } 368 else 369 { 370 $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'); 371 meta_refresh(3, $redirect); 372 trigger_error($message); 373 } 374 375 } 376 377 // Grab moderators ... if necessary 378 if ($display_moderators) 379 { 380 if ($return_moderators) 381 { 382 $forum_ids_moderator[] = $root_data['forum_id']; 383 } 384 get_moderators($forum_moderators, $forum_ids_moderator); 385 } 386 387 /** 388 * Event to perform additional actions before the forum list is being generated 389 * 390 * @event core.display_forums_before 391 * @var array active_forum_ary Array with forum data to display active topics 392 * @var bool display_moderators Flag indicating if we display forum moderators 393 * @var array forum_moderators Array with forum moderators list 394 * @var array forum_rows Data array of all forums we display 395 * @var bool return_moderators Flag indicating if moderators list should be returned 396 * @var array root_data Array with the root forum data 397 * @since 3.1.4-RC1 398 */ 399 $vars = array( 400 'active_forum_ary', 401 'display_moderators', 402 'forum_moderators', 403 'forum_rows', 404 'return_moderators', 405 'root_data', 406 ); 407 extract($phpbb_dispatcher->trigger_event('core.display_forums_before', compact($vars))); 408 409 // Used to tell whatever we have to create a dummy category or not. 410 $last_catless = true; 411 foreach ($forum_rows as $row) 412 { 413 // Category 414 if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) 415 { 416 // Do not display categories without any forums to display 417 if (!isset($valid_categories[$row['forum_id']])) 418 { 419 continue; 420 } 421 422 $cat_row = array( 423 'S_IS_CAT' => true, 424 'FORUM_ID' => $row['forum_id'], 425 'FORUM_NAME' => $row['forum_name'], 426 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 427 'FORUM_FOLDER_IMG' => '', 428 'FORUM_FOLDER_IMG_SRC' => '', 429 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '', 430 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', 431 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']), 432 ); 433 434 /** 435 * Modify the template data block of the 'category' 436 * 437 * This event is triggered once per 'category' 438 * 439 * @event core.display_forums_modify_category_template_vars 440 * @var array cat_row Template data of the 'category' 441 * @var bool last_catless The flag indicating whether the last forum had a parent category 442 * @var array root_data Array with the root forum data 443 * @var array row The data of the 'category' 444 * @since 3.1.0-RC4 445 * @changed 3.1.7-RC1 Removed undefined catless variable 446 */ 447 $vars = array( 448 'cat_row', 449 'last_catless', 450 'root_data', 451 'row', 452 ); 453 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_category_template_vars', compact($vars))); 454 455 $template->assign_block_vars('forumrow', $cat_row); 456 457 continue; 458 } 459 460 $visible_forums++; 461 $forum_id = $row['forum_id']; 462 463 $forum_unread = (isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id]) ? true : false; 464 465 $folder_image = $folder_alt = $l_subforums = ''; 466 $subforums_list = array(); 467 468 // Generate list of subforums if we need to 469 if (isset($subforums[$forum_id])) 470 { 471 foreach ($subforums[$forum_id] as $subforum_id => $subforum_row) 472 { 473 $subforum_unread = (isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id]) ? true : false; 474 475 if (!$subforum_unread && !empty($subforum_row['children'])) 476 { 477 foreach ($subforum_row['children'] as $child_id) 478 { 479 if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id]) 480 { 481 // Once we found an unread child forum, we can drop out of this loop 482 $subforum_unread = true; 483 break; 484 } 485 } 486 } 487 488 if ($subforum_row['display'] && $subforum_row['name']) 489 { 490 $subforums_list[] = array( 491 'link' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $subforum_id), 492 'name' => $subforum_row['name'], 493 'unread' => $subforum_unread, 494 'type' => $subforum_row['type'], 495 ); 496 } 497 else 498 { 499 unset($subforums[$forum_id][$subforum_id]); 500 } 501 502 // If one subforum is unread the forum gets unread too... 503 if ($subforum_unread) 504 { 505 $forum_unread = true; 506 } 507 } 508 509 $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS']; 510 $folder_image = ($forum_unread) ? 'forum_unread_subforum' : 'forum_read_subforum'; 511 } 512 else 513 { 514 switch ($row['forum_type']) 515 { 516 case FORUM_POST: 517 $folder_image = ($forum_unread) ? 'forum_unread' : 'forum_read'; 518 break; 519 520 case FORUM_LINK: 521 $folder_image = 'forum_link'; 522 break; 523 } 524 } 525 526 // Which folder should we display? 527 if ($row['forum_status'] == ITEM_LOCKED) 528 { 529 $folder_image = ($forum_unread) ? 'forum_unread_locked' : 'forum_read_locked'; 530 $folder_alt = 'FORUM_LOCKED'; 531 } 532 else 533 { 534 $folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS'; 535 } 536 537 // Create last post link information, if appropriate 538 if ($row['forum_last_post_id']) 539 { 540 if ($row['forum_password_last_post'] === '' && $auth->acl_gets('f_read', 'f_list_topics', $row['forum_id_last_post'])) 541 { 542 $last_post_subject = utf8_decode_ncr(censor_text($row['forum_last_post_subject'])); 543 544 $last_post_subject_truncated = truncate_string($last_post_subject, 30, 255, false, $user->lang['ELLIPSIS']); 545 } 546 else 547 { 548 $last_post_subject = $last_post_subject_truncated = ''; 549 } 550 $last_post_time = $user->format_date($row['forum_last_post_time']); 551 $last_post_time_rfc3339 = gmdate(DATE_RFC3339, $row['forum_last_post_time']); 552 $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']; 553 } 554 else 555 { 556 $last_post_subject = $last_post_time = $last_post_time_rfc3339 = $last_post_url = $last_post_subject_truncated = ''; 557 } 558 559 // Output moderator listing ... if applicable 560 $l_moderator = $moderators_list = ''; 561 if ($display_moderators && !empty($forum_moderators[$forum_id])) 562 { 563 $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS']; 564 $moderators_list = implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]); 565 } 566 567 $l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS'; 568 $post_click_count = ($row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? $row['forum_posts'] : ''; 569 570 $s_subforums_list = $subforums_row = array(); 571 foreach ($subforums_list as $subforum) 572 { 573 $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>'; 574 $subforums_row[] = array( 575 'U_SUBFORUM' => $subforum['link'], 576 'SUBFORUM_NAME' => $subforum['name'], 577 'S_UNREAD' => $subforum['unread'], 578 'IS_LINK' => $subforum['type'] == FORUM_LINK, 579 ); 580 } 581 $s_subforums_list = (string) implode($user->lang['COMMA_SEPARATOR'], $s_subforums_list); 582 $catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false; 583 584 if ($row['forum_type'] != FORUM_LINK) 585 { 586 $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); 587 } 588 else 589 { 590 // If the forum is a link and we count redirects we need to visit it 591 // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum 592 if (($row['forum_flags'] & FORUM_FLAG_LINK_TRACK) || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id)) 593 { 594 $u_viewforum = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']); 595 } 596 else 597 { 598 $u_viewforum = $row['forum_link']; 599 } 600 } 601 602 $forum_row = array( 603 'S_IS_CAT' => false, 604 'S_NO_CAT' => $catless && !$last_catless, 605 'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false, 606 'S_UNREAD_FORUM' => $forum_unread, 607 'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']), 608 'S_LOCKED_FORUM' => ($row['forum_status'] == ITEM_LOCKED) ? true : false, 609 'S_LIST_SUBFORUMS' => ($row['display_subforum_list']) ? true : false, 610 'S_SUBFORUMS' => (count($subforums_list)) ? true : false, 611 'S_DISPLAY_SUBJECT' => ($last_post_subject !== '' && $config['display_last_subject']) ? true : false, 612 'S_FEED_ENABLED' => ($config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST) ? true : false, 613 614 'FORUM_ID' => $row['forum_id'], 615 'FORUM_NAME' => $row['forum_name'], 616 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 617 'TOPICS' => $row['forum_topics'], 618 $l_post_click_count => $post_click_count, 619 'FORUM_IMG_STYLE' => $folder_image, 620 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 621 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', 622 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '', 623 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', 624 'LAST_POST_SUBJECT' => $last_post_subject, 625 'LAST_POST_SUBJECT_TRUNCATED' => $last_post_subject_truncated, 626 'LAST_POST_TIME' => $last_post_time, 627 'LAST_POST_TIME_RFC3339'=> $last_post_time_rfc3339, 628 'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 629 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 630 'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 631 'MODERATORS' => $moderators_list, 632 'SUBFORUMS' => $s_subforums_list, 633 634 'L_SUBFORUM_STR' => $l_subforums, 635 'L_MODERATOR_STR' => $l_moderator, 636 637 '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']) : '', 638 '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']) : '', 639 'U_VIEWFORUM' => $u_viewforum, 640 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 641 'U_LAST_POST' => $last_post_url, 642 ); 643 644 /** 645 * Modify the template data block of the forum 646 * 647 * This event is triggered once per forum 648 * 649 * @event core.display_forums_modify_template_vars 650 * @var array forum_row Template data of the forum 651 * @var array row The data of the forum 652 * @var array subforums_row Template data of subforums 653 * @since 3.1.0-a1 654 * @changed 3.1.0-b5 Added var subforums_row 655 */ 656 $vars = array('forum_row', 'row', 'subforums_row'); 657 extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars))); 658 659 $template->assign_block_vars('forumrow', $forum_row); 660 661 // Assign subforums loop for style authors 662 $template->assign_block_vars_array('forumrow.subforum', $subforums_row); 663 664 /** 665 * Modify and/or assign additional template data for the forum 666 * after forumrow loop has been assigned. This can be used 667 * to create additional forumrow subloops in extensions. 668 * 669 * This event is triggered once per forum 670 * 671 * @event core.display_forums_add_template_data 672 * @var array forum_row Template data of the forum 673 * @var array row The data of the forum 674 * @var array subforums_list The data of subforums 675 * @var array subforums_row Template data of subforums 676 * @var bool catless The flag indicating whether a forum has a parent category 677 * @since 3.1.0-b5 678 */ 679 $vars = array( 680 'forum_row', 681 'row', 682 'subforums_list', 683 'subforums_row', 684 'catless', 685 ); 686 extract($phpbb_dispatcher->trigger_event('core.display_forums_add_template_data', compact($vars))); 687 688 $last_catless = $catless; 689 } 690 691 $template->assign_vars(array( 692 '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()) : '', 693 'S_HAS_SUBFORUM' => ($visible_forums) ? true : false, 694 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 695 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 696 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), 697 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED_FORUM'), 698 )); 699 700 /** 701 * Event to perform additional actions after the forum list has been generated 702 * 703 * @event core.display_forums_after 704 * @var array active_forum_ary Array with forum data to display active topics 705 * @var bool display_moderators Flag indicating if we display forum moderators 706 * @var array forum_moderators Array with forum moderators list 707 * @var array forum_rows Data array of all forums we display 708 * @var bool return_moderators Flag indicating if moderators list should be returned 709 * @var array root_data Array with the root forum data 710 * @since 3.1.0-RC5 711 */ 712 $vars = array( 713 'active_forum_ary', 714 'display_moderators', 715 'forum_moderators', 716 'forum_rows', 717 'return_moderators', 718 'root_data', 719 ); 720 extract($phpbb_dispatcher->trigger_event('core.display_forums_after', compact($vars))); 721 722 if ($return_moderators) 723 { 724 return array($active_forum_ary, $forum_moderators); 725 } 726 727 return array($active_forum_ary, array()); 728 } 729 730 /** 731 * Create forum rules for given forum 732 */ 733 function generate_forum_rules(&$forum_data) 734 { 735 if ($forum_data['forum_rules']) 736 { 737 $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']); 738 } 739 740 if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link']) 741 { 742 return; 743 } 744 745 global $template; 746 747 $template->assign_vars(array( 748 'S_FORUM_RULES' => true, 749 'U_FORUM_RULES' => $forum_data['forum_rules_link'], 750 'FORUM_RULES' => $forum_data['forum_rules']) 751 ); 752 } 753 754 /** 755 * Create forum navigation links for given forum, create parent 756 * list if currently null, assign basic forum info to template 757 */ 758 function generate_forum_nav(&$forum_data_ary) 759 { 760 global $template, $auth, $config; 761 global $phpEx, $phpbb_root_path, $phpbb_dispatcher; 762 763 if (!$auth->acl_get('f_list', $forum_data_ary['forum_id'])) 764 { 765 return; 766 } 767 768 $navlinks_parents = $forum_template_data = array(); 769 770 // Get forum parents 771 $forum_parents = get_forum_parents($forum_data_ary); 772 773 $microdata_attr = 'data-forum-id'; 774 775 // Build navigation links 776 if (!empty($forum_parents)) 777 { 778 foreach ($forum_parents as $parent_forum_id => $parent_data) 779 { 780 list($parent_name, $parent_type) = array_values($parent_data); 781 782 // Skip this parent if the user does not have the permission to view it 783 if (!$auth->acl_get('f_list', $parent_forum_id)) 784 { 785 continue; 786 } 787 788 $navlinks_parents[] = array( 789 'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false, 790 'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false, 791 'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false, 792 'FORUM_NAME' => $parent_name, 793 'FORUM_ID' => $parent_forum_id, 794 'MICRODATA' => $microdata_attr . '="' . $parent_forum_id . '"', 795 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $parent_forum_id), 796 ); 797 } 798 } 799 800 $navlinks = array( 801 'S_IS_CAT' => ($forum_data_ary['forum_type'] == FORUM_CAT) ? true : false, 802 'S_IS_LINK' => ($forum_data_ary['forum_type'] == FORUM_LINK) ? true : false, 803 'S_IS_POST' => ($forum_data_ary['forum_type'] == FORUM_POST) ? true : false, 804 'FORUM_NAME' => $forum_data_ary['forum_name'], 805 'FORUM_ID' => $forum_data_ary['forum_id'], 806 'MICRODATA' => $microdata_attr . '="' . $forum_data_ary['forum_id'] . '"', 807 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_data_ary['forum_id']), 808 ); 809 810 $forum_template_data = array( 811 'FORUM_ID' => $forum_data_ary['forum_id'], 812 'FORUM_NAME' => $forum_data_ary['forum_name'], 813 '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']), 814 815 '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, 816 ); 817 818 $forum_data = $forum_data_ary; 819 /** 820 * Event to modify the navlinks text 821 * 822 * @event core.generate_forum_nav 823 * @var array forum_data Array with the forum data 824 * @var array forum_template_data Array with generic forum template data 825 * @var string microdata_attr The microdata attribute 826 * @var array navlinks_parents Array with the forum parents navlinks data 827 * @var array navlinks Array with the forum navlinks data 828 * @since 3.1.5-RC1 829 */ 830 $vars = array( 831 'forum_data', 832 'forum_template_data', 833 'microdata_attr', 834 'navlinks_parents', 835 'navlinks', 836 ); 837 extract($phpbb_dispatcher->trigger_event('core.generate_forum_nav', compact($vars))); 838 $forum_data_ary = $forum_data; 839 unset($forum_data); 840 841 $template->assign_block_vars_array('navlinks', $navlinks_parents); 842 $template->assign_block_vars('navlinks', $navlinks); 843 $template->assign_vars($forum_template_data); 844 845 return; 846 } 847 848 /** 849 * Returns forum parents as an array. Get them from forum_data if available, or update the database otherwise 850 */ 851 function get_forum_parents(&$forum_data) 852 { 853 global $db; 854 855 $forum_parents = array(); 856 857 if ($forum_data['parent_id'] > 0) 858 { 859 if ($forum_data['forum_parents'] == '') 860 { 861 $sql = 'SELECT forum_id, forum_name, forum_type 862 FROM ' . FORUMS_TABLE . ' 863 WHERE left_id < ' . $forum_data['left_id'] . ' 864 AND right_id > ' . $forum_data['right_id'] . ' 865 ORDER BY left_id ASC'; 866 $result = $db->sql_query($sql); 867 868 while ($row = $db->sql_fetchrow($result)) 869 { 870 $forum_parents[$row['forum_id']] = array($row['forum_name'], (int) $row['forum_type']); 871 } 872 $db->sql_freeresult($result); 873 874 $forum_data['forum_parents'] = serialize($forum_parents); 875 876 $sql = 'UPDATE ' . FORUMS_TABLE . " 877 SET forum_parents = '" . $db->sql_escape($forum_data['forum_parents']) . "' 878 WHERE parent_id = " . $forum_data['parent_id']; 879 $db->sql_query($sql); 880 } 881 else 882 { 883 $forum_parents = unserialize($forum_data['forum_parents']); 884 } 885 } 886 887 return $forum_parents; 888 } 889 890 /** 891 * Obtain list of moderators of each forum 892 */ 893 function get_moderators(&$forum_moderators, $forum_id = false) 894 { 895 global $db, $phpbb_root_path, $phpEx, $user, $auth; 896 global $phpbb_container; 897 898 $forum_id_ary = array(); 899 900 if ($forum_id !== false) 901 { 902 if (!is_array($forum_id)) 903 { 904 $forum_id = array($forum_id); 905 } 906 907 // Exchange key/value pair to be able to faster check for the forum id existence 908 $forum_id_ary = array_flip($forum_id); 909 } 910 911 $sql_array = array( 912 'SELECT' => 'm.*, u.user_colour, g.group_colour, g.group_type', 913 914 'FROM' => array( 915 MODERATOR_CACHE_TABLE => 'm', 916 ), 917 918 'LEFT_JOIN' => array( 919 array( 920 'FROM' => array(USERS_TABLE => 'u'), 921 'ON' => 'm.user_id = u.user_id', 922 ), 923 array( 924 'FROM' => array(GROUPS_TABLE => 'g'), 925 'ON' => 'm.group_id = g.group_id', 926 ), 927 ), 928 929 'WHERE' => 'm.display_on_index = 1', 930 ); 931 932 /** @var \phpbb\group\helper $group_helper */ 933 $group_helper = $phpbb_container->get('group_helper'); 934 935 // We query every forum here because for caching we should not have any parameter. 936 $sql = $db->sql_build_query('SELECT', $sql_array); 937 $result = $db->sql_query($sql, 3600); 938 939 while ($row = $db->sql_fetchrow($result)) 940 { 941 $f_id = (int) $row['forum_id']; 942 943 if (!isset($forum_id_ary[$f_id])) 944 { 945 continue; 946 } 947 948 if (!empty($row['user_id'])) 949 { 950 $forum_moderators[$f_id][] = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']); 951 } 952 else 953 { 954 $group_name = $group_helper->get_name($row['group_name']); 955 956 if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) 957 { 958 $forum_moderators[$f_id][] = '<span' . (($row['group_colour']) ? ' style="color:#' . $row['group_colour'] . ';"' : '') . '>' . $group_name . '</span>'; 959 } 960 else 961 { 962 $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>'; 963 } 964 } 965 } 966 $db->sql_freeresult($result); 967 968 return; 969 } 970 971 /** 972 * User authorisation levels output 973 * 974 * @param string $mode Can be forum or topic. Not in use at the moment. 975 * @param int $forum_id The current forum the user is in. 976 * @param int $forum_status The forums status bit. 977 */ 978 function gen_forum_auth_level($mode, $forum_id, $forum_status) 979 { 980 global $template, $auth, $user, $config; 981 982 $locked = ($forum_status == ITEM_LOCKED && !$auth->acl_get('m_edit', $forum_id)) ? true : false; 983 984 $rules = array( 985 ($auth->acl_get('f_post', $forum_id) && !$locked) ? $user->lang['RULES_POST_CAN'] : $user->lang['RULES_POST_CANNOT'], 986 ($auth->acl_get('f_reply', $forum_id) && !$locked) ? $user->lang['RULES_REPLY_CAN'] : $user->lang['RULES_REPLY_CANNOT'], 987 ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id) && !$locked) ? $user->lang['RULES_EDIT_CAN'] : $user->lang['RULES_EDIT_CANNOT'], 988 ($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'], 989 ); 990 991 if ($config['allow_attachments']) 992 { 993 $rules[] = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && !$locked) ? $user->lang['RULES_ATTACH_CAN'] : $user->lang['RULES_ATTACH_CANNOT']; 994 } 995 996 foreach ($rules as $rule) 997 { 998 $template->assign_block_vars('rules', array('RULE' => $rule)); 999 } 1000 1001 return; 1002 } 1003 1004 /** 1005 * Generate topic status 1006 */ 1007 function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$folder_alt, &$topic_type) 1008 { 1009 global $user, $config; 1010 1011 if ($topic_row['topic_status'] == ITEM_MOVED) 1012 { 1013 $topic_type = $user->lang['VIEW_TOPIC_MOVED']; 1014 $folder_img = 'topic_moved'; 1015 $folder_alt = 'TOPIC_MOVED'; 1016 } 1017 else 1018 { 1019 switch ($topic_row['topic_type']) 1020 { 1021 case POST_GLOBAL: 1022 $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; 1023 $folder = 'global_read'; 1024 $folder_new = 'global_unread'; 1025 break; 1026 1027 case POST_ANNOUNCE: 1028 $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT']; 1029 $folder = 'announce_read'; 1030 $folder_new = 'announce_unread'; 1031 break; 1032 1033 case POST_STICKY: 1034 $topic_type = $user->lang['VIEW_TOPIC_STICKY']; 1035 $folder = 'sticky_read'; 1036 $folder_new = 'sticky_unread'; 1037 break; 1038 1039 default: 1040 $topic_type = ''; 1041 $folder = 'topic_read'; 1042 $folder_new = 'topic_unread'; 1043 1044 // Hot topic threshold is for posts in a topic, which is replies + the first post. ;) 1045 if ($config['hot_threshold'] && ($replies + 1) >= $config['hot_threshold'] && $topic_row['topic_status'] != ITEM_LOCKED) 1046 { 1047 $folder .= '_hot'; 1048 $folder_new .= '_hot'; 1049 } 1050 break; 1051 } 1052 1053 if ($topic_row['topic_status'] == ITEM_LOCKED) 1054 { 1055 $topic_type = $user->lang['VIEW_TOPIC_LOCKED']; 1056 $folder .= '_locked'; 1057 $folder_new .= '_locked'; 1058 } 1059 1060 $folder_img = ($unread_topic) ? $folder_new : $folder; 1061 $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS'); 1062 1063 // Posted image? 1064 if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted']) 1065 { 1066 $folder_img .= '_mine'; 1067 } 1068 } 1069 1070 if ($topic_row['poll_start'] && $topic_row['topic_status'] != ITEM_MOVED) 1071 { 1072 $topic_type = $user->lang['VIEW_TOPIC_POLL']; 1073 } 1074 } 1075 1076 /** 1077 * Assign/Build custom bbcodes for display in screens supporting using of bbcodes 1078 * The custom bbcodes buttons will be placed within the template block 'custom_tags' 1079 */ 1080 function display_custom_bbcodes() 1081 { 1082 global $db, $template, $user, $phpbb_dispatcher; 1083 1084 // Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing) 1085 $num_predefined_bbcodes = NUM_PREDEFINED_BBCODES; 1086 1087 $sql_ary = array( 1088 'SELECT' => 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline', 1089 'FROM' => array(BBCODES_TABLE => 'b'), 1090 'WHERE' => 'b.display_on_posting = 1', 1091 'ORDER_BY' => 'b.bbcode_tag', 1092 ); 1093 1094 /** 1095 * Event to modify the SQL query before custom bbcode data is queried 1096 * 1097 * @event core.display_custom_bbcodes_modify_sql 1098 * @var array sql_ary The SQL array to get the bbcode data 1099 * @var int num_predefined_bbcodes The number of predefined core bbcodes 1100 * (multiplied by factor of 2) 1101 * @since 3.1.0-a3 1102 */ 1103 $vars = array('sql_ary', 'num_predefined_bbcodes'); 1104 extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_sql', compact($vars))); 1105 1106 $result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); 1107 1108 $i = 0; 1109 while ($row = $db->sql_fetchrow($result)) 1110 { 1111 // If the helpline is defined within the language file, we will use the localised version, else just use the database entry... 1112 if (isset($user->lang[strtoupper($row['bbcode_helpline'])])) 1113 { 1114 $row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])]; 1115 } 1116 1117 // Convert Numeric Character References to UTF-8 chars. 1118 $row['bbcode_helpline'] = utf8_decode_ncr($row['bbcode_helpline']); 1119 1120 $custom_tags = array( 1121 'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'", 1122 'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2), 1123 'BBCODE_TAG' => $row['bbcode_tag'], 1124 'BBCODE_TAG_CLEAN' => str_replace('=', '-', $row['bbcode_tag']), 1125 'BBCODE_HELPLINE' => $row['bbcode_helpline'], 1126 ); 1127 1128 /** 1129 * Event to modify the template data block of a custom bbcode 1130 * 1131 * This event is triggered once per bbcode 1132 * 1133 * @event core.display_custom_bbcodes_modify_row 1134 * @var array custom_tags Template data of the bbcode 1135 * @var array row The data of the bbcode 1136 * @since 3.1.0-a1 1137 */ 1138 $vars = array('custom_tags', 'row'); 1139 extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars))); 1140 1141 $template->assign_block_vars('custom_tags', $custom_tags); 1142 1143 $i++; 1144 } 1145 $db->sql_freeresult($result); 1146 1147 /** 1148 * Display custom bbcodes 1149 * 1150 * @event core.display_custom_bbcodes 1151 * @since 3.1.0-a1 1152 */ 1153 $phpbb_dispatcher->dispatch('core.display_custom_bbcodes'); 1154 } 1155 1156 /** 1157 * Display reasons 1158 * 1159 * @deprecated 3.2.0-dev 1160 */ 1161 function display_reasons($reason_id = 0) 1162 { 1163 global $phpbb_container; 1164 1165 $phpbb_container->get('phpbb.report.report_reason_list_provider')->display_reasons($reason_id); 1166 } 1167 1168 /** 1169 * Display user activity (action forum/topic) 1170 */ 1171 function display_user_activity(&$userdata_ary) 1172 { 1173 global $auth, $template, $db, $user, $config; 1174 global $phpbb_root_path, $phpEx; 1175 global $phpbb_container, $phpbb_dispatcher; 1176 1177 // Do not display user activity for users having too many posts... 1178 $limit = $config['load_user_activity_limit']; 1179 if ($userdata_ary['user_posts'] > $limit && $limit != 0) 1180 { 1181 return; 1182 } 1183 1184 $forum_ary = array(); 1185 1186 $forum_read_ary = $auth->acl_getf('f_read'); 1187 foreach ($forum_read_ary as $forum_id => $allowed) 1188 { 1189 if ($allowed['f_read']) 1190 { 1191 $forum_ary[] = (int) $forum_id; 1192 } 1193 } 1194 1195 $forum_ary = array_diff($forum_ary, $user->get_passworded_forums()); 1196 1197 $active_f_row = $active_t_row = array(); 1198 if (!empty($forum_ary)) 1199 { 1200 /* @var $phpbb_content_visibility \phpbb\content_visibility */ 1201 $phpbb_content_visibility = $phpbb_container->get('content.visibility'); 1202 1203 // Obtain active forum 1204 $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts 1205 FROM ' . POSTS_TABLE . ' 1206 WHERE poster_id = ' . $userdata_ary['user_id'] . ' 1207 AND post_postcount = 1 1208 AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' 1209 GROUP BY forum_id 1210 ORDER BY num_posts DESC'; 1211 $result = $db->sql_query_limit($sql, 1); 1212 $active_f_row = $db->sql_fetchrow($result); 1213 $db->sql_freeresult($result); 1214 1215 if (!empty($active_f_row)) 1216 { 1217 $sql = 'SELECT forum_name 1218 FROM ' . FORUMS_TABLE . ' 1219 WHERE forum_id = ' . $active_f_row['forum_id']; 1220 $result = $db->sql_query($sql, 3600); 1221 $active_f_row['forum_name'] = (string) $db->sql_fetchfield('forum_name'); 1222 $db->sql_freeresult($result); 1223 } 1224 1225 // Obtain active topic 1226 $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts 1227 FROM ' . POSTS_TABLE . ' 1228 WHERE poster_id = ' . $userdata_ary['user_id'] . ' 1229 AND post_postcount = 1 1230 AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' 1231 GROUP BY topic_id 1232 ORDER BY num_posts DESC'; 1233 $result = $db->sql_query_limit($sql, 1); 1234 $active_t_row = $db->sql_fetchrow($result); 1235 $db->sql_freeresult($result); 1236 1237 if (!empty($active_t_row)) 1238 { 1239 $sql = 'SELECT topic_title 1240 FROM ' . TOPICS_TABLE . ' 1241 WHERE topic_id = ' . $active_t_row['topic_id']; 1242 $result = $db->sql_query($sql); 1243 $active_t_row['topic_title'] = (string) $db->sql_fetchfield('topic_title'); 1244 $db->sql_freeresult($result); 1245 } 1246 } 1247 1248 $userdata = $userdata_ary; 1249 $show_user_activity = true; 1250 /** 1251 * Alter list of forums and topics to display as active 1252 * 1253 * @event core.display_user_activity_modify_actives 1254 * @var array userdata User's data 1255 * @var array active_f_row List of active forums 1256 * @var array active_t_row List of active posts 1257 * @var bool show_user_activity Show user forum and topic activity 1258 * @since 3.1.0-RC3 1259 * @changed 3.2.5-RC1 Added show_user_activity into event 1260 */ 1261 $vars = array('userdata', 'active_f_row', 'active_t_row', 'show_user_activity'); 1262 extract($phpbb_dispatcher->trigger_event('core.display_user_activity_modify_actives', compact($vars))); 1263 $userdata_ary = $userdata; 1264 unset($userdata); 1265 1266 $userdata_ary['active_t_row'] = $active_t_row; 1267 $userdata_ary['active_f_row'] = $active_f_row; 1268 1269 $active_f_name = $active_f_id = $active_f_count = $active_f_pct = ''; 1270 if (!empty($active_f_row['num_posts'])) 1271 { 1272 $active_f_name = $active_f_row['forum_name']; 1273 $active_f_id = $active_f_row['forum_id']; 1274 $active_f_count = $active_f_row['num_posts']; 1275 $active_f_pct = ($userdata_ary['user_posts']) ? ($active_f_count / $userdata_ary['user_posts']) * 100 : 0; 1276 } 1277 1278 $active_t_name = $active_t_id = $active_t_count = $active_t_pct = ''; 1279 if (!empty($active_t_row['num_posts'])) 1280 { 1281 $active_t_name = $active_t_row['topic_title']; 1282 $active_t_id = $active_t_row['topic_id']; 1283 $active_t_count = $active_t_row['num_posts']; 1284 $active_t_pct = ($userdata_ary['user_posts']) ? ($active_t_count / $userdata_ary['user_posts']) * 100 : 0; 1285 } 1286 1287 $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']; 1288 1289 $template->assign_vars(array( 1290 'ACTIVE_FORUM' => $active_f_name, 1291 'ACTIVE_FORUM_POSTS' => $user->lang('USER_POSTS', (int) $active_f_count), 1292 'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct), 1293 'ACTIVE_TOPIC' => censor_text($active_t_name), 1294 'ACTIVE_TOPIC_POSTS' => $user->lang('USER_POSTS', (int) $active_t_count), 1295 'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct), 1296 'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id), 1297 'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id), 1298 'S_SHOW_ACTIVITY' => $show_user_activity) 1299 ); 1300 } 1301 1302 /** 1303 * Topic and forum watching common code 1304 */ 1305 function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $notify_status = 'unset', $start = 0, $item_title = '') 1306 { 1307 global $db, $user, $phpEx, $start, $phpbb_root_path; 1308 global $request; 1309 1310 $table_sql = ($mode == 'forum') ? FORUMS_WATCH_TABLE : TOPICS_WATCH_TABLE; 1311 $where_sql = ($mode == 'forum') ? 'forum_id' : 'topic_id'; 1312 $match_id = ($mode == 'forum') ? $forum_id : $topic_id; 1313 $u_url = "uid={$user->data['user_id']}"; 1314 $u_url .= ($mode == 'forum') ? '&f' : '&f=' . $forum_id . '&t'; 1315 $is_watching = 0; 1316 1317 // Is user watching this topic? 1318 if ($user_id != ANONYMOUS) 1319 { 1320 $can_watch = true; 1321 1322 if ($notify_status == 'unset') 1323 { 1324 $sql = "SELECT notify_status 1325 FROM $table_sql 1326 WHERE $where_sql = $match_id 1327 AND user_id = $user_id"; 1328 $result = $db->sql_query($sql); 1329 1330 $notify_status = ($row = $db->sql_fetchrow($result)) ? $row['notify_status'] : NULL; 1331 $db->sql_freeresult($result); 1332 } 1333 1334 if (!is_null($notify_status) && $notify_status !== '') 1335 { 1336 if (isset($_GET['unwatch'])) 1337 { 1338 $uid = $request->variable('uid', 0); 1339 $token = $request->variable('hash', ''); 1340 1341 if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) 1342 { 1343 if ($uid != $user_id || $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) != $mode) 1344 { 1345 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); 1346 $message = $user->lang['ERR_UNWATCHING']; 1347 1348 if (!$request->is_ajax()) 1349 { 1350 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>'); 1351 } 1352 trigger_error($message); 1353 } 1354 1355 $sql = 'DELETE FROM ' . $table_sql . " 1356 WHERE $where_sql = $match_id 1357 AND user_id = $user_id"; 1358 $db->sql_query($sql); 1359 1360 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); 1361 $message = $user->lang['NOT_WATCHING_' . strtoupper($mode)]; 1362 1363 if (!$request->is_ajax()) 1364 { 1365 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>'); 1366 } 1367 meta_refresh(3, $redirect_url); 1368 trigger_error($message); 1369 } 1370 else 1371 { 1372 $s_hidden_fields = array( 1373 'uid' => $user->data['user_id'], 1374 'unwatch' => $mode, 1375 'start' => $start, 1376 'f' => $forum_id, 1377 ); 1378 if ($mode != 'forum') 1379 { 1380 $s_hidden_fields['t'] = $topic_id; 1381 } 1382 1383 if ($item_title == '') 1384 { 1385 $confirm_box_message = 'UNWATCH_' . strtoupper($mode); 1386 } 1387 else 1388 { 1389 $confirm_box_message = $user->lang('UNWATCH_' . strtoupper($mode) . '_DETAILED', $item_title); 1390 } 1391 confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); 1392 } 1393 } 1394 else 1395 { 1396 $is_watching = true; 1397 1398 if ($notify_status != NOTIFY_YES) 1399 { 1400 $sql = 'UPDATE ' . $table_sql . " 1401 SET notify_status = " . NOTIFY_YES . " 1402 WHERE $where_sql = $match_id 1403 AND user_id = $user_id"; 1404 $db->sql_query($sql); 1405 } 1406 } 1407 } 1408 else 1409 { 1410 if (isset($_GET['watch'])) 1411 { 1412 $uid = $request->variable('uid', 0); 1413 $token = $request->variable('hash', ''); 1414 1415 if ($token && check_link_hash($token, "{$mode}_$match_id") || confirm_box(true)) 1416 { 1417 if ($uid != $user_id || $request->variable('watch', '', false, \phpbb\request\request_interface::GET) != $mode) 1418 { 1419 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); 1420 $message = $user->lang['ERR_WATCHING']; 1421 1422 if (!$request->is_ajax()) 1423 { 1424 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>'); 1425 } 1426 trigger_error($message); 1427 } 1428 1429 $is_watching = true; 1430 1431 $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status) 1432 VALUES ($user_id, $match_id, " . NOTIFY_YES . ')'; 1433 $db->sql_query($sql); 1434 1435 $redirect_url = append_sid("{$phpbb_root_path}view$mode.$phpEx", "$u_url=$match_id&start=$start"); 1436 $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)]; 1437 1438 if (!$request->is_ajax()) 1439 { 1440 $message .= '<br /><br />' . $user->lang('RETURN_' . strtoupper($mode), '<a href="' . $redirect_url . '">', '</a>'); 1441 } 1442 meta_refresh(3, $redirect_url); 1443 trigger_error($message); 1444 } 1445 else 1446 { 1447 $s_hidden_fields = array( 1448 'uid' => $user->data['user_id'], 1449 'watch' => $mode, 1450 'start' => $start, 1451 'f' => $forum_id, 1452 ); 1453 if ($mode != 'forum') 1454 { 1455 $s_hidden_fields['t'] = $topic_id; 1456 } 1457 1458 $confirm_box_message = (($item_title == '') ? 'WATCH_' . strtoupper($mode) : $user->lang('WATCH_' . strtoupper($mode) . '_DETAILED', $item_title)); 1459 confirm_box(false, $confirm_box_message, build_hidden_fields($s_hidden_fields)); 1460 } 1461 } 1462 else 1463 { 1464 $is_watching = 0; 1465 } 1466 } 1467 } 1468 else 1469 { 1470 if ((isset($_GET['unwatch']) && $request->variable('unwatch', '', false, \phpbb\request\request_interface::GET) == $mode) || 1471 (isset($_GET['watch']) && $request->variable('watch', '', false, \phpbb\request\request_interface::GET) == $mode)) 1472 { 1473 login_box(); 1474 } 1475 else 1476 { 1477 $can_watch = 0; 1478 $is_watching = 0; 1479 } 1480 } 1481 1482 if ($can_watch) 1483 { 1484 $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")); 1485 $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")); 1486 $s_watching['title'] = $user->lang[(($is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; 1487 $s_watching['title_toggle'] = $user->lang[((!$is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)]; 1488 $s_watching['is_watching'] = $is_watching; 1489 } 1490 1491 return; 1492 } 1493 1494 /** 1495 * Get user rank title and image 1496 * 1497 * @param array $user_data the current stored users data 1498 * @param int $user_posts the users number of posts 1499 * 1500 * @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) 1501 * 1502 * 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 1503 */ 1504 function phpbb_get_user_rank($user_data, $user_posts) 1505 { 1506 global $ranks, $config, $phpbb_root_path, $phpbb_path_helper, $phpbb_dispatcher; 1507 1508 $user_rank_data = array( 1509 'title' => null, 1510 'img' => null, 1511 'img_src' => null, 1512 ); 1513 1514 /** 1515 * Preparing a user's rank before displaying 1516 * 1517 * @event core.modify_user_rank 1518 * @var array user_data Array with user's data 1519 * @var int user_posts User_posts to change 1520 * @since 3.1.0-RC4 1521 */ 1522 1523 $vars = array('user_data', 'user_posts'); 1524 extract($phpbb_dispatcher->trigger_event('core.modify_user_rank', compact($vars))); 1525 1526 if (empty($ranks)) 1527 { 1528 global $cache; 1529 $ranks = $cache->obtain_ranks(); 1530 } 1531 1532 if (!empty($user_data['user_rank'])) 1533 { 1534 1535 $user_rank_data['title'] = (isset($ranks['special'][$user_data['user_rank']]['rank_title'])) ? $ranks['special'][$user_data['user_rank']]['rank_title'] : ''; 1536 1537 $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']) : ''; 1538 1539 $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'] . '" />' : ''; 1540 } 1541 else if ($user_posts !== false) 1542 { 1543 if (!empty($ranks['normal'])) 1544 { 1545 foreach ($ranks['normal'] as $rank) 1546 { 1547 if ($user_posts >= $rank['rank_min']) 1548 { 1549 $user_rank_data['title'] = $rank['rank_title']; 1550 $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']) : ''; 1551 $user_rank_data['img'] = (!empty($rank['rank_image'])) ? '<img src="' . $user_rank_data['img_src'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : ''; 1552 break; 1553 } 1554 } 1555 } 1556 } 1557 1558 /** 1559 * Modify a user's rank before displaying 1560 * 1561 * @event core.get_user_rank_after 1562 * @var array user_data Array with user's data 1563 * @var int user_posts User_posts to change 1564 * @var array user_rank_data User rank data 1565 * @since 3.1.11-RC1 1566 */ 1567 1568 $vars = array( 1569 'user_data', 1570 'user_posts', 1571 'user_rank_data', 1572 ); 1573 extract($phpbb_dispatcher->trigger_event('core.get_user_rank_after', compact($vars))); 1574 1575 return $user_rank_data; 1576 } 1577 1578 /** 1579 * Prepare profile data 1580 */ 1581 function phpbb_show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false, $check_can_receive_pm = true) 1582 { 1583 global $config, $auth, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher; 1584 1585 $username = $data['username']; 1586 $user_id = $data['user_id']; 1587 1588 $user_rank_data = phpbb_get_user_rank($data, (($user_id == ANONYMOUS) ? false : $data['user_posts'])); 1589 1590 if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user')) 1591 { 1592 $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']); 1593 } 1594 else 1595 { 1596 $email = ''; 1597 } 1598 1599 if ($config['load_onlinetrack']) 1600 { 1601 $update_time = $config['load_online_time'] * 60; 1602 $online = (time() - $update_time < $data['session_time'] && ((isset($data['session_viewonline']) && $data['session_viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false; 1603 } 1604 else 1605 { 1606 $online = false; 1607 } 1608 1609 if ($data['user_allow_viewonline'] || $auth->acl_get('u_viewonline')) 1610 { 1611 $last_active = (!empty($data['session_time'])) ? $data['session_time'] : $data['user_lastvisit']; 1612 } 1613 else 1614 { 1615 $last_active = ''; 1616 } 1617 1618 $age = ''; 1619 1620 if ($config['allow_birthdays'] && $data['user_birthday']) 1621 { 1622 list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $data['user_birthday'])); 1623 1624 if ($bday_year) 1625 { 1626 $now = $user->create_datetime(); 1627 $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset()); 1628 1629 $diff = $now['mon'] - $bday_month; 1630 if ($diff == 0) 1631 { 1632 $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0; 1633 } 1634 else 1635 { 1636 $diff = ($diff < 0) ? 1 : 0; 1637 } 1638 1639 $age = max(0, (int) ($now['year'] - $bday_year - $diff)); 1640 } 1641 } 1642 1643 if (!function_exists('phpbb_get_banned_user_ids')) 1644 { 1645 include($phpbb_root_path . 'includes/functions_user.' . $phpEx); 1646 } 1647 1648 // Can this user receive a Private Message? 1649 $can_receive_pm = $check_can_receive_pm && ( 1650 // They must be a "normal" user 1651 $data['user_type'] != USER_IGNORE && 1652 1653 // They must not be deactivated by the administrator 1654 ($data['user_type'] != USER_INACTIVE || $data['user_inactive_reason'] != INACTIVE_MANUAL) && 1655 1656 // They must be able to read PMs 1657 count($auth->acl_get_list($user_id, 'u_readpm')) && 1658 1659 // They must not be permanently banned 1660 !count(phpbb_get_banned_user_ids($user_id, false)) && 1661 1662 // They must allow users to contact via PM 1663 (($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) || $data['user_allow_pm']) 1664 ); 1665 1666 // Dump it out to the template 1667 $template_data = array( 1668 'AGE' => $age, 1669 'RANK_TITLE' => $user_rank_data['title'], 1670 'JOINED' => $user->format_date($data['user_regdate']), 1671 'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active), 1672 'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0, 1673 'WARNINGS' => isset($data['user_warnings']) ? $data['user_warnings'] : 0, 1674 1675 'USERNAME_FULL' => get_username_string('full', $user_id, $username, $data['user_colour']), 1676 'USERNAME' => get_username_string('username', $user_id, $username, $data['user_colour']), 1677 'USER_COLOR' => get_username_string('colour', $user_id, $username, $data['user_colour']), 1678 'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $data['user_colour']), 1679 1680 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), 1681 1682 'AVATAR_IMG' => phpbb_get_user_avatar($data), 1683 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 1684 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, 1685 'RANK_IMG' => $user_rank_data['img'], 1686 'RANK_IMG_SRC' => $user_rank_data['img_src'], 1687 'S_JABBER_ENABLED' => ($config['jab_enable']) ? true : false, 1688 1689 'S_WARNINGS' => ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn')) ? true : false, 1690 1691 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id=$user_id&sr=posts") : '', 1692 '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) : '', 1693 '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) : '', 1694 '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) : '', 1695 'U_EMAIL' => $email, 1696 'U_JABBER' => ($data['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&action=jabber&u=' . $user_id) : '', 1697 1698 'USER_JABBER' => ($config['jab_enable'] && $auth->acl_get('u_sendim')) ? $data['user_jabber'] : '', 1699 'USER_JABBER_IMG' => ($config['jab_enable'] && $auth->acl_get('u_sendim') && $data['user_jabber']) ? $user->img('icon_contact_jabber', $data['user_jabber']) : '', 1700 1701 'L_SEND_EMAIL_USER' => $user->lang('SEND_EMAIL_USER', $username), 1702 'L_CONTACT_USER' => $user->lang('CONTACT_USER', $username), 1703 'L_VIEWING_PROFILE' => $user->lang('VIEWING_PROFILE', $username), 1704 ); 1705 1706 /** 1707 * Preparing a user's data before displaying it in profile and memberlist 1708 * 1709 * @event core.memberlist_prepare_profile_data 1710 * @var array data Array with user's data 1711 * @var array template_data Template array with user's data 1712 * @since 3.1.0-a1 1713 */ 1714 $vars = array('data', 'template_data'); 1715 extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars))); 1716 1717 return $template_data; 1718 } 1719 1720 function phpbb_sort_last_active($first, $second) 1721 { 1722 global $id_cache, $sort_dir; 1723 1724 $lesser_than = ($sort_dir === 'd') ? -1 : 1; 1725 1726 if (isset($id_cache[$first]['group_leader']) && $id_cache[$first]['group_leader'] && (!isset($id_cache[$second]['group_leader']) || !$id_cache[$second]['group_leader'])) 1727 { 1728 return -1; 1729 } 1730 else if (isset($id_cache[$second]['group_leader']) && (!isset($id_cache[$first]['group_leader']) || !$id_cache[$first]['group_leader']) && $id_cache[$second]['group_leader']) 1731 { 1732 return 1; 1733 } 1734 else 1735 { 1736 return $lesser_than * (int) ($id_cache[$first]['last_visit'] - $id_cache[$second]['last_visit']); 1737 } 1738 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |