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