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