[RC] Advanced Topic Type

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply
NevilleX
Registered User
Posts: 4
Joined: Sat Oct 15, 2005 8:35 pm

Post by NevilleX » Tue Oct 18, 2005 8:11 pm

OK, my images shows, but in the wrong place 8O

Icon on No1 topic should be on No2 (important) topic! No1 icon is assigned to Important topic type in admin panel.

Image

Please help!

skinx
Registered User
Posts: 5
Joined: Fri Oct 28, 2005 11:12 am

vieuwforum wont count more pages

Post by skinx » Fri Oct 28, 2005 11:25 am

Ey people i have installed this great mod and it works fine but im only having one problem with it and i hope you people can help me out

on the vieuwforum page when there are more then 50 topics made it should post further on a next page page 2
well the next page is given but the posts keep being displayed on page 1 so now i get a huge list on one page

Ive tested it out with my backup vieuwforum.php and when i put that back it works ok and the posts are given on page 2 also
so i gues there is a mistake in vieuwforum.php

here is my edited vieuwforum.php file and i hope you people can help me with the mistake or maybe possible bug
Thank you :wink:

Code: Select all

<?php
/***************************************************************************
 *                               viewforum.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: viewforum.php,v 1.139.2.12 2004/03/13 15:08:23 acydburn Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include_once($phpbb_root_path.'includes/functions_color_groups.'.$phpEx);


//
// Start initial var setup
//
if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
{
	$forum_id = ( isset($HTTP_GET_VARS[POST_FORUM_URL]) ) ? intval($HTTP_GET_VARS[POST_FORUM_URL]) : intval($HTTP_POST_VARS[POST_FORUM_URL]);
}
else if ( isset($HTTP_GET_VARS['forum']))
{
	$forum_id = intval($HTTP_GET_VARS['forum']);
}
else
{
	$forum_id = '';
}

$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;

if ( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
{
	$mark_read = (isset($HTTP_POST_VARS['mark'])) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
}
else
{
	$mark_read = '';
}
//
// End initial var setup
//

//
// Check if the user has actually sent a forum ID with his/her request
// If not give them a nice error page.
//
if ( !empty($forum_id) )
{
	$sql = "SELECT *
		FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
	}
}
else
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}

//
// If the query doesn't return any rows this isn't a valid forum. Inform
// the user.
//
if ( !($forum_row = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, 'Forum_not_exist');
}

//
// Start session management
//
$userdata = session_pagestart($user_ip, $forum_id);
init_userprefs($userdata);
//
// End session management
//

//
// Start auth check
//
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);

if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
{
	if ( !$userdata['session_logged_in'] )
	{
		$redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
		redirect(append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
	}
	//
	// The user is not authed to read this forum ...
	//
	$message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);

	message_die(GENERAL_MESSAGE, $message);
}
//
// End of auth check
//

//
// Handle marking posts
//
if ( $mark_read == 'topics' )
{
	if ( $userdata['session_logged_in'] )
	{
		$sql = "SELECT MAX(post_time) AS last_post 
			FROM " . POSTS_TABLE . " 
			WHERE forum_id = $forum_id";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
		}

		if ( $row = $db->sql_fetchrow($result) )
		{
			$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
			$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();

			if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
			{
				asort($tracking_forums);
				unset($tracking_forums[key($tracking_forums)]);
			}

			if ( $row['last_post'] > $userdata['user_lastvisit'] )
			{
				$tracking_forums[$forum_id] = time();

				setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
			}
		}

		$template->assign_vars(array(
			'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
		);
	}

	$message = $lang['Topics_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a> ');
	message_die(GENERAL_MESSAGE, $message);
}
//
// End handle marking posts
//

$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : '';
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';

//
// Do the forum Prune
//
if ( $is_auth['auth_mod'] && $board_config['prune_enable'] )
{
	if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
	{
		include($phpbb_root_path . 'includes/prune.'.$phpEx);
		require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
		auto_prune($forum_id);
	}
}
//
// End of forum prune
//

//
// Obtain list of moderators of each forum
// First users, then groups ... broken into two queries
//
$sql = "SELECT u.user_id, u.username 
	FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
	WHERE aa.forum_id = $forum_id 
		AND aa.auth_mod = " . TRUE . " 
		AND g.group_single_user = 1
		AND ug.group_id = aa.group_id 
		AND g.group_id = aa.group_id 
		AND u.user_id = ug.user_id 
	GROUP BY u.user_id, u.username  
	ORDER BY u.user_id";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}

$moderators = array();
while( $row = $db->sql_fetchrow($result) )
{
	$moderators[] = color_group_colorize_name($row['user_id']);
	
}

$sql = "SELECT g.group_id, g.group_name 
	FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g 
	WHERE aa.forum_id = $forum_id
		AND aa.auth_mod = " . TRUE . " 
		AND g.group_single_user = 0
		AND g.group_type <> ". GROUP_HIDDEN ."
		AND ug.group_id = aa.group_id 
		AND g.group_id = aa.group_id 
	GROUP BY g.group_id, g.group_name  
	ORDER BY g.group_id";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
}

while( $row = $db->sql_fetchrow($result) )
{
	$moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
}
	
$l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
$forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];
unset($moderators);

//
// Generate a 'Show topics in previous x days' select box. If the topicsdays var is sent
// then get it's value, find the number of topics with dates newer than it (to properly
// handle pagination) and alter the main query
//
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
$previous_days_text = array($lang['All_Topics'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);

if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) )
{
	$topic_days = ( !empty($HTTP_POST_VARS['topicdays']) ) ? intval($HTTP_POST_VARS['topicdays']) : intval($HTTP_GET_VARS['topicdays']);
	$min_topic_time = time() - ($topic_days * 86400);

	$sql = "SELECT COUNT(t.topic_id) AS forum_topics 
		FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
		WHERE t.forum_id = $forum_id 
			AND p.post_id = t.topic_last_post_id
			AND p.post_time >= $min_topic_time"; 

	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);
	}
	$row = $db->sql_fetchrow($result);

	$topics_count = ( $row['forum_topics'] ) ? $row['forum_topics'] : 1;
	$limit_topics_time = "AND p.post_time >= $min_topic_time";

	if ( !empty($HTTP_POST_VARS['topicdays']) )
	{
		$start = 0;
	}
}
else
{
	$topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;

	$limit_topics_time = '';
	$topic_days = 0;
}

$select_topic_days = '<select name="topicdays">';
for($i = 0; $i < count($previous_days); $i++)
{
	$selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';
	$select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
}
$select_topic_days .= '</select>';


//
// All announcement data, this keeps announcements
// on each viewforum page ...
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id 
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_last_post_id
		AND p.poster_id = u2.user_id
		AND t.topic_type = " . POST_ANNOUNCE . " 
	ORDER BY t.topic_last_post_id DESC ";
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

$topic_rowset = array();
$total_announcements = 0;
while( $row = $db->sql_fetchrow($result) )
{
	$topic_rowset[] = $row;
	$total_announcements++;
}

$db->sql_freeresult($result);

//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_first_post_id
		AND p2.post_id = t.topic_last_post_id
		AND u2.user_id = p2.poster_id 

    AND t.topic_type = " . POST_STICKY . " 

		$limit_topics_time
	ORDER BY t.topic_type DESC, t.topic_last_post_id DESC 
	LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

$total_topics = 0;
while( $row = $db->sql_fetchrow($result) )
{
	$topic_rowset[] = $row;
	$total_topics++;
}

$db->sql_freeresult($result);

// BEGIN Advanced Topic Type MOD

//
// All topic types added
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
  FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
  WHERE t.forum_id = $forum_id
  AND t.topic_poster = u.user_id
  AND p.post_id = t.topic_first_post_id
  AND p2.post_id = t.topic_last_post_id
  AND u2.user_id = p2.poster_id 
  AND t.topic_type > " . POST_GLOBAL_ANNOUNCE . " 
  AND t.topic_type_active = 1
  $limit_topics_time
  ORDER BY t.topic_type DESC, t.topic_last_post_id DESC 
  LIMIT $start, ".$board_config['topics_per_page'];

if ( !($result = $db->sql_query($sql)) )
{
  message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

$total_add_types = 0;
while( $row = $db->sql_fetchrow($result) )
{
  $topic_rowset[] = $row;
  $total_add_types++;
}

$db->sql_freeresult($result);

//
// All normal posts and inactive topic types
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
  FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
  WHERE t.forum_id = $forum_id
  AND t.topic_poster = u.user_id
  AND p.post_id = t.topic_first_post_id
  AND p2.post_id = t.topic_last_post_id
  AND u2.user_id = p2.poster_id 
  AND ( (t.topic_type > ". POST_GLOBAL_ANNOUNCE ." AND t.topic_type_active = 0 ) OR t.topic_type = " . POST_NORMAL . " )
  $limit_topics_time
  ORDER BY t.topic_last_post_id DESC 
  LIMIT $start, ".$board_config['topics_per_page'];

if ( !($result = $db->sql_query($sql)) )
{
  message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

$total_non_active = 0;
while( $row = $db->sql_fetchrow($result) )
{
  $topic_rowset[] = $row;
  $total_non_active++;
}

$db->sql_freeresult($result);
// END Advanced Topic Type MOD


//
// Total topics ...
//
$total_topics += $total_announcements;

// BEGIN Advanced Topic Type MOD
$total_topics += $total_add_types;
$total_topics += $total_non_active;
// END Advanced Topic Type MOD


//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

//
// Post URL generation for templating vars
//
$template->assign_vars(array(
	'L_DISPLAY_TOPICS' => $lang['Display_topics'],

	'U_POST_NEW_TOPIC' => append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"),

	'S_SELECT_TOPIC_DAYS' => $select_topic_days,
	'S_POST_DAYS_ACTION' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&start=$start"))
);

//
// User authorisation levels output
//
$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';
$s_auth_can .= ( $is_auth['auth_ban'] ) ? $lang['Rules_ban_can'] . '<br />' : ''; 
$s_auth_can .= ( $is_auth['auth_greencard'] ) ? $lang['Rules_greencard_can'] . '<br />' : ''; 
$s_auth_can .= ( $is_auth['auth_bluecard'] ) ? $lang['Rules_bluecard_can'] . '<br />' : ''; 


if ( $is_auth['auth_mod'] )
{
	$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&start=" . $start . "&sid=" . $userdata['session_id'] . '">', '</a>');
}

//
// Mozilla navigation bar
//
$nav_links['up'] = array(
	'url' => append_sid('index.'.$phpEx),
	'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
);

//
// Dump out the page header and load viewforum template
//
define('SHOW_ONLINE', true);
$page_title = $lang['View_forum'] . ' - ' . $forum_row['forum_name'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames(array(
	'body' => 'viewforum_body.tpl')
);
make_jumpbox('viewforum.'.$phpEx);

$template->assign_vars(array(
	'FORUM_ID' => $forum_id,
	'FORUM_NAME' => $forum_row['forum_name'],
	'MODERATORS' => $forum_moderators,
	'POST_IMG' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'],

	'FOLDER_IMG' => $images['folder'],
	'FOLDER_NEW_IMG' => $images['folder_new'],
	'FOLDER_HOT_IMG' => $images['folder_hot'],
	'FOLDER_HOT_NEW_IMG' => $images['folder_hot_new'],
	'FOLDER_LOCKED_IMG' => $images['folder_locked'],
	'FOLDER_LOCKED_NEW_IMG' => $images['folder_locked_new'],
	'FOLDER_STICKY_IMG' => $images['folder_sticky'],
	'FOLDER_STICKY_NEW_IMG' => $images['folder_sticky_new'],
	'FOLDER_ANNOUNCE_IMG' => $images['folder_announce'],
	'FOLDER_ANNOUNCE_NEW_IMG' => $images['folder_announce_new'],

	'L_TOPICS' => $lang['Topics'],
	'L_REPLIES' => $lang['Replies'],
	'L_VIEWS' => $lang['Views'],
	'L_POSTS' => $lang['Posts'],
	'L_LASTPOST' => $lang['Last_Post'], 
	'L_MODERATOR' => $l_moderators, 
	'L_MARK_TOPICS_READ' => $lang['Mark_all_topics'], 
	'L_POST_NEW_TOPIC' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'], 
	'L_NO_NEW_POSTS' => $lang['No_new_posts'],
	'L_NEW_POSTS' => $lang['New_posts'],
	'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'], 
	'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'], 
	'L_NO_NEW_POSTS_HOT' => $lang['No_new_posts_hot'],
	'L_NEW_POSTS_HOT' => $lang['New_posts_hot'],
	'L_ANNOUNCEMENT' => $lang['Post_Announcement'], 
	'L_STICKY' => $lang['Post_Sticky'], 
	'L_POSTED' => $lang['Posted'],
	'L_JOINED' => $lang['Joined'],
	'L_AUTHOR' => $lang['Author'],

	'S_AUTH_LIST' => $s_auth_can, 

	'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL ."=$forum_id"),

	'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&mark=topics"))
);
//
// End header
//

//
// Okay, lets dump out the page ...
//

// BEGIN Advanced Topic Type MOD
$sql = "SELECT t.*, t1.topic_type_color AS announce_color, t2.topic_type_color AS sticky_color
  FROM ". TOPIC_ADD_TYPE_TABLE ." t,". TOPIC_ADD_TYPE_TABLE ." t1, ". TOPIC_ADD_TYPE_TABLE ." t2
  WHERE t1.topic_type_name = 'announce'
  AND t2.topic_type_name = 'sticky'";
  
if ( !($result = $db->sql_query($sql)) )
{
  message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
while ($tt_row = $db->sql_fetchrow($result))
{
  $row[] = $tt_row;
  $announce_color = '#'.$tt_row['announce_color'];
  $sticky_color = '#'.$tt_row['sticky_color'];
}
// END Advanced Topic Type MOD

if( $total_topics )
{
	for($i = 0; $i < $total_topics; $i++)
	{
		$topic_id = $topic_rowset[$i]['topic_id'];

		$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];

		$replies = $topic_rowset[$i]['topic_replies'];

		$topic_type = $topic_rowset[$i]['topic_type'];


    // BEGIN Advanced Topic Type MOD
    if( $topic_type == POST_ANNOUNCE )
    {
      $topic_type = '<span style="color:'. $announce_color .'">'. $lang['Topic_Announcement'] . ' </span>';
    }
    else if( $topic_type == POST_STICKY )
    {
      $topic_type = '<span style="color:'. $sticky_color .'">'. $lang['Topic_Sticky'] . ' </span>';
    }
    else if( $topic_type > POST_GLOBAL_ANNOUNCE )
    {
      for($j = 0; $j < count($row); $j++ )
      {
        if( intval($topic_rowset[$i]['topic_type'] - POST_ADD_TYPE) == $row[$j]['topic_type_order'] )
        {
          $topic_type = '<span style="color:#'. $row[$j]['topic_type_color'] .'">'. $row[$j]['topic_type_name'] .':</span> ';      
        }
      }  
    }
    // END Advanced Topic Type MOD

		else
		{
			$topic_type = '';		
		}

		if( $topic_rowset[$i]['topic_vote'] )
		{
			$topic_type .= $lang['Topic_Poll'] . ' ';
		}
		
		if( $topic_rowset[$i]['topic_status'] == TOPIC_MOVED )
		{
			$topic_type = $lang['Topic_Moved'] . ' ';
			$topic_id = $topic_rowset[$i]['topic_moved_id'];

			$folder_image =  $images['folder'];
			$folder_alt = $lang['Topics_Moved'];
			$newest_post_img = '';
		}
		else
		{
			if( $topic_rowset[$i]['topic_type'] == POST_ANNOUNCE )
			{
				$folder = $images['folder_announce'];
				$folder_new = $images['folder_announce_new'];
			}

      // BEGIN Advanced Topic Type MOD
      else if( $topic_rowset[$i]['topic_type'] > POST_ADD_TYPE )
      {
        if( $row[$i]['topic_type_image'] != '' )
        {
          $folder = $row[$i]['topic_type_image'];
          $folder_new = $row[$i]['topic_type_image_new'];
        }
        else
        {  
          $folder = $images['folder_topic_type'];
	  $folder_new = $images['folder_topic_type_new'];
        }
      }
      // END Advanced Topic Type MOD

			else if( $topic_rowset[$i]['topic_type'] == POST_STICKY )
			{
				$folder = $images['folder_sticky'];
				$folder_new = $images['folder_sticky_new'];
			}
			else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
			{
				$folder = $images['folder_locked'];
				$folder_new = $images['folder_locked_new'];
			}
			else
			{
				if($replies >= $board_config['hot_threshold'])
				{
					$folder = $images['folder_hot'];
					$folder_new = $images['folder_hot_new'];
				}
				else
				{
					$folder = $images['folder'];
					$folder_new = $images['folder_new'];
				}
			}

			$newest_post_img = '';
			if( $userdata['session_logged_in'] )
			{
				if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
				{
					if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
					{
						$unread_topics = true;

						if( !empty($tracking_topics[$topic_id]) )
						{
							if( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
							{
								$unread_topics = false;
							}
						}

						if( !empty($tracking_forums[$forum_id]) )
						{
							if( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
							{
								$unread_topics = false;
							}
						}

						if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
						{
							if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >= $topic_rowset[$i]['post_time'] )
							{
								$unread_topics = false;
							}
						}

						if( $unread_topics )
						{
							$folder_image = $folder_new;
							$folder_alt = $lang['New_posts'];

							$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
						}
						else
						{
							$folder_image = $folder;
							$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];

							$newest_post_img = '';
						}
					}
					else
					{
						$folder_image = $folder_new;
						$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];

						$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
					}
				}
				else 
				{
					$folder_image = $folder;
					$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];

					$newest_post_img = '';
				}
			}
			else
			{
				$folder_image = $folder;
				$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];

				$newest_post_img = '';
			}
		}

		if( ( $replies + 1 ) > $board_config['posts_per_page'] )
		{
			$total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
			$goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';

			$times = 1;
			for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
			{
				$goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$j") . '">' . $times . '</a>';
				if( $times == 1 && $total_pages > 4 )
				{
					$goto_page .= ' ... ';
					$times = $total_pages - 3;
					$j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
				}
				else if ( $times < $total_pages )
				{
					$goto_page .= ', ';
				}
				$times++;
			}
			$goto_page .= ' ] ';
		}
		else
		{
			$goto_page = '';
		}
		
		$view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");

		$topic_author = ($topic_rowset[$i]['user_id'] == ANONYMOUS ) ? (($topic_rowset[$i]['post_username'] != '' ) ? $topic_rowset[$i]['post_username'] : $lang['Guest'] ) : color_group_colorize_name($topic_rowset[$i]['user_id']);



		$first_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_time'], $board_config['board_timezone']);

		$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);

		$last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username2'] != '' ) ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '='  . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';

		$last_post_url = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';

		$views = $topic_rowset[$i]['topic_views'];
		
		$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
		$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

		$template->assign_block_vars('topicrow', array(
			'ROW_COLOR' => $row_color,
			'ROW_CLASS' => $row_class,
			'FORUM_ID' => $forum_id,
			'TOPIC_ID' => $topic_id,
			'TOPIC_FOLDER_IMG' => $folder_image, 
			'TOPIC_AUTHOR' => $topic_author, 
			'GOTO_PAGE' => $goto_page,
			'REPLIES' => $replies,
			'NEWEST_POST_IMG' => $newest_post_img, 
			'TOPIC_TITLE' => $topic_title,
			'TOPIC_TYPE' => $topic_type,
			'VIEWS' => $views,
			'FIRST_POST_TIME' => $first_post_time, 
			'LAST_POST_TIME' => $last_post_time, 
			'LAST_POST_AUTHOR' => $last_post_author, 
			'LAST_POST_IMG' => $last_post_url, 

			'L_TOPIC_FOLDER_ALT' => $folder_alt, 

			'U_VIEW_TOPIC' => $view_topic_url)
		);
	}

	$topics_count -= $total_announcements;

	$template->assign_vars(array(
		'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
		'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )), 

		'L_GOTO_PAGE' => $lang['Goto_page'])
	);
}
else
{
	//
	// No topics
	//
	$no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
	$template->assign_vars(array(
		'L_NO_TOPICS' => $no_topics_msg)
	);

	$template->assign_block_vars('switch_no_topics', array() );

}

//
// Parse the page and print
//
$template->pparse('body');

//
// Page footer
//
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Tue Nov 01, 2005 6:10 am

To make this mod phpBB 2.0.18 compatible:

OPEN: posting.php

FIND AND DELETE:

Code: Select all

$topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ) ? $topic_type : POST_NORMAL;
What you say about forum pagination is true. When more than 50 the threats still display on the first screen. The bug is obviously in viewforum.php I will have a look :wink:

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Tue Nov 01, 2005 6:50 am

No, I can't fix the pagination bug :( PLEASE!!!! WE NEED SOME HELP!!! Where is the creator? Can you please help us? I'm sure this is a simple bug, but I dunno :cry:

skinx
Registered User
Posts: 5
Joined: Fri Oct 28, 2005 11:12 am

Post by skinx » Tue Nov 01, 2005 11:48 am

Well peeple i have toyed round a bit with it and it seems to have been solved i lowered the topics on the page till 25 and then it worked correct later on i putted it back to 50 and everything seems fine
maybe the database didnt like the mod @ the first place and after toying with the topic numbers a page in config it catched up
i dunno if its possible but sure works :D

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Tue Nov 01, 2005 4:36 pm

Tha problem is that the Special Topic Types don't count towards the pagination. For example; if you put 50, then you have to reach 51 normal topics to have them separated in two pages. This is not right in my opinion, it's better that Special Topic Types count.

The Bosss
Registered User
Posts: 47
Joined: Sat Apr 30, 2005 9:33 am

Post by The Bosss » Wed Nov 02, 2005 8:40 am

Why can't someone take a look at mine? It shows 22 and 23 instead of "Exclusive" and "Confirmed:"?

www.mgsworld.org/forums
www.mgsworld.org is soon up again! ;)

mjm1905
Registered User
Posts: 59
Joined: Fri Dec 12, 2003 1:51 am
Location: New Jersey
Contact:

Real Mess

Post by mjm1905 » Wed Nov 02, 2005 6:01 pm

I am getting a number of errors. Trying to undo the mod now.

When posting, PHPbb enters debug mode. From the error message, I think the problem is nested within:

Code: Select all

#-----[ IN-LINE FIND ]----------------------------------------------
#

topic_type = $topic_type

#
#-----[ IN-LINE AFTER, ADD ]----------------------------------------------
#

 $topic_type_active    
But I can't figure why.

I've read several other posts regarding this, but I am not grasping the fix. I do like the idea though.

// edit:

I got everything back to normal. I appreciate sharing the MOD. I will try it again another time. It's really a nice touch to a forum, for increased clarification purpose.
Michael J Medeiros

It's not a choice, it's a child.

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Sat Nov 05, 2005 10:43 pm

I made this mod phpBB 2.018 compatible. Enjoy :wink:

Code: Select all

OPEN: posting.php
FIND: $topic_type = ( !empty($HTTP_POST_VARS['topictype']) ) ? intval($HTTP_POST_VARS['topictype']) : POST_NORMAL;
AFTER, ADD: $topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE, POST_ADD_TYPE)) ) ? $topic_type : POST_NORMAL;
PS: Do not add the normal line when upgrading to 2.0.18, add the one I put there. If have a fresh installation, then, replace.

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Mon Nov 07, 2005 8:23 pm

I don't know what to say about the pagination. It's now working on my forum. The only kind of topics that do not count towards the pagination are the Sticky (and maybe the Announcements but I'm not sure).

About my last fix; I decided to delete that line because I think it's not really important and didn't allow me to add a new type of topic. Maybe we can define a new constant to include all the special type of posts in the in_array but I won't do that a the moment. If you put POST_ADD_TYPE you are not including all of them and some transform into POST_NORMAL.

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Mon Nov 07, 2005 11:45 pm

martin_uy wrote: This mod is excellent :P

I fix some bugs. If you installed this mod and the code the creator posted in this threat to allow different images for different skins then you should correct in viewforum.php the following:

Code: Select all

$sql = "SELECT t.*, t1.topic_type_color AS announce_color, t2.topic_type_color AS sticky_color, th.template_name AS template_name
  FROM ". TOPIC_ADD_TYPE_TABLE ." t,". TOPIC_ADD_TYPE_TABLE ." t1, ". TOPIC_ADD_TYPE_TABLE ." t2, ". THEMES_TABLE ." th
  WHERE t1.topic_type_name = 'announce'
  AND t2.topic_type_name = 'sticky'
AND th.themes_id = ". ( ( $board_config['override_user_style'] ) ? $board_config['default_style'] : $userdata['user_style']  );
MUST BE:

Code: Select all

$sql = "SELECT t.*, t1.topic_type_color AS announce_color, t2.topic_type_color AS sticky_color, th.template_name AS template_name
  FROM ". TOPIC_ADD_TYPE_TABLE ." t,". TOPIC_ADD_TYPE_TABLE ." t1, ". TOPIC_ADD_TYPE_TABLE ." t2, ". THEMES_TABLE ." th
  WHERE t1.topic_type_name = 'announce'
  AND t2.topic_type_name = 'sticky'
AND th.themes_id = '". ( ( $board_config['override_user_style'] ) ? $userdata['user_style'] : $board_config['default_style'] )."' ";
Thanks, hope this can help you!.
If any doubt please PM me.

This fix I made solves a problem but make another. I recently realised about that and made another different fix:

Code: Select all

OPEN: viewforum.php

FIND: 

$sql = "SELECT t.*, t1.topic_type_color AS announce_color, t2.topic_type_color AS sticky_color, th.template_name AS template_name

BEFORE, ADD: 

if ( !$userdata['session_logged_in'] = TRUE )
	{
	$temas = ( $board_config['override_user_style'] )  ? $board_config['default_style'] : $userdata['user_style'] ;
	}
	else
	{
	$temas = $board_config['default_style'] ;
	}

FIND: 

AND th.themes_id = '". ( ( $board_config['override_user_style'] ) ? $userdata['user_style'] : $board_config['default_style'] )."' ";

REPLACE WITH:

AND th.themes_id = '".$temas."'";
Enjoy :wink:

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Wed Nov 09, 2005 6:27 am

martin_uy wrote: I made this mod phpBB 2.018 compatible. Enjoy :wink:

Code: Select all

OPEN: posting.php
FIND: $topic_type = ( !empty($HTTP_POST_VARS['topictype']) ) ? intval($HTTP_POST_VARS['topictype']) : POST_NORMAL;
AFTER, ADD: $topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE, POST_ADD_TYPE)) ) ? $topic_type : POST_NORMAL;
PS: Do not add the normal line when upgrading to 2.0.18, add the one I put there. If have a fresh installation, then, replace.

Me again with a solution for this problem. The fix I put above is not correct at all because POST_ADD_TYPE is constant = 20 and 20 is only the first Topic Type. So, this is not valid for the others topic types (which grow from one to one. For example: your first topic type is 20, the second is 21, the third is 22, etc.) and they get converted into Normal posts. The code added for the upgrade to 2.0.18 validates the input, so, if it's not one of the types recognized it automatically converts into a Normal Topic.

The fix quoted won't work if you have more than one Topic Type.

What to do then?

Well, I solved this problem correctly but manually. This means that you can leave the string this way:

Code: Select all

$topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE, 20 )) ) ? $topic_type : POST_NORMAL;
but remember to add the Topic Type number to this string each time you create a new topic type.

For example; if you want to add two topics types you will have to edit on posting.php and replace the string we are talking about with this one:

Code: Select all

$topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE, 20, 21 )) ) ? $topic_type : POST_NORMAL;
That's the only way I know how to solve this. I'm pretty sure there is another 'automatic' way; but don't worry the manual way works as it's supposed to work and have no security holes/bugs if you keep it updated with the number of the topic types you have :wink:

It's not such an important instruction in my opinion; so you can remove it at all. If you decide to update it manually, as I explained, and you would like to delete a topic type you should search the number for that topic type and delete it from the string.

IE: I would like to delete the "Special Topic Type". I search in the DB and found that the "Special Topic Type" is 21. Then I open posting.php and I modify this way:

Code: Select all

$topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE, 20)) ) ? $topic_type : POST_NORMAL;
Thanks and enjoy, Martin.
PS: I'm not modifying topic types too much, so I will update it manually when I need (it's not much work, come on!!!). Well, If any news about how to do this automatically I keep you updated :lol:

igami
Registered User
Posts: 79
Joined: Fri Jun 17, 2005 6:49 pm

Post by igami » Sat Nov 26, 2005 1:31 am

Does the mod offered for download in post 1 of this thread work with 2.018 or not?

igami
Registered User
Posts: 79
Joined: Fri Jun 17, 2005 6:49 pm

Post by igami » Sat Nov 26, 2005 3:11 am

Nope :cry:

Everything seemed to go smoothly, but when I viewforum it does not display the new type name or image.

Code: Select all

<span class="topictitle"><span style="color:#">:</span> 
Its leaving it blank - beats me!

martin_uy
Registered User
Posts: 46
Joined: Sun Oct 16, 2005 5:52 pm
Contact:

Post by martin_uy » Sat Nov 26, 2005 4:17 am

igami wrote: Does the mod offered for download in post 1 of this thread work with 2.018 or not?
Nop, I fixed this problem adding some code. There is one line in posting.php which validates the input and it's incompatible. Look at my posts in this threat. There is one possible solution posted, another solution is going to be remove that line (it's not neccesary) and there is one more which I haven't posted yet. The last is the BEST and valid one. I'm waiting for permission from the original author to release a newer version of this mod with this and other fix.

Thanks, Martin.

Tip: Look at this addon I released: http://www.phpbb.com/phpBB/viewtopic.ph ... highlight=

Post Reply

Return to “[2.0.x] MODs in Development”