sql_fetchrow($result); $sql = " SELECT f.forum_id, f.forum_name" . $sql_title . ", t.topic_id, t.topic_last_post_id, t.topic_poster, t.topic_views, t.topic_replies, t.topic_type, t.topic_status, p2.post_time, p2.poster_id, u.username as last_username, u2.username as author_username FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u, " . USERS_TABLE . " u2 WHERE f.forum_id IN (" . $glance_news_forum_id . ") AND t.forum_id = f.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND t.topic_moved_id = 0 AND p2.poster_id = u.user_id AND t.topic_poster = u2.user_id ORDER BY t.topic_last_post_id DESC"; $sql .= ($glance_news_offset) ? " LIMIT " . $glance_news_offset . ", " . $glance_num_news : " LIMIT " . $glance_num_news; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not query new news information", "", __LINE__, __FILE__, $sql); } $latest_news = array(); while ( $topic_row = $db->sql_fetchrow($result) ) { $topic_row['topic_title'] = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_row['topic_title']) : $topic_row['topic_title']; $latest_news[] = $topic_row; } $db->sql_freeresult($result); // MOD NAV BEGIN // obtain the total number of topic for our news topic navigation bit $sql = "SELECT SUM(forum_topics) as topic_total FROM " . FORUMS_TABLE . " f WHERE f.forum_id IN (" . $glance_news_forum_id . ")"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not query total topics information", "", __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $overall_news_topics = $row['topic_total']; $db->sql_freeresult($result); // MOD NAV END } // // GET THE LAST 5 TOPICS // if ( $glance_num_recent ) { $glance_auth_level = ( $glance_auth_read ) ? AUTH_VIEW : AUTH_ALL; $is_auth_ary = auth($glance_auth_level, AUTH_LIST_ALL, $userdata); $forumsignore = $glance_news_forum_id; if ( $num_forums = count($is_auth_ary) ) { while ( list($forum_id, $auth_mod) = each($is_auth_ary) ) { $unauthed = false; if ( !$auth_mod['auth_view'] ) { $unauthed = true; } if ( !$glance_auth_read && !$auth_mod['auth_read'] ) { $unauthed = true; } if ( $unauthed ) { $forumsignore .= ($forumsignore) ? ',' . $forum_id : $forum_id; } } } $forumsignore .= ($forumsignore && $glance_recent_ignore) ? ',' : ''; $sql = " SELECT f.forum_id, f.forum_name" . $sql_title . ", t.topic_id, t.topic_last_post_id, t.topic_poster, t.topic_views, t.topic_replies, t.topic_type, p2.post_time, p2.poster_id, u.username as last_username, u2.username as author_username FROM " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u, " . USERS_TABLE . " u2 WHERE f.forum_id NOT IN (" . $forumsignore . $glance_recent_ignore . ") AND t.forum_id = f.forum_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND t.topic_moved_id = 0 AND p2.poster_id = u.user_id AND t.topic_poster = u2.user_id ORDER BY t.topic_last_post_id DESC"; $sql .= ($glance_recent_offset) ? " LIMIT " . $glance_recent_offset . ", " . $glance_num_recent : " LIMIT " . $glance_num_recent; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not query latest topic information", "", __LINE__, __FILE__, $sql); } $latest_topics = array(); $latest_anns = array(); $latest_stickys = array(); while ( $topic_row = $db->sql_fetchrow($result) ) { $topic_row['topic_title'] = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_row['topic_title']) : $topic_row['topic_title']; switch ($topic_row['topic_type']) { case POST_ANNOUNCE: $latest_anns[] = $topic_row; break; case POST_STICKY: $latest_stickys[] = $topic_row; break; default: $latest_topics[] = $topic_row; break; } } $latest_topics = array_merge($latest_anns, $latest_stickys, $latest_topics); $db->sql_freeresult($result); // MOD NAV BEGIN // obtain the total number of topic for our recent topic navigation bit $sql = "SELECT SUM(forum_topics) as topic_total FROM " . FORUMS_TABLE . " f WHERE f.forum_id NOT IN (" . $forumsignore . $glance_recent_ignore . $glance_news_forum_id . ")"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Could not query total topics information", "", __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $overall_total_topics = $row['topic_total']; $db->sql_freeresult($result); // MOD NAV END } // // BEGIN OUTPUT // $template->set_filenames(array( 'glance_output' => 'glance_body.tpl') ); if ( $glance_num_news ) { if ( !empty($latest_news) ) { $bullet_pre = ''; $newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '' : ''; $topic_link = $glance_forum_dir . 'viewtopicp&t=' . $latest_news[$i]['topic_id'] . $newest_code; // // MOD TODAY AT BEGIN // //if ( $board_config['time_today'] < $latest_news[$i]['post_time']) //{ // $last_post_time = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $latest_news[$i]['post_time'], $board_config['board_timezone'])); //} //else if ( $board_config['time_yesterday'] < $latest_topics[$i]['post_time']) //{ // $last_post_time = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $latest_news[$i]['post_time'], $board_config['board_timezone'])); //} // MOD TODAY AT END $last_poster = ($latest_news[$i]['poster_id'] == ANONYMOUS ) ? ( ($latest_news[$i]['last_username'] != '' ) ? $latest_news[$i]['last_username'] . ' ' : $lang['Guest'] . ' ' ) : '' . $latest_news[$i]['last_username'] . ' '; $last_poster .= '' . $lang['View_latest_post'] . ''; $topic_poster = ($latest_news[$i]['topic_poster'] == ANONYMOUS ) ? ( ($latest_news[$i]['author_username'] != '' ) ? $latest_news[$i]['author_username'] . ' ' : $lang['Guest'] . ' ' ) : '' . $latest_news[$i]['author_username'] . ' '; $template->assign_block_vars('news', array( 'BULLET' => $bullet_full, 'TOPIC_TITLE' => $latest_news[$i]['topic_title'], 'TOPIC_LINK' => $topic_link, 'TOPIC_TIME' => $last_post_time, 'TOPIC_POSTER' => $topic_poster, 'TOPIC_VIEWS' => $latest_news[$i]['topic_views'], 'TOPIC_REPLIES' => $latest_news[$i]['topic_replies'], 'LAST_POSTER' => $last_poster, 'FORUM_TITLE' => $latest_news[$i]['forum_name'], 'FORUM_LINK' => $glance_forum_dir . 'viewforum&f=' . $latest_news[$i]['forum_id']) ); } // MOD NAV BEGIN if (($glance_news_offset > 0) or ($glance_news_offset+$glance_num_news < $overall_news_topics)) { $new_url = '<< Prev ' . $glance_num_news . '' : $new_url . ($glance_news_offset-$glance_num_news).'" class="th"><< Prev ' . $glance_num_news . ''; } if ($glance_news_offset+$glance_num_news < $overall_total_topics) { // offset + limit gives us the maximum record number // that we could have displayed on this page. if it's // less than the total number of entries, that means // there are more entries to see, and we can go forward $next_news_url = ($glance_recent_offset > 0) ? $new_url . ($glance_news_offset+$glance_num_news) . '&glance_recent_offset=' . $glance_recent_offset . '" class="th">Next ' . $glance_num_news . ' >>' : $new_url . ($glance_news_offset+$glance_num_news).'" class="th">Next ' . $glance_num_news . ' >>'; } } // MOD NAV END } else { $template->assign_block_vars('news', array( 'BULLET' => '', $glance_recent_bullet_old, 'TOPIC_TITLE' => 'None') ); } } if ( $glance_num_recent ) { $glance_info = 'counted recent'; $bullet_pre = ''; break; case POST_STICKY: $bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? $images['folder_sticky_new'] : $images['folder_sticky'] ) . '" border="0" />'; break; default: if ($latest_topics[$i]['topic_status'] == TOPIC_LOCKED) { $folder = $images['folder_locked']; $folder_new = $images['folder_locked_new']; } else if ($latest_topics[$i]['topic_replies'] >= $board_config['hot_threshold']) { $folder = $images['folder_hot']; $folder_new = $images['folder_hot_new']; } else { $folder = $images['folder']; $folder_new = $images['folder_new']; } $bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? $folder_new : $folder ) . '" border="0" />'; break; } $newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '' : ''; $topic_link = $glance_forum_dir . 'viewtopic&t=' . $latest_topics[$i]['topic_id'] . $newest_code; $topic_poster = ($latest_topics[$i]['topic_poster'] == ANONYMOUS ) ? ( ($latest_topics[$i]['author_username'] != '' ) ? $latest_topics[$i]['author_username'] . ' ' : $lang['Guest'] . ' ' ) : '' . $latest_topics[$i]['author_username'] . ' '; $last_post_time = create_date($board_config['default_dateformat'], $latest_topics[$i]['post_time'], $board_config['board_timezone']); $last_poster = ($latest_topics[$i]['poster_id'] == ANONYMOUS ) ? ( ($latest_topics[$i]['last_username'] != '' ) ? $latest_topics[$i]['last_username'] . ' ' : $lang['Guest'] . ' ' ) : '' . $latest_topics[$i]['last_username'] . ' '; $last_poster .= '' . $lang['View_latest_post'] . ''; // // MOD TODAY AT BEGIN // //if ( $board_config['time_today'] < $latest_topics[$i]['post_time']) //{ // $last_post_time = sprintf($lang['Today_at'], create_date($board_config['default_timeformat'], $latest_topics[$i]['post_time'], $board_config['board_timezone'])); //} //else if ( $board_config['time_yesterday'] < $latest_topics[$i]['post_time']) //{ // $last_post_time = sprintf($lang['Yesterday_at'], create_date($board_config['default_timeformat'], $latest_topics[$i]['post_time'], $board_config['board_timezone'])); //} // MOD TODAY AT END $template->assign_block_vars('recent', array( 'BULLET' => $bullet_full, 'TOPIC_LINK' => $topic_link, 'TOPIC_TITLE' => $latest_topics[$i]['topic_title'], 'TOPIC_POSTER' => $topic_poster, 'TOPIC_VIEWS' => $latest_topics[$i]['topic_views'], 'TOPIC_REPLIES' => $latest_topics[$i]['topic_replies'], 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => $last_poster, 'FORUM_TITLE' => $latest_topics[$i]['forum_name'], 'FORUM_LINK' => $glance_forum_dir . 'viewforum&f=' . $latest_topics[$i]['forum_id']) ); } // MOD NAV BEGIN if (($glance_recent_offset > 0) or ($glance_recent_offset+$glance_num_recent < $overall_total_topics)) { $new_url = '<< Prev ' . $glance_num_recent . '' : $new_url . ($glance_recent_offset-$glance_num_recent).'" class="th"><< Prev ' . $glance_num_recent . ''; } if ($glance_recent_offset+$glance_num_recent < $overall_total_topics) { // offset + limit gives us the maximum record number // that we could have displayed on this page. if it's // less than the total number of entries, that means // there are more entries to see, and we can go forward $next_recent_url = ($glance_news_offset > 0) ? $new_url . ($glance_recent_offset+$glance_num_recent) . '&glance_news_offset=' . $glance_news_offset . '" class="th">Next ' . $glance_num_recent . ' >>' : $new_url . ($glance_recent_offset+$glance_num_recent).'" class="th">Next ' . $glance_num_recent . ' >>'; } } // MOD NAV END } else { $template->assign_block_vars('recent', array( 'BULLET' => '', $glance_recent_bullet_old, 'TOPIC_TITLE' => 'None') ); } } if ( $glance_num_news ) { $template->assign_block_vars('switch_glance_news', array( 'NEXT_URL' => $next_news_url, 'PREV_URL' => $prev_news_url) ); // MOD CAT ROLLOUT BEGIN //$news_on = !isset($HTTP_COOKIE_VARS['phpbbGlance_news']) || !empty($HTTP_COOKIE_VARS['phpbbGlance_news']) ? true : false; //if( $news_on ) //{ // $template->assign_block_vars('switch_glance_news.switch_news_on', array()); //} //else //{ // $template->assign_block_vars('switch_glance_news.switch_news_off', array()); //} // MOD CAT ROLLOUT END } if ( $glance_num_recent ) { $template->assign_block_vars('switch_glance_recent', array( 'NEXT_URL' => $next_recent_url, 'PREV_URL' => $prev_recent_url) ); // MOD CAT ROLLOUT BEGIN //$recent_on = !isset($HTTP_COOKIE_VARS['phpbbGlance_recent']) || !empty($HTTP_COOKIE_VARS['phpbbGlance_recent']) ? true : false; //if( $recent_on ) //{ // $template->assign_block_vars('switch_glance_recent.switch_recent_on', array()); //} //else //{ // $template->assign_block_vars('switch_glance_recent.switch_recent_off', array()); //} // MOD CAT ROLLOUT END } $template->assign_vars(array( 'GLANCE_TABLE_WIDTH' => $glance_table_width, 'RECENT_HEADING' => $glance_recent_heading, 'NEWS_HEADING' => $glance_news_heading, 'L_TOPICS' => $lang['Topics'], 'L_REPLIES' => $lang['Replies'], 'L_VIEWS' => $lang['Views'], 'L_LASTPOST' => $lang['Last_Post'], 'L_AUTHOR' => $lang['Author']) ); $template->assign_var_from_handle('GLANCE_OUTPUT', 'glance_output'); // THE END ?>