##############################################################
## MOD Title:		Update Forumtitle as Weblink
## MOD Author: OXPUS < webmaster@oxpus.de > (Karsten Ude) http://www.oxpus.de
## MOD Description:	Update from 1.1.2 to 1.2.0
## MOD Version:		1.0.0
##
## Installation Level:	Easy
## Installation Time:	3-5 Minutes
## Files To Edit:	6
##			index.php
##			language/lang_english/lang_main.php
##			language/lang_german/lang_main.php
##			templates/subSilver/index_body.tpl
##
## Included Files:	n/a
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
## Instead entering the given SQL-Statement, you can upload the file db_update_1_2_0.php
## to your phpbb root directory and run this with your browser.
## This file will do all nessassary changes in the database for you.
## After using this file, please delete it to avoid errors.
##
## If you have installed the Categories Hierarchy Mod, don't install this mod, too!
## Creating a forum as a weblink is possible with the Categories Hierarchy Mod!
##
##############################################################
## MOD History:
##
##   2004-08-16 - Version 1.0.0
##      - First release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL ]------------------------------------------
#
ALTER TABLE `phpbb_forums` ADD COLUMN `forum_link_count` MEDIUMINT(8) UNSIGNED NOT NULL;

#
#-----[ OPEN ]------------------------------------------
#
index.php

#
#-----[ FIND ]------------------------------------------
#
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------------
#
$forum_id = ( isset($HTTP_POST_VARS[POST_FORUM_URL]) ) ? intval($HTTP_POST_VARS[POST_FORUM_URL])) : intval($HTTP_GET_VARS[POST_FORUM_URL]));
$forum_link = ( isset($HTTP_POST_VARS['forum_link']) ) ? intval($HTTP_POST_VARS['forum_link'])) : intval($HTTP_GET_VARS['forum_link']));

if ( $forum_link == 1 && $forum_id != 0 )
{
	$sql = "UPDATE " . FORUMS_TABLE . "
		SET forum_link_count = forum_link_count + 1
		WHERE forum_id = $forum_id";
	if ( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not update link counter', '', __LINE__, __FILE__, $sql);
	}

	$sql = "SELECT weblink FROM " . FORUMS_TABLE . "
		WHERE forum_id = $forum_id";
	if ( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not update link counter', '', __LINE__, __FILE__, $sql);
	}

	while ( $row = $db->sql_fetchrow($result) )
	{
		$forum_weblink = $row['weblink'];
	}

	header("Location: ".$forum_weblink);
	exit;
}

#
#-----[ FIND ]------------------------------------------
#
								'FORUM_FOLDER_IMG' => ( $forum_data[$j]['title_is_link'] == 1 && $forum_data[$j]['forum_link_icon'] != '' ) ? $forum_data[$j]['forum_link_icon'] : $folder_image,

#
#-----[ AFTER, ADD ]------------------------------------------
#
								'FORUM_LINK_COUNT' => ( $forum_data[$j]['title_is_link'] == 1 ) ? sprintf($lang['Forum_link_count'], $forum_data[$j]['forum_link_count']) : '',

#
#-----[ FIND ]------------------------------------------
#
								'U_VIEWFORUM' => ( $forum_data[$j]['title_is_link'] == 1 ) ? $forum_data[$j]['weblink'] : append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
							);

#
#-----[ REPLACE WITH ]------------------------------------------
#
								'U_VIEWFORUM' => ( $forum_data[$j]['title_is_link'] == 1 ) ? append_sid("index.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;forum_link=1") : append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"))
							);

							if ( $forum_data[$j]['title_is_link'] == 1 )
							{
								$template->assign_block_vars('switch_forum_link_on', array());
							}
							else
							{
								$template->assign_block_vars('switch_forum_link_off', array());
							}

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------
#
?>

#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Forum_link_count'] = 'Link was visited %s times.';

#
#-----[ OPEN ]------------------------------------------
#
language/lang_german/lang_main.php

#
#-----[ FIND ]------------------------------------------
#
?>

#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['Forum_link_count'] = 'Link wurde %s mal besucht.';

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl

#
#-----[ FIND ]------------------------------------------
#
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOPICS}</span></td>
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.POSTS}</span></td>
	<td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>

#
#-----[ REPLACE WITH ]------------------------------------------
#
<!-- BEGIN switch_forum_link_off -->
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOPICS}</span></td>
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.POSTS}</span></td>
	<td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>
<!-- END switch_forum_link_off -->
<!-- BEGIN switch_forum_link_on -->
	<td class="row2" align="center" valign="middle" height="50" colspan="3"><span class="gensmall">{catrow.forumrow.FORUM_LINK_COUNT}</span></td>
<!-- END switch_forum_link_on -->


#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM