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