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