diff --git a/root/portal/block/announcements.php b/root/portal/block/announcements.php index ed780f1c..62e4ce9a 100644 --- a/root/portal/block/announcements.php +++ b/root/portal/block/announcements.php @@ -18,13 +18,6 @@ if (!defined('IN_PORTAL')) exit; } -$template->assign_vars(array( - 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'), - 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), - 'S_DISPLAY_ANNOUNCEMENTS' => true, -)); - $announcement = request_var('announcement', -1); $start = request_var('ap', 0); $start = ($start < 0) ? 0 : $start; @@ -33,264 +26,199 @@ $start = ($start < 0) ? 0 : $start; $portal_announcement_length = ($announcement < 0) ? $portal_config['portal_announcements_length'] : 0; $fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_announcements_permissions'], $portal_config['portal_number_of_announcements'], $portal_announcement_length, $portal_config['portal_announcements_day'], 'announcements', $start); - // Any announcements present? If not terminate it here. - if (sizeof($fetch_news) == 0) +// Any announcements present? If not terminate it here. +if (sizeof($fetch_news) == 0) +{ + $template->assign_block_vars('announcements_row', array( + 'S_NO_TOPICS' => true, + 'S_NOT_LAST' => false + )); + + $template->assign_var('S_CAN_READ', false); +} +else +{ + // Count number of posts for announcements archive, considering if permission check is dis- or enabled. + if ( $portal_config['portal_announcements_archive'] ) { - $template->assign_block_vars('announcements_row', array( - 'S_NO_TOPICS' => true, - 'S_NOT_LAST' => false - )); + $permissions = $portal_config['portal_announcements_permissions']; + $forum_from = $portal_config['portal_global_announcements_forum']; + $forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); - $template->assign_var('S_CAN_READ', false); - } - else - { - // Count number of posts for announcements archive, considering if permission check is dis- or enabled. - if ( $portal_config['portal_announcements_archive'] ) - { - $permissions = $portal_config['portal_announcements_permissions']; - $forum_from = $portal_config['portal_global_announcements_forum']; - $forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); - - $time = ( $portal_config['portal_announcements_day'] == 0 ) ? 0 : $portal_config['portal_announcements_day']; - $post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400); - - $str_where = ''; - - if( $permissions == TRUE ) - { - $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true))); - } else { - $disallow_access = array(); - } - - $global_f = 0; - - if( sizeof($forum_from) ) - { - $disallow_access = array_diff($forum_from, $disallow_access); - if( !sizeof($disallow_access) ) - { - return array(); - } - - foreach( $disallow_access as $acc_id) - { - $acc_id = (int) $acc_id; - $str_where .= "forum_id = $acc_id OR "; - if( $global_f < 1 && $acc_id > 0 ) - { - $global_f = $acc_id; - } - } - } - else - { - foreach( $disallow_access as $acc_id ) - { - $acc_id = (int) $acc_id; - $str_where .= "forum_id <> $acc_id AND "; - } - } - - $str_where = ( strlen($str_where) > 0 ) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : ''; - - $sql = 'SELECT COUNT(topic_id) AS num_topics - FROM ' . TOPICS_TABLE . ' - WHERE ((topic_type = ' . POST_GLOBAL . ') - OR topic_type = ' . POST_ANNOUNCE . ') - AND topic_approved = 1 - AND topic_moved_id = 0 - ' . $post_time . ' - ' . $str_where; - $result = $db->sql_query($sql); - $total_announcements = (int) $db->sql_fetchfield('num_topics'); - $db->sql_freeresult($result); - } - - - if($announcement < 0) - // Show the announcements overview - { - $count = $fetch_news['topic_count']; - for ($i = 0; $i < $count; $i++) - { - if( isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true ) - { - $open_bracket = '[ '; - $close_bracket = ' ]'; - $read_full = $user->lang['READ_FULL']; - - } - else - { - $open_bracket = ''; - $close_bracket = ''; - $read_full = ''; - } - // unread? - $forum_id = $fetch_news[$i]['forum_id']; - $topic_id = $fetch_news[$i]['topic_id']; - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); - $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; + $time = ( $portal_config['portal_announcements_day'] == 0 ) ? 0 : $portal_config['portal_announcements_day']; + $post_time = ($time == 0) ? '' : 'AND topic_time > ' . (time() - $time * 86400); - $real_forum_id = ( $forum_id == 0 ) ? $fetch_news['global_id']: $forum_id; - - $read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i; - $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); - if ( $portal_config['portal_announcements_archive'] ) - { - $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $portal_config['portal_number_of_announcements'], $start, 'announcements'); - } - + $str_where = ''; - $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) + if( $permissions == TRUE ) + { + $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true))); + } else { + $disallow_access = array(); + } + + $global_f = 0; + + if( sizeof($forum_from) ) + { + $disallow_access = array_diff($forum_from, $disallow_access); + if( !sizeof($disallow_access) ) { - $folder .= '_locked'; - $folder_new .= '_locked'; + return array(); } - if ($fetch_news[$i]['topic_type'] == POST_GLOBAL) - { - $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']) : '', - 'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '', - 'TITLE' => $fetch_news[$i]['topic_title'], - 'POSTER' => $fetch_news[$i]['username'], - 'POSTER_FULL' => $fetch_news[$i]['username_full'], - 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], - 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', - 'TIME' => $fetch_news[$i]['topic_time'], - 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']), - 'TEXT' => $fetch_news[$i]['post_text'], - 'REPLIES' => $fetch_news[$i]['topic_replies'], - 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], - 'A_ID' => $i, - '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], - '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), - 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'), - 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), - 'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url), - 'L_READ_FULL' => $read_full, - 'OPEN' => $open_bracket, - 'CLOSE' => $close_bracket, - 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, - 'S_POLL' => $fetch_news[$i]['poll'], - 'S_UNREAD_INFO' => $unread_topic, - 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), - 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, - )); - - if( !empty($fetch_news[$i]['attachments']) ) + foreach( $disallow_access as $acc_id) + { + $acc_id = (int) $acc_id; + $str_where .= "forum_id = $acc_id OR "; + if( $global_f < 1 && $acc_id > 0 ) { - foreach ($fetch_news[$i]['attachments'] as $attachment) - { - $template->assign_block_vars('announcements_row.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - if ($portal_config['portal_number_of_announcements'] <> 0 && $portal_config['portal_announcements_archive']) - { - $template->assign_vars(array( - 'S_TOPIC_ICONS' => $fetch_news['topic_icons'], - 'AP_PAGINATION' => $pagination, - 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements), - 'AP_PAGE_NUMBER' => on_page($total_announcements, $portal_config['portal_number_of_announcements'], $start)) - ); + $global_f = $acc_id; } } } else - // Show "read full" page - { - $i = $announcement; + { + foreach( $disallow_access as $acc_id ) + { + $acc_id = (int) $acc_id; + $str_where .= "forum_id <> $acc_id AND "; + } + } + + $str_where = ( strlen($str_where) > 0 ) ? 'AND (forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : ''; + + $sql = 'SELECT COUNT(topic_id) AS num_topics + FROM ' . TOPICS_TABLE . ' + WHERE ((topic_type = ' . POST_GLOBAL . ') + OR topic_type = ' . POST_ANNOUNCE . ') + AND topic_approved = 1 + AND topic_moved_id = 0 + ' . $post_time . ' + ' . $str_where; + $result = $db->sql_query($sql); + $total_announcements = (int) $db->sql_fetchfield('num_topics'); + $db->sql_freeresult($result); + } + + + if($announcement < 0) + // Show the announcements overview + { + $count = $fetch_news['topic_count']; + for ($i = 0; $i < $count; $i++) + { + if( isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true ) + { + $open_bracket = '[ '; + $close_bracket = ' ]'; + $read_full = $user->lang['READ_FULL']; + + } + else + { + $open_bracket = ''; + $close_bracket = ''; + $read_full = ''; + } + // unread? $forum_id = $fetch_news[$i]['forum_id']; $topic_id = $fetch_news[$i]['topic_id']; $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); - $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - $open_bracket = '[ '; - $close_bracket = ' ]'; - $read_full = $user->lang['BACK']; - - $read_full_url = (isset($_GET['ap'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "ap=$start#a$i") : append_sid("{$phpbb_root_path}portal.$phpEx#a$i"); + $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; + + $real_forum_id = ( $forum_id == 0 ) ? $fetch_news['global_id']: $forum_id; + + $read_full_url = (isset($_GET['ap'])) ? 'ap='. $start . '&announcement=' . $i . '#a' . $i : 'announcement=' . $i . '#a' . $i; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); if ( $portal_config['portal_announcements_archive'] ) { $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $portal_config['portal_number_of_announcements'], $start, 'announcements'); - } + } - $template->assign_block_vars('announcements_row', array( + + $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) + { + $folder .= '_locked'; + $folder_new .= '_locked'; + } + if ($fetch_news[$i]['topic_type'] == POST_GLOBAL) + { + $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']) : '', - 'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '', - 'TITLE' => $fetch_news[$i]['topic_title'], + 'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '', + 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], - 'POSTER_FULL' => $fetch_news[$i]['username_full'], - 'TIME' => $fetch_news[$i]['topic_time'], - 'TEXT' => $fetch_news[$i]['post_text'], - 'REPLIES' => $fetch_news[$i]['topic_replies'], + 'POSTER_FULL' => $fetch_news[$i]['username_full'], + 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], + 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', + 'TIME' => $fetch_news[$i]['topic_time'], + 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']), + 'TEXT' => $fetch_news[$i]['post_text'], + 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'A_ID' => $i, + '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], + '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", (($forum_id) ? 'f=' . $forum_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", 't=' . $topic_id), - 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($forum_id) ? 'f=' . $forum_id . '&' : '') . 't=' . $topic_id), - 'S_POLL' => $fetch_news[$i]['poll'], - 'S_UNREAD_INFO' => $unread_topic, - 'U_READ_FULL' => $read_full_url, - 'L_READ_FULL' => $read_full, + '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), + 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'), + 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id), + 'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url), + 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket, + 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, + 'S_POLL' => $fetch_news[$i]['poll'], + 'S_UNREAD_INFO' => $unread_topic, 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, )); - + if( !empty($fetch_news[$i]['attachments']) ) { foreach ($fetch_news[$i]['attachments'] as $attachment) @@ -304,7 +232,6 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_foru if ($portal_config['portal_number_of_announcements'] <> 0 && $portal_config['portal_announcements_archive']) { $template->assign_vars(array( - 'S_TOPIC_ICONS' => $fetch_news['topic_icons'], 'AP_PAGINATION' => $pagination, 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements), 'AP_PAGE_NUMBER' => on_page($total_announcements, $portal_config['portal_number_of_announcements'], $start)) @@ -312,5 +239,78 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_foru } } } + else + // Show "read full" page + { + $i = $announcement; + $forum_id = $fetch_news[$i]['forum_id']; + $topic_id = $fetch_news[$i]['topic_id']; + $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); + $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; + $open_bracket = '[ '; + $close_bracket = ' ]'; + $read_full = $user->lang['BACK']; + + $read_full_url = (isset($_GET['ap'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "ap=$start#a$i") : append_sid("{$phpbb_root_path}portal.$phpEx#a$i"); + $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); + if ( $portal_config['portal_announcements_archive'] ) + { + $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_announcements, $portal_config['portal_number_of_announcements'], $start, 'announcements'); + } + + $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']) : '', + 'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '', + 'TITLE' => $fetch_news[$i]['topic_title'], + 'POSTER' => $fetch_news[$i]['username'], + 'POSTER_FULL' => $fetch_news[$i]['username_full'], + 'TIME' => $fetch_news[$i]['topic_time'], + 'TEXT' => $fetch_news[$i]['post_text'], + 'REPLIES' => $fetch_news[$i]['topic_replies'], + 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], + 'A_ID' => $i, + '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", (($forum_id) ? 'f=' . $forum_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", 't=' . $topic_id), + 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&' . (($forum_id) ? 'f=' . $forum_id . '&' : '') . 't=' . $topic_id), + 'S_POLL' => $fetch_news[$i]['poll'], + 'S_UNREAD_INFO' => $unread_topic, + 'U_READ_FULL' => $read_full_url, + 'L_READ_FULL' => $read_full, + 'OPEN' => $open_bracket, + 'CLOSE' => $close_bracket, + 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), + 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, + )); + + if( !empty($fetch_news[$i]['attachments']) ) + { + foreach ($fetch_news[$i]['attachments'] as $attachment) + { + $template->assign_block_vars('announcements_row.attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + } + + if ($portal_config['portal_number_of_announcements'] <> 0 && $portal_config['portal_announcements_archive']) + { + $template->assign_vars(array( + + 'AP_PAGINATION' => $pagination, + 'TOTAL_ANNOUNCEMENTS' => ($total_announcements == 1) ? $user->lang['VIEW_LATEST_ANNOUNCEMENT'] : sprintf($user->lang['VIEW_LATEST_ANNOUNCEMENTS'], $total_announcements), + 'AP_PAGE_NUMBER' => on_page($total_announcements, $portal_config['portal_number_of_announcements'], $start)) + ); + } + } +} + +$template->assign_vars(array( + 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), + 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'), + 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), + 'S_DISPLAY_ANNOUNCEMENTS' => true, + 'S_TOPIC_ICONS' => $fetch_news['topic_icons'], +)); ?> \ No newline at end of file diff --git a/root/portal/block/news.php b/root/portal/block/news.php index b7dff146..5e731e8a 100644 --- a/root/portal/block/news.php +++ b/root/portal/block/news.php @@ -20,15 +20,6 @@ if (!defined('IN_PORTAL')) exit; } -$template->assign_vars(array( - 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), - 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'), - 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), - 'S_NEWEST_OR_FIRST' => ( $portal_config['portal_news_show_last'] ) ? $user->lang['JUMP_NEWEST'] : $user->lang['JUMP_FIRST'], - 'POSTED_BY_TEXT' => ( $portal_config['portal_news_show_last'] ) ? $user->lang['LAST_POST'] : $user->lang['POSTED'], - 'S_DISPLAY_NEWS' => true, -)); - $news = request_var('news', -1); $user->add_lang('viewforum'); $start = request_var('np', 0); @@ -39,242 +30,177 @@ $portal_news_length = ($news < 0) ? $portal_config['portal_news_length'] : 0; $fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_news_permissions'], $portal_config['portal_number_of_news'], $portal_news_length, 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news', $start); - // Any news present? If not terminate it here. - if (sizeof($fetch_news) == 0) +// Any news present? If not terminate it here. +if (sizeof($fetch_news) == 0) +{ + $template->assign_block_vars('news_row', array( + 'S_NO_TOPICS' => true, + 'S_NOT_LAST' => false, + )); +} +else +{ + // Count number of posts for news archive, considering if permission check is dis- or enabled. + if ( $portal_config['portal_news_archive'] ) { - $template->assign_block_vars('news_row', array( - 'S_NO_TOPICS' => true, - 'S_NOT_LAST' => false, - )); - } - else - { - // Count number of posts for news archive, considering if permission check is dis- or enabled. - if ( $portal_config['portal_news_archive'] ) + $permissions = $portal_config['portal_news_permissions']; + $forum_from = $portal_config['portal_news_forum']; + + $forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); + + $str_where = ''; + + if( $permissions == TRUE ) { - $permissions = $portal_config['portal_news_permissions']; - $forum_from = $portal_config['portal_news_forum']; - - $forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array()); - - $str_where = ''; - - if( $permissions == TRUE ) + $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true))); + } else { + $disallow_access = array(); + } + + if( sizeof($forum_from) ) + { + $disallow_access = array_diff($forum_from, $disallow_access); + if( !sizeof($disallow_access) ) { - $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true))); - } else { - $disallow_access = array(); + return array(); } - if( sizeof($forum_from) ) + foreach( $disallow_access as $acc_id) { - $disallow_access = array_diff($forum_from, $disallow_access); - if( !sizeof($disallow_access) ) - { - return array(); - } - - foreach( $disallow_access as $acc_id) - { - $acc_id = (int) $acc_id; - $str_where .= "forum_id = $acc_id OR "; - } - } - else - { - foreach( $disallow_access as $acc_id ) - { - $acc_id = (int) $acc_id; - $str_where .= "forum_id <> $acc_id AND "; - } - } - - $str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; - - $topic_type = ($portal_config['portal_show_all_news']) ? '( topic_type <> ' . POST_ANNOUNCE . ' ) AND ( topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL; - - $sql = 'SELECT COUNT(topic_id) AS num_topics - FROM ' . TOPICS_TABLE . ' - WHERE ' . $topic_type . ' - AND topic_approved = 1 - AND topic_moved_id = 0 - ' . $str_where; - $result = $db->sql_query($sql); - $total_news = (int) $db->sql_fetchfield('num_topics'); - $db->sql_freeresult($result); - } - - if($news < 0) - // Show the news overview - { - $count = $fetch_news['topic_count']; - for ($i = 0; $i < $count; $i++) - { - if( isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true ) - { - $open_bracket = '[ '; - $close_bracket = ' ]'; - $read_full = $user->lang['READ_FULL']; - } - else - { - $open_bracket = ''; - $close_bracket = ''; - $read_full = ''; - } - // unread? - $forum_id = $fetch_news[$i]['forum_id']; - $topic_id = $fetch_news[$i]['topic_id']; - $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); - $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - - $read_full_url = (isset($_GET['np'])) ? 'np='. $start . '&news=' . $i . '#n' . $i : 'news=' . $i . '#n' . $i; - $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); - if ( $portal_config['portal_news_archive'] ) - { - $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'); - } - - $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: - $folder = 'sticky_read'; - $folder_new = 'sticky_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) - { - $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; - - $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']) : '', - 'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '', - 'TITLE' => $fetch_news[$i]['topic_title'], - 'POSTER' => $fetch_news[$i]['username'], - 'POSTER_FULL' => $fetch_news[$i]['username_full'], - 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], - 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', - 'TIME' => $fetch_news[$i]['topic_time'], - 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']), - 'TEXT' => $fetch_news[$i]['post_text'], - 'REPLIES' => $fetch_news[$i]['topic_replies'], - 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], - 'N_ID' => $i, - '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']), - 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), - 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'), - 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), - 'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url), - 'L_READ_FULL' => $read_full, - 'OPEN' => $open_bracket, - 'CLOSE' => $close_bracket, - 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, - 'S_POLL' => $fetch_news[$i]['poll'], - 'S_UNREAD_INFO' => $unread_topic, - 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), - 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, - )); - - if( !empty($fetch_news[$i]['attachments']) ) - { - foreach ($fetch_news[$i]['attachments'] as $attachment) - { - $template->assign_block_vars('news_row.attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); - } - } - - if ($portal_config['portal_number_of_news'] <> 0 && $portal_config['portal_news_archive']) - { - $template->assign_vars(array( - 'S_TOPIC_ICONS' => $fetch_news['topic_icons'], - 'NP_PAGINATION' => $pagination, - 'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news), - 'NP_PAGE_NUMBER' => on_page($total_news, $portal_config['portal_number_of_news'], $start)) - ); - } + $acc_id = (int) $acc_id; + $str_where .= "forum_id = $acc_id OR "; } } else - // Show "read full" page { - $i = $news; + foreach( $disallow_access as $acc_id ) + { + $acc_id = (int) $acc_id; + $str_where .= "forum_id <> $acc_id AND "; + } + } + + $str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; + + $topic_type = ($portal_config['portal_show_all_news']) ? '( topic_type <> ' . POST_ANNOUNCE . ' ) AND ( topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL; + + $sql = 'SELECT COUNT(topic_id) AS num_topics + FROM ' . TOPICS_TABLE . ' + WHERE ' . $topic_type . ' + AND topic_approved = 1 + AND topic_moved_id = 0 + ' . $str_where; + $result = $db->sql_query($sql); + $total_news = (int) $db->sql_fetchfield('num_topics'); + $db->sql_freeresult($result); + } + + if($news < 0) + // Show the news overview + { + $count = $fetch_news['topic_count']; + for ($i = 0; $i < $count; $i++) + { + if( isset($fetch_news[$i]['striped']) && $fetch_news[$i]['striped'] == true ) + { + $open_bracket = '[ '; + $close_bracket = ' ]'; + $read_full = $user->lang['READ_FULL']; + } + else + { + $open_bracket = ''; + $close_bracket = ''; + $read_full = ''; + } + // unread? $forum_id = $fetch_news[$i]['forum_id']; $topic_id = $fetch_news[$i]['topic_id']; $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; - $open_bracket = '[ '; - $close_bracket = ' ]'; - $read_full = $user->lang['BACK']; - - $read_full_url = (isset($_GET['np'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "np=$start#n$i") : append_sid("{$phpbb_root_path}portal.$phpEx#n$i"); + + $read_full_url = (isset($_GET['np'])) ? 'np='. $start . '&news=' . $i . '#n' . $i : 'news=' . $i . '#n' . $i; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); if ( $portal_config['portal_news_archive'] ) { $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'); } + + $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: + $folder = 'sticky_read'; + $folder_new = 'sticky_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) + { + $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; + $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']) : '', 'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '', 'TITLE' => $fetch_news[$i]['topic_title'], 'POSTER' => $fetch_news[$i]['username'], 'POSTER_FULL' => $fetch_news[$i]['username_full'], + 'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'], + 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '', 'TIME' => $fetch_news[$i]['topic_time'], + 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']), 'TEXT' => $fetch_news[$i]['post_text'], 'REPLIES' => $fetch_news[$i]['topic_replies'], 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], 'N_ID' => $i, + '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", 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_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']), 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'), 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url), + 'L_READ_FULL' => $read_full, + 'OPEN' => $open_bracket, + 'CLOSE' => $close_bracket, + 'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false, 'S_POLL' => $fetch_news[$i]['poll'], 'S_UNREAD_INFO' => $unread_topic, - 'U_READ_FULL' => $read_full_url, - 'L_READ_FULL' => $read_full, - 'OPEN' => $open_bracket, - 'CLOSE' => $close_bracket, 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, )); @@ -293,12 +219,85 @@ $fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_con { $template->assign_vars(array( 'NP_PAGINATION' => $pagination, - 'S_TOPIC_ICONS' => $fetch_news['topic_icons'], 'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news), 'NP_PAGE_NUMBER' => on_page($total_news, $portal_config['portal_number_of_news'], $start)) ); } } } + else + // Show "read full" page + { + $i = $news; + $forum_id = $fetch_news[$i]['forum_id']; + $topic_id = $fetch_news[$i]['topic_id']; + $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false); + $unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; + $open_bracket = '[ '; + $close_bracket = ' ]'; + $read_full = $user->lang['BACK']; + + $read_full_url = (isset($_GET['np'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "np=$start#n$i") : append_sid("{$phpbb_root_path}portal.$phpEx#n$i"); + $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id); + if ( $portal_config['portal_news_archive'] ) + { + $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'); + } + + $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']) : '', + 'FORUM_NAME' => ( $forum_id ) ? $fetch_news[$i]['forum_name'] : '', + 'TITLE' => $fetch_news[$i]['topic_title'], + 'POSTER' => $fetch_news[$i]['username'], + 'POSTER_FULL' => $fetch_news[$i]['username_full'], + 'TIME' => $fetch_news[$i]['topic_time'], + 'TEXT' => $fetch_news[$i]['post_text'], + 'REPLIES' => $fetch_news[$i]['topic_replies'], + 'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'], + 'N_ID' => $i, + '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", '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", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']), + 'S_POLL' => $fetch_news[$i]['poll'], + 'S_UNREAD_INFO' => $unread_topic, + 'U_READ_FULL' => $read_full_url, + 'L_READ_FULL' => $read_full, + 'OPEN' => $open_bracket, + 'CLOSE' => $close_bracket, + 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url), + 'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false, + )); + + if( !empty($fetch_news[$i]['attachments']) ) + { + foreach ($fetch_news[$i]['attachments'] as $attachment) + { + $template->assign_block_vars('news_row.attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + } + + if ($portal_config['portal_number_of_news'] <> 0 && $portal_config['portal_news_archive']) + { + $template->assign_vars(array( + 'NP_PAGINATION' => $pagination, + 'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news), + 'NP_PAGE_NUMBER' => on_page($total_news, $portal_config['portal_number_of_news'], $start)) + ); + } + } +} + +$template->assign_vars(array( + 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), + 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'), + 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'), + 'S_NEWEST_OR_FIRST' => ( $portal_config['portal_news_show_last'] ) ? $user->lang['JUMP_NEWEST'] : $user->lang['JUMP_FIRST'], + 'POSTED_BY_TEXT' => ( $portal_config['portal_news_show_last'] ) ? $user->lang['LAST_POST'] : $user->lang['POSTED'], + 'S_DISPLAY_NEWS' => true, + 'S_TOPIC_ICONS' => $fetch_news['topic_icons'], +)); ?> \ No newline at end of file diff --git a/root/portal/includes/functions.php b/root/portal/includes/functions.php index 97753112..ebf627d5 100644 --- a/root/portal/includes/functions.php +++ b/root/portal/includes/functions.php @@ -84,6 +84,8 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le $str_where = ''; $topic_icons = array(); + + $have_icons = 0; if( $permissions == TRUE ) { @@ -137,7 +139,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le $topic_type = 't.topic_type = ' . POST_NORMAL; $str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; $user_link = ( $portal_config['portal_news_style'] ) ? 't.topic_poster = u.user_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ; - $post_link = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ; + $post_link = ( $portal_config['portal_news_style'] ) ? 't.topic_first_post_id = p.post_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ; $topic_order = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ; @@ -147,7 +149,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le $topic_type = '( t.topic_type <> ' . POST_ANNOUNCE . ' ) AND ( t.topic_type <> ' . POST_GLOBAL . ')'; $str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : ''; $user_link = ( $portal_config['portal_news_style'] ) ? 't.topic_poster = u.user_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ; - $post_link = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ; + $post_link = ( $portal_config['portal_news_style'] ) ? 't.topic_first_post_id = p.post_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ; $topic_order = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ; break; @@ -318,11 +320,12 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le } $topic_icons[] = $row['enable_icons']; + $have_icons = ( $row['icon_id'] > 0 ) ? 1 : $have_icons; $posts[$i] = array_merge($posts[$i], array( 'post_text' => ap_validate($message), 'topic_id' => $row['topic_id'], - 'topic_last_post_id' => $row['post_id'], + 'topic_last_post_id' => $row['topic_last_post_id'], 'topic_type' => $row['topic_type'], 'topic_posted' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, 'icon_id' => $row['icon_id'], @@ -350,7 +353,8 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le $i++; } - $posts['topic_icons'] = max($topic_icons); + $posts['topic_icons'] = ( max($topic_icons) > 0 && $have_icons ) ? true : false; + $posts['topic_count'] = $i; if( $global_f < 1 )