From 9d9e5684c7666616998474133fe6ddd4fc809929 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 16 Aug 2008 15:45:27 +0000 Subject: [PATCH] Topic icons and the "self post star" are displayed now. --- root/portal/block/announcements.php | 64 ++++++++++++++++------------- root/portal/block/news.php | 41 ++++++++++-------- root/portal/includes/functions.php | 6 +++ 3 files changed, 67 insertions(+), 44 deletions(-) diff --git a/root/portal/block/announcements.php b/root/portal/block/announcements.php index c4f0b38d..6b4f0db9 100644 --- a/root/portal/block/announcements.php +++ b/root/portal/block/announcements.php @@ -143,37 +143,32 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_foru $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $portal_config['portal_number_of_announcements'], $start, 'announcements'); } - // Determining topic icons code borrowed from nickvergessens NV_recent_topics - http://www.flying-bits.org - $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; - - $folder_img = $folder_alt = $topic_type = $folder = $folder_new = ''; - switch ($fetch_news[$i]['topic_type']) - { - case POST_GLOBAL: - $topic_type = $user->lang['VIEW_TOPIC_GLOBAL']; - $folder = 'global_read'; - $folder_new = 'global_unread'; - break; - case POST_ANNOUNCE: - $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT']; - $folder = 'announce_read'; - $folder_new = 'announce_unread'; - break; - default: - $topic_type = ''; - $folder = 'topic_read'; - $folder_new = 'topic_unread'; - if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) - { - $folder .= '_hot'; - $folder_new .= '_hot'; - } - break; - } + + $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; + $folder_img = $folder_alt = $topic_type = $folder = $folder_new = ''; + switch ($fetch_news[$i]['topic_type']) + { + case POST_GLOBAL: + $folder = 'global_read'; + $folder_new = 'global_unread'; + break; + case POST_ANNOUNCE: + $folder = 'announce_read'; + $folder_new = 'announce_unread'; + break; + default: + $folder = 'topic_read'; + $folder_new = 'topic_unread'; + if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) + { + $folder .= '_hot'; + $folder_new .= '_hot'; + } + break; + } if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) { - $topic_type = $user->lang['VIEW_TOPIC_LOCKED']; $folder .= '_locked'; $folder_new .= '_locked'; } @@ -181,8 +176,18 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_foru { $global_announce_list[$fetch_news[$i]['topic_id']] = true; } + if ($fetch_news[$i]['topic_posted']) + { + $folder .= '_mine'; + $folder_new .= '_mine'; + } $folder_img = ($unread_topic) ? $folder_new : $folder; $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); + + // Grab icons + $icons = $cache->obtain_icons(); + $forum_data = $db->sql_fetchrow($result); + $s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; $template->assign_block_vars('announcements_row', array( 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', @@ -202,6 +207,9 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_foru 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'), + 'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', + 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', + 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), diff --git a/root/portal/block/news.php b/root/portal/block/news.php index e2fc51d2..9e7ca594 100644 --- a/root/portal/block/news.php +++ b/root/portal/block/news.php @@ -134,25 +134,20 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_con { $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $portal_config['portal_number_of_news'], $start, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news'); } - - // Determining topic icons code borrowed from nickvergessens NV_recent_topics - http://www.flying-bits.org - $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; - $folder_img = $folder_alt = $topic_type = $folder = $folder_new = ''; + $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies']; + $folder_img = $folder_alt = $topic_type = $folder = $folder_new = ''; switch ($fetch_news[$i]['topic_type']) { case POST_STICKY: - $topic_type = $user->lang['VIEW_TOPIC_STICKY']; $folder = 'sticky_read'; $folder_new = 'sticky_unread'; break; case POST_ANNOUNCE: - $topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT']; $folder = 'announce_read'; $folder_new = 'announce_unread'; break; default: - $topic_type = ''; $folder = 'topic_read'; $folder_new = 'topic_unread'; if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED) @@ -162,16 +157,26 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_con } break; } - - if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) - { - $topic_type = $user->lang['VIEW_TOPIC_LOCKED']; - $folder .= '_locked'; - $folder_new .= '_locked'; - } + + if ($fetch_news[$i]['topic_status'] == ITEM_LOCKED) + { + $folder .= '_locked'; + $folder_new .= '_locked'; + } + if ($fetch_news[$i]['topic_posted']) + { + $folder .= '_mine'; + $folder_new .= '_mine'; + } + + $folder_img = ($unread_topic) ? $folder_new : $folder; + $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); + + // Grab icons + $icons = $cache->obtain_icons(); + $forum_data = $db->sql_fetchrow($result); + $s_display_active = ($forum_data['forum_type'] == FORUM_CAT && ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; - $folder_img = ($unread_topic) ? $folder_new : $folder; - $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); $template->assign_block_vars('news_row', array( 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', @@ -190,6 +195,9 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_con 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], + 'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '', + 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '', + 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '', 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'), 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']), 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']), @@ -200,6 +208,7 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_con 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, + 'S_TOPIC_ICONS' => ($s_display_active && sizeof($active_forum_ary)) ? max($active_forum_ary['enable_icons']) : (($forum_data['enable_icons']) ? true : false), 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, diff --git a/root/portal/includes/functions.php b/root/portal/includes/functions.php index 5a465e3a..ea7f343f 100644 --- a/root/portal/includes/functions.php +++ b/root/portal/includes/functions.php @@ -193,6 +193,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le t.topic_last_poster_name, t.topic_last_poster_id, t.topic_last_poster_colour, + t.icon_id, u.username, u.user_id, u.user_type, @@ -239,6 +240,9 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le 'ORDER_BY' => $topic_order, ); + $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']); + $sql_array['SELECT'] .= ', tp.topic_posted'; + $sql = $db->sql_build_query('SELECT', $sql_array); if ($number_of_posts <> 0) @@ -315,6 +319,8 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le 'topic_id' => $row['topic_id'], 'topic_last_post_id' => $row['post_id'], 'topic_type' => $row['topic_type'], + 'topic_posted' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, + 'icon_id' => $row['icon_id'], 'topic_status' => $row['topic_status'], 'forum_id' => $row['forum_id'], 'topic_replies' => $row['topic_replies'],