[ 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 * ucp_main 24 * UCP Front Panel 25 */ 26 class ucp_main 27 { 28 var $p_master; 29 var $u_action; 30 31 function ucp_main(&$p_master) 32 { 33 $this->p_master = &$p_master; 34 } 35 36 function main($id, $mode) 37 { 38 global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $phpbb_dispatcher; 39 global $request; 40 41 switch ($mode) 42 { 43 case 'front': 44 45 $user->add_lang('memberlist'); 46 47 $sql_from = TOPICS_TABLE . ' t '; 48 $sql_select = ''; 49 50 if ($config['load_db_track']) 51 { 52 $sql_from .= ' LEFT JOIN ' . TOPICS_POSTED_TABLE . ' tp ON (tp.topic_id = t.topic_id 53 AND tp.user_id = ' . $user->data['user_id'] . ')'; 54 $sql_select .= ', tp.topic_posted'; 55 } 56 57 if ($config['load_db_lastread']) 58 { 59 $sql_from .= ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id 60 AND tt.user_id = ' . $user->data['user_id'] . ')'; 61 $sql_select .= ', tt.mark_time'; 62 63 $sql_from .= ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.forum_id = t.forum_id 64 AND ft.user_id = ' . $user->data['user_id'] . ')'; 65 $sql_select .= ', ft.mark_time AS forum_mark_time'; 66 } 67 68 $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; 69 $folder = 'global_read'; 70 $folder_new = 'global_unread'; 71 72 // Get cleaned up list... return only those forums having the f_read permission 73 $forum_ary = $auth->acl_getf('f_read', true); 74 $forum_ary = array_unique(array_keys($forum_ary)); 75 $topic_list = $rowset = array(); 76 77 // If the user can't see any forums, he can't read any posts because fid of 0 is invalid 78 if (!empty($forum_ary)) 79 { 80 $sql = "SELECT t.* $sql_select 81 FROM $sql_from 82 WHERE t.topic_type = " . POST_GLOBAL . ' 83 AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . ' 84 ORDER BY t.topic_last_post_time DESC, t.topic_last_post_id DESC'; 85 $result = $db->sql_query($sql); 86 87 while ($row = $db->sql_fetchrow($result)) 88 { 89 $topic_list[] = $row['topic_id']; 90 $rowset[$row['topic_id']] = $row; 91 } 92 $db->sql_freeresult($result); 93 } 94 95 $topic_forum_list = array(); 96 foreach ($rowset as $t_id => $row) 97 { 98 if (isset($forum_tracking_info[$row['forum_id']])) 99 { 100 $row['forum_mark_time'] = $forum_tracking_info[$row['forum_id']]; 101 } 102 103 $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread'] && $user->data['is_registered'] && isset($row['forum_mark_time'])) ? $row['forum_mark_time'] : 0; 104 $topic_forum_list[$row['forum_id']]['topics'][] = (int) $t_id; 105 } 106 107 $topic_tracking_info = $tracking_topics = array(); 108 if ($config['load_db_lastread']) 109 { 110 foreach ($topic_forum_list as $f_id => $topic_row) 111 { 112 $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); 113 } 114 } 115 else 116 { 117 foreach ($topic_forum_list as $f_id => $topic_row) 118 { 119 $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); 120 } 121 } 122 unset($topic_forum_list); 123 124 foreach ($topic_list as $topic_id) 125 { 126 $row = &$rowset[$topic_id]; 127 128 $forum_id = $row['forum_id']; 129 $topic_id = $row['topic_id']; 130 131 $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; 132 133 $folder_img = ($unread_topic) ? $folder_new : $folder; 134 $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS'); 135 136 if ($row['topic_status'] == ITEM_LOCKED) 137 { 138 $folder_img .= '_locked'; 139 } 140 141 // Posted image? 142 if (!empty($row['topic_posted']) && $row['topic_posted']) 143 { 144 $folder_img .= '_mine'; 145 } 146 147 $template->assign_block_vars('topicrow', array( 148 'FORUM_ID' => $forum_id, 149 'TOPIC_ID' => $topic_id, 150 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 151 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 152 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 153 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 154 'LAST_POST_SUBJECT' => censor_text($row['topic_last_post_subject']), 155 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 156 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 157 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 158 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 159 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 160 'TOPIC_TITLE' => censor_text($row['topic_title']), 161 'TOPIC_TYPE' => $topic_type, 162 163 'TOPIC_IMG_STYLE' => $folder_img, 164 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 165 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', '') : '', 166 167 'S_USER_POSTED' => (!empty($row['topic_posted']) && $row['topic_posted']) ? true : false, 168 'S_UNREAD' => $unread_topic, 169 170 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 171 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=" . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 172 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 173 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', 174 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id")) 175 ); 176 } 177 178 if ($config['load_user_activity']) 179 { 180 if (!function_exists('display_user_activity')) 181 { 182 include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); 183 } 184 display_user_activity($user->data); 185 } 186 187 // Do the relevant calculations 188 $memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400)); 189 $posts_per_day = $user->data['user_posts'] / $memberdays; 190 $percentage = ($config['num_posts']) ? min(100, ($user->data['user_posts'] / $config['num_posts']) * 100) : 0; 191 192 $template->assign_vars(array( 193 'USER_COLOR' => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '', 194 'JOINED' => $user->format_date($user->data['user_regdate']), 195 'LAST_ACTIVE' => (empty($last_active)) ? ' - ' : $user->format_date($last_active), 196 'WARNINGS' => ($user->data['user_warnings']) ? $user->data['user_warnings'] : 0, 197 'POSTS' => ($user->data['user_posts']) ? $user->data['user_posts'] : 0, 198 'POSTS_DAY' => $user->lang('POST_DAY', $posts_per_day), 199 'POSTS_PCT' => $user->lang('POST_PCT', $percentage), 200 201 // 'S_GROUP_OPTIONS' => $group_options, 202 203 'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $user->data['user_id'] . '&sr=posts') : '', 204 )); 205 206 break; 207 208 case 'subscribed': 209 210 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 211 212 $user->add_lang('viewforum'); 213 214 add_form_key('ucp_front_subscribed'); 215 216 $unwatch = (isset($_POST['unwatch'])) ? true : false; 217 218 /** 219 * Read and potentially modify the post data used to remove subscriptions to forums/topics 220 * 221 * @event core.ucp_main_subscribed_post_data 222 * @since 3.1.10-RC1 223 */ 224 $phpbb_dispatcher->dispatch('core.ucp_main_subscribed_post_data'); 225 226 if ($unwatch) 227 { 228 if (check_form_key('ucp_front_subscribed')) 229 { 230 $forums = array_keys(request_var('f', array(0 => 0))); 231 $topics = array_keys(request_var('t', array(0 => 0))); 232 $msg = ''; 233 234 if (sizeof($forums) || sizeof($topics)) 235 { 236 $l_unwatch = ''; 237 if (sizeof($forums)) 238 { 239 $sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . ' 240 WHERE ' . $db->sql_in_set('forum_id', $forums) . ' 241 AND user_id = ' . $user->data['user_id']; 242 $db->sql_query($sql); 243 244 $l_unwatch .= '_FORUMS'; 245 } 246 247 if (sizeof($topics)) 248 { 249 $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' 250 WHERE ' . $db->sql_in_set('topic_id', $topics) . ' 251 AND user_id = ' . $user->data['user_id']; 252 $db->sql_query($sql); 253 254 $l_unwatch .= '_TOPICS'; 255 } 256 $msg = $user->lang['UNWATCHED' . $l_unwatch]; 257 } 258 else 259 { 260 $msg = $user->lang['NO_WATCHED_SELECTED']; 261 } 262 } 263 else 264 { 265 $msg = $user->lang['FORM_INVALID']; 266 } 267 $message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=subscribed") . '">', '</a>'); 268 meta_refresh(3, append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=subscribed")); 269 trigger_error($message); 270 } 271 272 $forbidden_forums = array(); 273 274 if ($config['allow_forum_notify']) 275 { 276 $forbidden_forums = $auth->acl_getf('!f_read', true); 277 $forbidden_forums = array_unique(array_keys($forbidden_forums)); 278 279 $sql_array = array( 280 'SELECT' => 'f.*', 281 282 'FROM' => array( 283 FORUMS_WATCH_TABLE => 'fw', 284 FORUMS_TABLE => 'f' 285 ), 286 287 'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . ' 288 AND f.forum_id = fw.forum_id 289 AND ' . $db->sql_in_set('f.forum_id', $forbidden_forums, true, true), 290 291 'ORDER_BY' => 'left_id' 292 ); 293 294 if ($config['load_db_lastread']) 295 { 296 $sql_array['LEFT_JOIN'] = array( 297 array( 298 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 299 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id' 300 ) 301 ); 302 303 $sql_array['SELECT'] .= ', ft.mark_time '; 304 } 305 else 306 { 307 $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); 308 $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); 309 } 310 311 /** 312 * Modify the query used to retrieve a list of subscribed forums 313 * 314 * @event core.ucp_main_subscribed_forums_modify_query 315 * @var array sql_array The subscribed forums query 316 * @var array forbidden_forums The list of forbidden forums 317 * @since 3.1.10-RC1 318 */ 319 $vars = array( 320 'sql_array', 321 'forbidden_forums', 322 ); 323 extract($phpbb_dispatcher->trigger_event('core.ucp_main_subscribed_forums_modify_query', compact($vars))); 324 325 $sql = $db->sql_build_query('SELECT', $sql_array); 326 $result = $db->sql_query($sql); 327 328 while ($row = $db->sql_fetchrow($result)) 329 { 330 $forum_id = $row['forum_id']; 331 332 if ($config['load_db_lastread']) 333 { 334 $forum_check = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark']; 335 } 336 else 337 { 338 $forum_check = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; 339 } 340 341 $unread_forum = ($row['forum_last_post_time'] > $forum_check) ? true : false; 342 343 // Which folder should we display? 344 if ($row['forum_status'] == ITEM_LOCKED) 345 { 346 $folder_image = ($unread_forum) ? 'forum_unread_locked' : 'forum_read_locked'; 347 $folder_alt = 'FORUM_LOCKED'; 348 } 349 else 350 { 351 $folder_image = ($unread_forum) ? 'forum_unread' : 'forum_read'; 352 $folder_alt = ($unread_forum) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS'; 353 } 354 355 // Create last post link information, if appropriate 356 if ($row['forum_last_post_id']) 357 { 358 $last_post_time = $user->format_date($row['forum_last_post_time']); 359 $last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&p=" . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id']; 360 } 361 else 362 { 363 $last_post_time = $last_post_url = ''; 364 } 365 366 $template_vars = array( 367 'FORUM_ID' => $forum_id, 368 'FORUM_IMG_STYLE' => $folder_image, 369 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 370 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '', 371 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', 372 'FORUM_NAME' => $row['forum_name'], 373 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 374 'LAST_POST_SUBJECT' => $row['forum_last_post_subject'], 375 'LAST_POST_TIME' => $last_post_time, 376 377 'LAST_POST_AUTHOR' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 378 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 379 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 380 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 381 382 'S_UNREAD_FORUM' => $unread_forum, 383 384 'U_LAST_POST' => $last_post_url, 385 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) 386 ); 387 388 /** 389 * Add template variables to a subscribed forum row. 390 * 391 * @event core.ucp_main_subscribed_forum_modify_template_vars 392 * @var array template_vars Array containing the template variables for the row 393 * @var array row Array containing the subscribed forum row data 394 * @var int forum_id Forum ID 395 * @var string folder_image Folder image 396 * @var string folder_alt Alt text for the folder image 397 * @var bool unread_forum Whether the forum has unread content or not 398 * @var string last_post_time The time of the most recent post, expressed as a formatted date string 399 * @var string last_post_url The URL of the most recent post in the forum 400 * @since 3.1.10-RC1 401 */ 402 $vars = array( 403 'template_vars', 404 'row', 405 'forum_id', 406 'folder_image', 407 'folder_alt', 408 'unread_forum', 409 'last_post_time', 410 'last_post_url', 411 ); 412 extract($phpbb_dispatcher->trigger_event('core.ucp_main_subscribed_forum_modify_template_vars', compact($vars))); 413 414 $template->assign_block_vars('forumrow', $template_vars); 415 } 416 $db->sql_freeresult($result); 417 } 418 419 // Subscribed Topics 420 if ($config['allow_topic_notify']) 421 { 422 if (empty($forbidden_forums)) 423 { 424 $forbidden_forums = $auth->acl_getf('!f_read', true); 425 $forbidden_forums = array_unique(array_keys($forbidden_forums)); 426 } 427 $this->assign_topiclist('subscribed', $forbidden_forums); 428 } 429 430 $template->assign_vars(array( 431 'S_TOPIC_NOTIFY' => $config['allow_topic_notify'], 432 'S_FORUM_NOTIFY' => $config['allow_forum_notify'], 433 )); 434 435 break; 436 437 case 'bookmarks': 438 439 if (!$config['allow_bookmarks']) 440 { 441 $template->assign_vars(array( 442 'S_NO_DISPLAY_BOOKMARKS' => true) 443 ); 444 break; 445 } 446 447 include($phpbb_root_path . 'includes/functions_display.' . $phpEx); 448 449 $user->add_lang('viewforum'); 450 451 if (isset($_POST['unbookmark'])) 452 { 453 $s_hidden_fields = array('unbookmark' => 1); 454 $topics = (isset($_POST['t'])) ? array_keys(request_var('t', array(0 => 0))) : array(); 455 $url = $this->u_action; 456 457 if (!sizeof($topics)) 458 { 459 trigger_error('NO_BOOKMARKS_SELECTED'); 460 } 461 462 foreach ($topics as $topic_id) 463 { 464 $s_hidden_fields['t'][$topic_id] = 1; 465 } 466 467 if (confirm_box(true)) 468 { 469 $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . ' 470 WHERE user_id = ' . $user->data['user_id'] . ' 471 AND ' . $db->sql_in_set('topic_id', $topics); 472 $db->sql_query($sql); 473 474 meta_refresh(3, $url); 475 $message = $user->lang['BOOKMARKS_REMOVED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>'); 476 trigger_error($message); 477 } 478 else 479 { 480 confirm_box(false, 'REMOVE_SELECTED_BOOKMARKS', build_hidden_fields($s_hidden_fields)); 481 } 482 } 483 $forbidden_forums = $auth->acl_getf('!f_read', true); 484 $forbidden_forums = array_unique(array_keys($forbidden_forums)); 485 486 $this->assign_topiclist('bookmarks', $forbidden_forums); 487 488 break; 489 490 case 'drafts': 491 492 $pm_drafts = ($this->p_master->p_name == 'pm') ? true : false; 493 $template->assign_var('S_SHOW_DRAFTS', true); 494 495 $user->add_lang('posting'); 496 497 $edit = (isset($_REQUEST['edit'])) ? true : false; 498 $submit = (isset($_POST['submit'])) ? true : false; 499 $draft_id = $request->variable('edit', 0); 500 $delete = (isset($_POST['delete'])) ? true : false; 501 502 $s_hidden_fields = ($edit) ? '<input type="hidden" name="edit" value="' . $draft_id . '" />' : ''; 503 $draft_subject = $draft_message = ''; 504 add_form_key('ucp_draft'); 505 506 if ($delete) 507 { 508 if (check_form_key('ucp_draft')) 509 { 510 $drafts = array_keys(request_var('d', array(0 => 0))); 511 512 if (sizeof($drafts)) 513 { 514 $sql = 'DELETE FROM ' . DRAFTS_TABLE . ' 515 WHERE ' . $db->sql_in_set('draft_id', $drafts) . ' 516 AND user_id = ' . $user->data['user_id']; 517 $db->sql_query($sql); 518 } 519 $msg = $user->lang['DRAFTS_DELETED']; 520 unset($drafts); 521 } 522 else 523 { 524 $msg = $user->lang['FORM_INVALID']; 525 } 526 $message = $msg . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 527 meta_refresh(3, $this->u_action); 528 trigger_error($message); 529 } 530 531 if ($submit && $edit) 532 { 533 $draft_subject = utf8_normalize_nfc(request_var('subject', '', true)); 534 $draft_message = utf8_normalize_nfc(request_var('message', '', true)); 535 if (check_form_key('ucp_draft')) 536 { 537 if ($draft_message && $draft_subject) 538 { 539 $draft_row = array( 540 'draft_subject' => $draft_subject, 541 'draft_message' => $draft_message 542 ); 543 544 $sql = 'UPDATE ' . DRAFTS_TABLE . ' 545 SET ' . $db->sql_build_array('UPDATE', $draft_row) . " 546 WHERE draft_id = $draft_id 547 AND user_id = " . $user->data['user_id']; 548 $db->sql_query($sql); 549 550 $message = $user->lang['DRAFT_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); 551 552 meta_refresh(3, $this->u_action); 553 trigger_error($message); 554 } 555 else 556 { 557 $template->assign_var('ERROR', ($draft_message == '') ? $user->lang['EMPTY_DRAFT'] : (($draft_subject == '') ? $user->lang['EMPTY_DRAFT_TITLE'] : '')); 558 } 559 } 560 else 561 { 562 $template->assign_var('ERROR', $user->lang['FORM_INVALID']); 563 } 564 } 565 566 if (!$pm_drafts) 567 { 568 $sql = 'SELECT d.*, f.forum_name 569 FROM ' . DRAFTS_TABLE . ' d, ' . FORUMS_TABLE . ' f 570 WHERE d.user_id = ' . $user->data['user_id'] . ' ' . 571 (($edit) ? "AND d.draft_id = $draft_id" : '') . ' 572 AND f.forum_id = d.forum_id 573 ORDER BY d.save_time DESC'; 574 } 575 else 576 { 577 $sql = 'SELECT * FROM ' . DRAFTS_TABLE . ' 578 WHERE user_id = ' . $user->data['user_id'] . ' ' . 579 (($edit) ? "AND draft_id = $draft_id" : '') . ' 580 AND forum_id = 0 581 AND topic_id = 0 582 ORDER BY save_time DESC'; 583 } 584 $result = $db->sql_query($sql); 585 586 $draftrows = $topic_ids = array(); 587 588 while ($row = $db->sql_fetchrow($result)) 589 { 590 if ($row['topic_id']) 591 { 592 $topic_ids[] = (int) $row['topic_id']; 593 } 594 $draftrows[] = $row; 595 } 596 $db->sql_freeresult($result); 597 598 if (sizeof($topic_ids)) 599 { 600 $sql = 'SELECT topic_id, forum_id, topic_title 601 FROM ' . TOPICS_TABLE . ' 602 WHERE ' . $db->sql_in_set('topic_id', array_unique($topic_ids)); 603 $result = $db->sql_query($sql); 604 605 while ($row = $db->sql_fetchrow($result)) 606 { 607 $topic_rows[$row['topic_id']] = $row; 608 } 609 $db->sql_freeresult($result); 610 } 611 unset($topic_ids); 612 613 $template->assign_var('S_EDIT_DRAFT', $edit); 614 615 $row_count = 0; 616 foreach ($draftrows as $draft) 617 { 618 $link_topic = $link_forum = $link_pm = false; 619 $insert_url = $view_url = $title = ''; 620 621 if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id'])) 622 { 623 $link_topic = true; 624 $view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id']); 625 $title = $topic_rows[$draft['topic_id']]['topic_title']; 626 627 $insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']); 628 } 629 else if ($auth->acl_get('f_read', $draft['forum_id'])) 630 { 631 $link_forum = true; 632 $view_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $draft['forum_id']); 633 $title = $draft['forum_name']; 634 635 $insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']); 636 } 637 else if ($pm_drafts) 638 { 639 $link_pm = true; 640 $insert_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=compose&d=" . $draft['draft_id']); 641 } 642 643 $template_row = array( 644 'DATE' => $user->format_date($draft['save_time']), 645 'DRAFT_MESSAGE' => ($submit) ? $draft_message : $draft['draft_message'], 646 'DRAFT_SUBJECT' => ($submit) ? $draft_subject : $draft['draft_subject'], 647 'TITLE' => $title, 648 649 'DRAFT_ID' => $draft['draft_id'], 650 'FORUM_ID' => $draft['forum_id'], 651 'TOPIC_ID' => $draft['topic_id'], 652 653 'U_VIEW' => $view_url, 654 'U_VIEW_EDIT' => $this->u_action . '&edit=' . $draft['draft_id'], 655 'U_INSERT' => $insert_url, 656 657 'S_LINK_TOPIC' => $link_topic, 658 'S_LINK_FORUM' => $link_forum, 659 'S_LINK_PM' => $link_pm, 660 'S_HIDDEN_FIELDS' => $s_hidden_fields 661 ); 662 $row_count++; 663 664 ($edit) ? $template->assign_vars($template_row) : $template->assign_block_vars('draftrow', $template_row); 665 } 666 667 if (!$edit) 668 { 669 $template->assign_var('S_DRAFT_ROWS', $row_count); 670 } 671 672 break; 673 } 674 675 $template->assign_vars(array( 676 'L_TITLE' => $user->lang['UCP_MAIN_' . strtoupper($mode)], 677 678 'S_DISPLAY_MARK_ALL' => ($mode == 'watched' || ($mode == 'drafts' && !isset($_GET['edit']))) ? true : false, 679 'S_HIDDEN_FIELDS' => (isset($s_hidden_fields)) ? $s_hidden_fields : '', 680 'S_UCP_ACTION' => $this->u_action, 681 682 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 683 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 684 )); 685 686 // Set desired template 687 $this->tpl_name = 'ucp_main_' . $mode; 688 $this->page_title = 'UCP_MAIN_' . strtoupper($mode); 689 } 690 691 /** 692 * Build and assign topiclist for bookmarks/subscribed topics 693 */ 694 function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array()) 695 { 696 global $user, $db, $template, $config, $cache, $auth, $phpbb_root_path, $phpEx, $phpbb_container, $request, $phpbb_dispatcher; 697 698 $table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE; 699 $start = request_var('start', 0); 700 $pagination = $phpbb_container->get('pagination'); 701 702 // Grab icons 703 $icons = $cache->obtain_icons(); 704 705 $sql_array = array( 706 'SELECT' => 'COUNT(t.topic_id) as topics_count', 707 708 'FROM' => array( 709 $table => 'i', 710 TOPICS_TABLE => 't' 711 ), 712 713 'WHERE' => 'i.topic_id = t.topic_id 714 AND i.user_id = ' . $user->data['user_id'] . ' 715 AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), 716 ); 717 718 /** 719 * Modify the query used to retrieve the count of subscribed/bookmarked topics 720 * 721 * @event core.ucp_main_topiclist_count_modify_query 722 * @var array sql_array The subscribed/bookmarked topics query 723 * @var array forbidden_forum_ary The list of forbidden forums 724 * @var string mode The type of topic list ('subscribed' or 'bookmarks') 725 * @since 3.1.10-RC1 726 */ 727 $vars = array( 728 'sql_array', 729 'forbidden_forum_ary', 730 'mode', 731 ); 732 extract($phpbb_dispatcher->trigger_event('core.ucp_main_topiclist_count_modify_query', compact($vars))); 733 734 $sql = $db->sql_build_query('SELECT', $sql_array); 735 $result = $db->sql_query($sql); 736 $topics_count = (int) $db->sql_fetchfield('topics_count'); 737 $db->sql_freeresult($result); 738 739 if ($topics_count) 740 { 741 $start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count); 742 $pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start); 743 744 $template->assign_vars(array( 745 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $topics_count), 746 )); 747 } 748 749 if ($mode == 'subscribed') 750 { 751 $sql_array = array( 752 'SELECT' => 't.*, f.forum_name', 753 754 'FROM' => array( 755 TOPICS_WATCH_TABLE => 'tw', 756 TOPICS_TABLE => 't' 757 ), 758 759 'WHERE' => 'tw.user_id = ' . $user->data['user_id'] . ' 760 AND t.topic_id = tw.topic_id 761 AND ' . $db->sql_in_set('t.forum_id', $forbidden_forum_ary, true, true), 762 763 'ORDER_BY' => 't.topic_last_post_time DESC, t.topic_last_post_id DESC' 764 ); 765 766 $sql_array['LEFT_JOIN'] = array(); 767 } 768 else 769 { 770 $sql_array = array( 771 'SELECT' => 't.*, f.forum_name, b.topic_id as b_topic_id', 772 773 'FROM' => array( 774 BOOKMARKS_TABLE => 'b', 775 ), 776 777 'WHERE' => 'b.user_id = ' . $user->data['user_id'] . ' 778 AND ' . $db->sql_in_set('f.forum_id', $forbidden_forum_ary, true, true), 779 780 'ORDER_BY' => 't.topic_last_post_time DESC, t.topic_last_post_id DESC' 781 ); 782 783 $sql_array['LEFT_JOIN'] = array(); 784 $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'b.topic_id = t.topic_id'); 785 } 786 787 $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 't.forum_id = f.forum_id'); 788 789 if ($config['load_db_lastread']) 790 { 791 $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = t.forum_id AND ft.user_id = ' . $user->data['user_id']); 792 $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id']); 793 $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time AS forum_mark_time'; 794 } 795 796 if ($config['load_db_track']) 797 { 798 $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_POSTED_TABLE => 'tp'), 'ON' => 'tp.topic_id = t.topic_id AND tp.user_id = ' . $user->data['user_id']); 799 $sql_array['SELECT'] .= ', tp.topic_posted'; 800 } 801 802 /** 803 * Modify the query used to retrieve the list of subscribed/bookmarked topics 804 * 805 * @event core.ucp_main_topiclist_modify_query 806 * @var array sql_array The subscribed/bookmarked topics query 807 * @var array forbidden_forum_ary The list of forbidden forums 808 * @var string mode The type of topic list ('subscribed' or 'bookmarks') 809 * @since 3.1.10-RC1 810 */ 811 $vars = array( 812 'sql_array', 813 'forbidden_forum_ary', 814 'mode', 815 ); 816 extract($phpbb_dispatcher->trigger_event('core.ucp_main_topiclist_modify_query', compact($vars))); 817 818 $sql = $db->sql_build_query('SELECT', $sql_array); 819 $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); 820 821 $topic_list = $topic_forum_list = $global_announce_list = $rowset = array(); 822 while ($row = $db->sql_fetchrow($result)) 823 { 824 $topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id']; 825 826 $topic_list[] = $topic_id; 827 $rowset[$topic_id] = $row; 828 829 $topic_forum_list[$row['forum_id']]['forum_mark_time'] = ($config['load_db_lastread']) ? $row['forum_mark_time'] : 0; 830 $topic_forum_list[$row['forum_id']]['topics'][] = $topic_id; 831 832 if ($row['topic_type'] == POST_GLOBAL) 833 { 834 $global_announce_list[] = $topic_id; 835 } 836 } 837 $db->sql_freeresult($result); 838 839 $topic_tracking_info = array(); 840 if ($config['load_db_lastread']) 841 { 842 foreach ($topic_forum_list as $f_id => $topic_row) 843 { 844 $topic_tracking_info += get_topic_tracking($f_id, $topic_row['topics'], $rowset, array($f_id => $topic_row['forum_mark_time'])); 845 } 846 } 847 else 848 { 849 foreach ($topic_forum_list as $f_id => $topic_row) 850 { 851 $topic_tracking_info += get_complete_topic_tracking($f_id, $topic_row['topics']); 852 } 853 } 854 855 $phpbb_content_visibility = $phpbb_container->get('content.visibility'); 856 857 foreach ($topic_list as $topic_id) 858 { 859 $row = &$rowset[$topic_id]; 860 861 $forum_id = $row['forum_id']; 862 $topic_id = (isset($row['b_topic_id'])) ? $row['b_topic_id'] : $row['topic_id']; 863 864 $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; 865 866 // Replies 867 $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; 868 869 if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id'])) 870 { 871 $topic_id = $row['topic_moved_id']; 872 } 873 874 // Get folder img, topic status/type related information 875 $folder_img = $folder_alt = $topic_type = ''; 876 topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); 877 878 $view_topic_url_params = "f=$forum_id&t=$topic_id"; 879 $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); 880 881 // Send vars to template 882 $template_vars = array( 883 'FORUM_ID' => $forum_id, 884 'TOPIC_ID' => $topic_id, 885 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 886 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], 887 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 888 'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']), 889 890 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 891 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 892 'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 893 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 894 895 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 896 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 897 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 898 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 899 900 'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false, 901 902 'REPLIES' => $replies, 903 'VIEWS' => $row['topic_views'], 904 'TOPIC_TITLE' => censor_text($row['topic_title']), 905 'TOPIC_TYPE' => $topic_type, 906 'FORUM_NAME' => $row['forum_name'], 907 908 'TOPIC_IMG_STYLE' => $folder_img, 909 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 910 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 911 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 912 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', 913 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', 914 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 915 916 'S_TOPIC_TYPE' => $row['topic_type'], 917 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, 918 'S_UNREAD_TOPIC' => $unread_topic, 919 920 'U_NEWEST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&view=unread') . '#unread', 921 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 922 'U_VIEW_TOPIC' => $view_topic_url, 923 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), 924 ); 925 926 /** 927 * Add template variables to a subscribed/bookmarked topic row. 928 * 929 * @event core.ucp_main_topiclist_topic_modify_template_vars 930 * @var array template_vars Array containing the template variables for the row 931 * @var array row Array containing the subscribed/bookmarked topic row data 932 * @var int forum_id ID of the forum containing the topic 933 * @var int topic_id Topic ID 934 * @var int replies Number of replies in the topic 935 * @var string topic_type Topic type 936 * @var string folder_img Folder image 937 * @var string folder_alt Alt text for the folder image 938 * @var array icons Array containing topic icons 939 * @var bool unread_topic Whether the topic has unread content or not 940 * @var string view_topic_url The URL of the topic 941 * @since 3.1.10-RC1 942 */ 943 $vars = array( 944 'template_vars', 945 'row', 946 'forum_id', 947 'topic_id', 948 'replies', 949 'topic_type', 950 'folder_img', 951 'folder_alt', 952 'icons', 953 'unread_topic', 954 'view_topic_url', 955 ); 956 extract($phpbb_dispatcher->trigger_event('core.ucp_main_topiclist_topic_modify_template_vars', compact($vars))); 957 958 $template->assign_block_vars('topicrow', $template_vars); 959 960 $pagination->generate_template_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&t=$topic_id"), 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); 961 } 962 } 963 }
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 |