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