diff options
| author | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:35 +0100 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2010-03-02 01:05:35 +0100 |
| commit | bae824e818fb30260385ed63e6fbea2779a3d19a (patch) | |
| tree | e5830d6c6ff9eb5ca7903759d4d654289adaeccf /phpBB/viewtopic.php | |
| parent | 517f25353246f06eec7d1fdef90a04119a45bbbf (diff) | |
| parent | 19c923cf1bb21bf5fa13b18c0f481c0cf05216e7 (diff) | |
| download | forums-bae824e818fb30260385ed63e6fbea2779a3d19a.tar forums-bae824e818fb30260385ed63e6fbea2779a3d19a.tar.gz forums-bae824e818fb30260385ed63e6fbea2779a3d19a.tar.bz2 forums-bae824e818fb30260385ed63e6fbea2779a3d19a.tar.xz forums-bae824e818fb30260385ed63e6fbea2779a3d19a.zip | |
Merge commit 'release-3.0-RC1'
Diffstat (limited to 'phpBB/viewtopic.php')
| -rw-r--r-- | phpBB/viewtopic.php | 118 |
1 files changed, 57 insertions, 61 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4ef45eddc0..98d852737e 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -111,6 +111,7 @@ if ($view && !$post_id) LEFT JOIN ' . TOPICS_TABLE . " t2 ON (t2.topic_id = $topic_id AND t.forum_id = t2.forum_id) WHERE t.topic_last_post_time $sql_condition t2.topic_last_post_time " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " + AND t.topic_moved_id = 0 ORDER BY t.topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -171,7 +172,7 @@ if ($user->data['is_registered']) if ($config['allow_bookmarks']) { - $sql_array['SELECT'] .= ', bm.order_id as bookmarked'; + $sql_array['SELECT'] .= ', bm.topic_id as bookmarked'; $sql_array['LEFT_JOIN'][] = array( 'FROM' => array(BOOKMARKS_TABLE => 'bm'), 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id' @@ -250,11 +251,11 @@ if ($post_id) if ($sort_dir == $check_sort) { - $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] + 1 : $topic_data['topic_replies'] + 1; + $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies']; } else { - $topic_data['prev_posts'] = 1; + $topic_data['prev_posts'] = 0; } } else @@ -270,7 +271,7 @@ if ($post_id) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $topic_data['prev_posts'] = $row['prev_posts']; + $topic_data['prev_posts'] = $row['prev_posts'] - 1; } } @@ -340,7 +341,7 @@ if (isset($_GET['e'])) // What is start equal to? if ($post_id) { - $start = floor(($topic_data['prev_posts'] - 1) / $config['posts_per_page']) * $config['posts_per_page']; + $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page']; } // Get topic tracking info @@ -406,7 +407,9 @@ if ($hilit_words) { if (trim($word)) { - $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*?', preg_quote($word, '#')); + $word = str_replace('\*', '\w+?', preg_quote($word, '#')); + $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word); + $highlight_match .= (($highlight_match != '') ? '|' : '') . $word; } } @@ -438,12 +441,8 @@ if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('b $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array( 'user_id' => $user->data['user_id'], 'topic_id' => $topic_id, - 'order_id' => 0) - ); + )); $db->sql_query($sql); - - $where_sql = ''; - $sign = '+'; } else { @@ -451,19 +450,8 @@ if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('b WHERE user_id = {$user->data['user_id']} AND topic_id = $topic_id"; $db->sql_query($sql); - - // Works because of current order_id selected as bookmark value (please do not change because of simplicity) - $where_sql = " AND order_id > {$topic_data['bookmarked']}"; - $sign = '-'; } - // Re-Sort Bookmarks - $sql = 'UPDATE ' . BOOKMARKS_TABLE . " - SET order_id = order_id $sign 1 - WHERE user_id = {$user->data['user_id']} - $where_sql"; - $db->sql_query($sql); - meta_refresh(3, $viewtopic_url); $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>'); @@ -495,7 +483,8 @@ $topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lo $topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : ''; $topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : ''; $topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : ''; -$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_TOPIC'] . '</option>' : ''; +$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : ''; +$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : ''; $topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : ''; $topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : ''; $topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : ''; @@ -529,6 +518,12 @@ $template->assign_vars(array( 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']), 'TOPIC_ID' => $topic_id, 'TOPIC_TITLE' => $topic_data['topic_title'], + 'TOPIC_POSTER' => $topic_data['topic_poster'], + + 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), + 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), + 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), + 'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts), @@ -556,6 +551,7 @@ $template->assign_vars(array( 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), + 'S_IS_LOCKED' =>($topic_data['topic_status'] == ITEM_UNLOCKED) ? false : true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, @@ -564,7 +560,7 @@ $template->assign_vars(array( 'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action">' . $topic_mod . '</select>' : '', 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "t=$topic_id&f=$forum_id&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id), - 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('f_search', $forum_id)) ? true : false, + 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 't=' . $topic_id), 'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&t=$topic_id", @@ -991,7 +987,8 @@ while ($row = $db->sql_fetchrow($result)) { $user_sig = ''; - if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) + // We add the signature to every posters entry because enable_sig is post dependant + if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs')) { $user_sig = $row['user_sig']; } @@ -1011,7 +1008,7 @@ while ($row = $db->sql_fetchrow($result)) 'viewonline' => $row['user_allow_viewonline'], 'allow_pm' => $row['user_allow_pm'], - 'avatar' => '', + 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', 'age' => '', 'rank_title' => '', @@ -1024,32 +1021,13 @@ while ($row = $db->sql_fetchrow($result)) 'online' => false, 'profile' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=viewprofile&u=$poster_id"), 'www' => $row['user_website'], - 'aim' => ($row['user_aim']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=aim&u=$poster_id") : '', - 'msn' => ($row['user_msnm']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', + 'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=aim&u=$poster_id") : '', + 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=msnm&u=$poster_id") : '', 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg' : '', - 'jabber' => ($row['user_jabber']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', + 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=contact&action=jabber&u=$poster_id") : '', 'search' => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", 'search_author=' . urlencode($row['username']) .'&showresults=posts') : '', ); - if ($row['user_avatar'] && $user->optionget('viewavatars')) - { - $avatar_img = ''; - - switch ($row['user_avatar_type']) - { - case AVATAR_UPLOAD: - $avatar_img = $config['avatar_path'] . '/'; - break; - - case AVATAR_GALLERY: - $avatar_img = $config['avatar_gallery_path'] . '/'; - break; - } - - $avatar_img .= $row['user_avatar']; - $user_cache[$poster_id]['avatar'] = '<img src="' . $avatar_img . '" width="' . $row['user_avatar_width'] . '" height="' . $row['user_avatar_height'] . '" alt="" />'; - } - get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']); if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email')) @@ -1214,11 +1192,18 @@ $template->assign_vars(array( $first_unread = $post_unread = false; for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) { + // A non-existing rowset only happens if there was no user present for the entered poster_id + // This could be a broken posts table. + if (!isset($rowset[$post_list[$i]])) + { + continue; + } + $row =& $rowset[$post_list[$i]]; $poster_id = $row['user_id']; // End signature parsing, only if needed - if ($user_cache[$poster_id]['sig'] && empty($user_cache[$poster_id]['sig_parsed'])) + if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed'])) { $user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']); $user_cache[$poster_id]['sig'] = str_replace("\n", '<br />', $user_cache[$poster_id]['sig']); @@ -1330,8 +1315,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) ) { // It is safe to grab the username from the user cache array, we are at the last - // post and only the topic poster and last poster are allowed to bump. However, a - // check is still needed incase an admin bumped the topic (but didn't post in the topic) + // post and only the topic poster and last poster are allowed to bump. + // Admins and mods are bound to the above rules too... $l_bumped_by = '<br /><br />' . sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time'])); } else @@ -1381,9 +1366,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'BUMPED_MESSAGE' => $l_bumped_by, 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), - 'POST_ICON_IMG' => (!empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', - 'POST_ICON_IMG_WIDTH' => (!empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', - 'POST_ICON_IMG_HEIGHT' => (!empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', + 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', + 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', + 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', 'ICQ_STATUS_IMG' => $user_cache[$poster_id]['icq_status_img'], 'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false), @@ -1411,9 +1396,10 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '', 'U_PREV_POST_ID' => $prev_post_id, 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $poster_id, true, $user->session_id) : '', - 'U_WARN' => ($auth->acl_getf_global('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', + 'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'POST_ID' => $row['post_id'], + 'POSTER_ID' => $poster_id, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true, @@ -1423,6 +1409,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_UNREAD_POST' => $post_unread, 'S_FIRST_UNREAD' => $s_first_unread, 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false, + 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false, 'S_IGNORE_POST' => ($row['hide_post']) ? true : false, 'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&p={$row['post_id']}&view=show#p{$row['post_id']}" . '">', '</a>') : '', @@ -1480,8 +1467,8 @@ if (isset($user->data['session_page']) && strpos($user->data['session_page'], '& } } -// Only mark topic if it's currently unread -if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id]) +// Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed. +if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id]) { markread('topic', $forum_id, $topic_id, $max_post_time); @@ -1494,11 +1481,20 @@ else } // If there are absolutely no more unread posts in this forum and unread posts shown, we can savely show the #unread link -if ($all_marked_read && $post_unread) +if ($all_marked_read) { - $template->assign_vars(array( - 'U_VIEW_UNREAD_POST' => '#unread', - )); + if ($post_unread) + { + $template->assign_vars(array( + 'U_VIEW_UNREAD_POST' => '#unread', + )); + } + else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id]) + { + $template->assign_vars(array( + 'U_VIEW_UNREAD_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&view=unread") . '#unread', + )); + } } else if (!$all_marked_read) { |
