## ## Mod title: Show user posts and topics ## ## Mod version: 1.0.2 ## Works on PunBB: 1.2.* ## Release date: 2009-08-19 ## Author: Koos (pampoen10@yahoo.com) ## ## Description: Adds 'Show all topics' link next to the 'Show all posts' ## link in the user profile. The 'Show all topics' link will ## now only show the topics which the user has started ## (instead of the topics in which the user has participated in), ## and the 'Show all posts' link will show all the posts the ## user has made. Also, when performing a search and selecting ## 'Show results as: Posts', the entire post will be displayed ## (without it being truncated) and its BBCode will be parsed. ## ## Affected files: profile.php ## search.php ## lang/English/profile.php ## lang/English/search.php ## ## Affects DB: no ## ## Notes: The modified versions of affected files are included in ## this archive for easy install if you are installing this ## mod in a clean install of punbb 1.2.21/fluxbb 1.2.21. ## ## DISCLAIMER: Please note that "mods" are not officially supported by ## PunBB. Installation of this modification is done at your ## own risk. Backup your forum database and any and all ## applicable files before proceeding. ## ## # #---------[ 1. OPEN ]--------------------------------------------------------- # profile.php # #---------[ 2. FIND (line: 969) ]--------------------------------------------- # $posts_field .= (($posts_field != '') ? ' - ' : '').''.$lang_profile['Show posts'].''; # #---------[ 3. REPLACE WITH ]------------------------------------------------- # $posts_field .= (($posts_field != '') ? ' - ' : '').''.$lang_profile['Show posts'].' | '.$lang_profile['Show topics'].''; # #---------[ 4. FIND (line: 1082) ]--------------------------------------------- # if ($pun_user['g_id'] == PUN_ADMIN) $posts_field = '

'.$lang_profile['Show posts'].'

'."\n"; else if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST) $posts_field = '

'.$lang_common['Posts'].': '.$user['num_posts'].' - '.$lang_profile['Show posts'].'

'."\n"; else $posts_field = '

'.$lang_profile['Show posts'].'

'."\n"; # #---------[ 5. REPLACE WITH ]------------------------------------------------- # if ($pun_user['g_id'] == PUN_ADMIN) $posts_field = '

'.$lang_profile['Show posts'].' | '.$lang_profile['Show topics'].'

'."\n"; else if ($pun_config['o_show_post_count'] == '1' || $pun_user['g_id'] < PUN_GUEST) $posts_field = '

'.$lang_common['Posts'].': '.$user['num_posts'].' - '.$lang_profile['Show posts'].' | '.$lang_profile['Show topics'].'

'."\n"; else $posts_field = '

'.$lang_profile['Show posts'].' | '.$lang_profile['Show topics'].'

'."\n"; # #---------[ 6. OPEN ]--------------------------------------------------------- # search.php # #---------[ 7. FIND (line: 31) ]--------------------------------------------- # require PUN_ROOT.'include/common.php'; # #---------[ 8. AFTER, ADD ]--------------------------------------------------- # require PUN_ROOT.'include/parser.php'; # #---------[ 9. FIND (line: 86) ]--------------------------------------------- # // If it's a user search (by id) else if ($action == 'show_user') # #---------[ 10. REPLACE WITH ]------------------------------------------------- # // If it's a user search (by id) else if ($action == 'show_user' || $action == 'show_topics') # #---------[ 11. FIND (line: 281) ]--------------------------------------------- # if ($author && $keywords) { // If we searched for both keywords and author name we want the intersection between the results $search_ids = array_intersect($keyword_results, $author_results); unset($keyword_results, $author_results); } else if ($keywords) $search_ids = $keyword_results; else $search_ids = $author_results; $num_hits = count($search_ids); if (!$num_hits) message($lang_search['No hits']); # #---------[ 12. REPLACE WITH ]------------------------------------------------- # if ($author && $keywords) { // If we searched for both keywords and author name we want the intersection between the results $search_ids = array_intersect($keyword_results, $author_results); unset($keyword_results, $author_results); } else if ($keywords) $search_ids = $keyword_results; else $search_ids = $author_results; $num_hits = count($search_ids); if (!$num_hits) { $is_sort_dir = (strpos($_SERVER['REQUEST_URI'],"sort_dir") !== false) ? true : false; if ($is_sort_dir) message($lang_search['No hits']); else message($lang_search['No user posts']); } # #---------[ 13. FIND (line: 329) ]--------------------------------------------- # else if ($action == 'show_new' || $action == 'show_24h' || $action == 'show_user' || $action == 'show_subscriptions' || $action == 'show_unanswered') # #---------[ 14. REPLACE WITH ]------------------------------------------------- # else if ($action == 'show_new' || $action == 'show_24h' || $action == 'show_user' || $action == 'show_topics' || $action == 'show_subscriptions' || $action == 'show_unanswered') # #---------[ 15. FIND (line: 352) ]--------------------------------------------- # // If it's a search for posts by a specific user ID else if ($action == 'show_user') { $result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.poster_id='.$user_id.' GROUP BY t.id') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); $num_hits = $db->num_rows($result); if (!$num_hits) message($lang_search['No user posts']); } # #---------[ 16. AFTER, ADD ]------------------------------------------------- # // If it's a search for topics by a specific user ID else if ($action == 'show_topics') { $result = $db->query('SELECT t.id FROM '.$db->prefix.'users AS u, '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.poster= u.username AND u.id = '.$user_id.' GROUP BY t.id') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); $num_hits = $db->num_rows($result); if (!$num_hits) message($lang_search['No user topics']); } # #---------[ 17. FIND (line: 476) ]--------------------------------------------- # $sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql; # #---------[ 18. REPLACE WITH ]------------------------------------------------- # $sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, p.message AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql; # #---------[ 19. FIND (line: 574) ]--------------------------------------------- # $message = str_replace("\n", '
', pun_htmlspecialchars($search_set[$i]['message'])); # #---------[ 20. REPLACE WITH ]------------------------------------------------- # $message = parse_message($search_set[$i]['message'], 0); # #---------[ 21. DELETE (line: 580) ]------------------------------------------------- # if (pun_strlen($message) >= 1000) $message .= ' …'; # #---------[ 22. OPEN ]--------------------------------------------------------- # lang/English/profile.php # #---------[ 23. FIND (line: 27) ]--------------------------------------------- # 'Show posts' => 'Show all posts', # #---------[ 24. AFTER, ADD ]--------------------------------------------------- # 'Show topics' => 'Show all topics', # #---------[ 25. OPEN ]--------------------------------------------------------- # lang/English/search.php # #---------[ 26. FIND (line: 27) ]--------------------------------------------- # 'No user posts' => 'There are no posts by this user in this forum.', # #---------[ 27. AFTER, ADD ]--------------------------------------------------- # 'No user topics' => 'There are no topics by this user in this forum.', # #---------[ 28. SAVE/UPLOAD ]------------------------------------------------- #