################################################################################
##   MOD Title:		External Forum Redirect
##   MOD Version:		2.0.0.2
##   MOD Author:		John McKernan 
## 	 MOD Co-Author:		Nightrider.  Converted this file to be EasyMod friendly
##   MOD Description:	This hack allows you to specify a forum as an external
##						forum. When the user clicks on the Forum name (on the 
##						index page) they will be taken to an external url you
##						specify in the Admin Control Panel.
##
##						Seperate counters are maintained to track the number
##						of users and guests clicking the links. This is 
##						displayed on the index page.
##
##						The external url may, optionally, be open in a new
##						browser window, and you can specify a custom folder 
##						image for each external forum.
##
##						Useful to direct users to other boards / sites you may
##						have, or to set-up cross-linking arrangements with
##						outside boards / sites.
##
##   phpBB Version:		2.0.4 - 2.0.6
##		
##   Difficulty Level:	Moderate 
##   Installation Time:	25 Minutes ~1 Minute using EasyMod
##
##   Files To Edit:		7
##						index.php
##						admin/admin_forums.php
##						language/lang_english/lang_admin.php
##						language/lang_english/lang_main.php
##						templates/subSilver/index_body.tpl
##						templates/subSilver/subSilver.cfg
##						templates/subSilver/admin\forum_edit_body.tpl
##
##   Files Included:	3
##						install_hack.php
##						view_external.php
##						templates/subSilver/images/folder_external.gif
##
##   Release History:
##	 		 		 	2.0.0.1 - converted to EasyMod Friendly format...										
##						2.0.0 - added option to open external link in a new
##								window & specify a custom folder image
##								(Nov 24, 2003)
##						1.0.1 - corrected typo in 'Find' instruction for
##								index.php - thanks to Rapid Dr3am (Sep 7, 2003)
##						1.0.0 - Initial release (Sep 1, 2003)
##
################################################################################
##
##  FOR UPDATES/SUPPORT, please visit http://www.phpbbhacks.com/forums
##
##  Stay up-to-date on the latest news involving our hacks, sign-up for
##  our newsletter at http://wwww.presagemedia.com/lists/?p=subscribe
##
##  This author supports phpBBHacks.com. This hack is made available
##  solely through their database at http://www.phpbbhacks.com
##
##  If you are new to installing hacks for phpBB, may I suggest that you take
##  a look at my 'Installing phpBB Hacks' tutorial at phpBBHacks.com. You can
##  find it here: http://www.phpbbhacks.com/forums/viewtopic.php?t=12211. You
##  may also find my other tutorials helpful, please visit 
##  http://www.presagemedia.com/hacks/cms_articles.php
##
################################################################################
##
##  This hack is released under the GPL License.
##  All Intellectual Property Rights are retained by the hack author(s) 
##  shown above.
##
##  This hack can be freely used, but not distributed, without permission.
##
################################################################################
## Author Notes: 
## 
##     This hack has been tested on phpBB v 2.0.4 & 2.0.6
## 
##
##----------[ POST-INSTALLATION ]------------------------
##
##  Using your browser, navigate to the following file. Once the file has been
##  successfully run, please be sure to immediately delete this file from your
##  server.
##
##  install_hack.php
## 
##	You've completed all steps necessary to install this hack. Now go to your
##	Admin Control Panel and create a new forum or edit an existing forum, and set
## 	the 'External Site', 'External URL', 'Launch in new window' and 'Custom image' settings appropriately to specify the forum as an external link.
## 
## 	To specify a custom image for any external forum, enter the complete url
##	to the desired image. If you leave this blank, the default external forum
##	image will be used.
##
################################################################################
##
##  BEFORE ADDING THIS HACK TO YOUR FORUM, please be sure to backup ALL
##  affected files.
##
################################################################################
## IMPORTANT: FULL INSTALLATION.
## 
##     These instructions should only be followed if you have not already
##	   installed the 'External Forum Redirect' hack versions 1.0.0 or 1.0.1.
##
##     If you have installed an earlier version of this hack, please
##     disregard these instructions and follow the instructions in the
##     'Upgrade_from_v1.txt' file instead.
## 
################################################################################
#
#----------[ COPY ]-------------------------------
#
copy folder_icons/north_south_america/folder_external.gif to templates/subSilver/images/folder_external.gif
copy phpBB_root/view_external.php to view_external.php
copy phpBB_root/install_hack.php to install_hack.php

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

#
#----------[ FIND ]-------------------------------------
#
							$template->assign_block_vars('catrow.forumrow',	array(

#
#----------[ BEFORE, ADD ]------------------------------
#

							$forum_target = '';

							if ($forum_data[$j]['forum_external'])
							{
								$forum_url = append_sid("view_external.$phpEx?" . POST_FORUM_URL . "=$forum_id");

								$member_hits = $forum_data[$j]['forum_redirects_user'];
								$guest_hits = $forum_data[$j]['forum_redirects_guest'];
								$all_hits = ($member_hits + $guest_hits);

								$forum_details = $lang['External_text'] . '<b>' . $all_hits . '</b>';

								$forum_details .= ( $all_hits == 1 ) ? $lang['External_hit'] : $lang['External_hits'];
								
								$forum_details .= '<br />(' . $lang['External_members'] . ': <b>' . $member_hits . '</b>&nbsp;&middot;&nbsp;' . $lang['External_guests'] . ': <b>' . $guest_hits . '</b>)';

								$folder_image = ($forum_data[$j]['forum_ext_image']) ?  $forum_data[$j]['forum_ext_image'] : $images['forum_external'];

								$forum_posts = '--';
								$forum_topics = '--';

								$forum_target = ($forum_data[$j]['forum_ext_newwin']) ? 'target="_external"' : '';
							}
							else 
							{	
								$forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");

								$forum_posts = $forum_data[$j]['forum_posts'];
								$forum_topics = $forum_data[$j]['forum_topics'];
								$forum_details = $last_post;
							}

#
#----------[ FIND ]-------------------------------------
#

								'POSTS' => $forum_data[$j]['forum_posts'],
								'TOPICS' => $forum_data[$j]['forum_topics'],

#
#----------[ REPLACE WITH ]-----------------------------
#

								'POSTS' => $forum_posts,
								'TOPICS' => $forum_topics,

#
#----------[ FIND ]-------------------------------------
#

								'LAST_POST' => $last_post,

#
#----------[ REPLACE WITH ]-----------------------------
#

								'LAST_POST' => $forum_details,
								'TARGET' => $forum_target,

#
#----------[ FIND ]-------------------------------------
#

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

#
#----------[ REPLACE WITH ]-----------------------------
#

								'U_VIEWFORUM' => $forum_url)

#
#----------[ OPEN ]-------------------------------------
#

admin/admin_forums.php

#
#----------[ FIND ]-------------------------------------
#

				$forumstatus = $row['forum_status'];

#
#----------[ AFTER, ADD ]-------------------------------
#

				$forum_external = $row['forum_external'];
				$forum_redirect_url = $row['forum_redirect_url'];
				$forum_ext_newwin = $row['forum_ext_newwin'];
				$forum_ext_image = $row['forum_ext_image'];

#
#----------[ FIND ]-------------------------------------
#
#				$forumstatus = FORUM_UNLOCKED;
				$forum_id = ''; 
				$prune_enabled = '';

#
#----------[ AFTER, ADD ]-------------------------------
#

				$forum_external = '0';
				$forum_redirect_url = '';
				$forum_ext_newwin = '0';
				$forum_ext_image = '';

#
#----------[ FIND ]-------------------------------------
#

				'L_DAYS' => $lang['Days'],

#
#----------[ AFTER, ADD ]-------------------------------
#

				'FORUM_EXTERNAL_YES' => ($forum_external) ? 'checked="checked"' : '',
				'FORUM_EXTERNAL_NO' => (!$forum_external) ? 'checked="checked"' : '',
				'FORUM_REDIRECT_URL' => $forum_redirect_url,
				'FORUM_EXT_NEWWIN_YES' => ($forum_ext_newwin) ? 'checked="checked"' : '',
				'FORUM_EXT_NEWWIN_NO' => (!$forum_ext_newwin) ? 'checked="checked"' : '',
				'FORUM_EXT_IMAGE' => $forum_ext_image,
				'L_FORUM_EXT_NEWWIN' => $lang['Forum_ext_newwin'],
				'L_FORUM_EXT_IMAGE' => $lang['Forum_ext_image'],
				'L_FORUM_EXTERNAL' => $lang['Forum_external'],
				'L_FORUM_REDIRECT_URL' => $lang['Forum_redirect_url'],
				'L_NO' => $lang['No'],
				'L_YES' => $lang['Yes'],

#
#----------[ FIND ]-------------------------------------
#
#  There is more to this piece of code than what is
#  shown here. This excerpt is shown since many hacks
#  alter this code, and so yours may be different than
#  the default code. This portion should remain constant.
#

			// There is no problem having duplicate forum names so we won't check for it.
			$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id,

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

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

, forum_external, forum_redirect_url, forum_ext_newwin, forum_ext_image

#
#----------[ FIND ]-------------------------------------
#
" . intval($HTTP_POST_VARS['forumstatus']) . "

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

" . intval($HTTP_POST_VARS['forumstatus']) . "

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

, " . intval($HTTP_POST_VARS['forum_external']) . ", '" . $HTTP_POST_VARS['forum_redirect_url'] . "', " . intval($HTTP_POST_VARS['forum_ext_newwin']) . ", '" . $HTTP_POST_VARS['forum_ext_image'] . "'

#
#----------[ FIND ]-------------------------------------
#
#  There is more to this piece of code than what is
#  shown here. This excerpt is shown since many hacks
#  alter this code, and so yours may be different than
#  the default code. This portion should remain constant.
#
#			$sql = "UPDATE " . FORUMS_TABLE . "
forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . "

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

forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . "

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

, forum_external = " . intval($HTTP_POST_VARS['forum_external']) . ", forum_redirect_url = '" . str_replace("\'", "''", $HTTP_POST_VARS['forum_redirect_url']) . "', forum_ext_newwin = " . intval($HTTP_POST_VARS['forum_ext_newwin']) . ", forum_ext_image = '" . str_replace("\'", "''", $HTTP_POST_VARS['forum_ext_image']) . "'

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

#
#----------[ FIND ]-------------------------------------
#
//
// That
// -------------------------------------------------

#
#----------[ BEFORE, ADD ]------------------------------
#

// external forum redirect
$lang['Forum_external'] = 'External Site';
$lang['Forum_redirect_url'] = 'External URL';
$lang['Forum_ext_newwin'] = 'Launch external site in new window';
$lang['Forum_ext_image'] = 'Custom folder image for external site';

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

#
#----------[ FIND ]-------------------------------------
#

//
// That
// -------------------------------------------------

#
#----------[ BEFORE, ADD ]------------------------------
#

// External forum redirection
$lang['External_text'] = 'This link has been visited ';
$lang['External_hit'] = ' time.';
$lang['External_hits'] = ' times.';
$lang['External_members'] = 'Users';
$lang['External_guests'] = 'Guests';

#
#----------[ OPEN ]-------------------------------------
#
templates/subSilver/subSilver.cfg

#
#----------[ FIND ]-------------------------------------
#

$images['forum_locked'] = "$current_template_images/folder_locked_big.gif";

#
#----------[ AFTER, ADD ]-------------------------------
#

$images['forum_external'] = "$current_template_images/folder_external.gif";


#
#----------[ OPEN ]-------------------------------------
#
templates/subSilver/admin/forum_edit_body.tpl

#
#----------[ FIND ]-------------------------------------
#

	<tr> 
	  <td class="row1">{L_FORUM_STATUS}</td>
	  <td class="row2"><select name="forumstatus">{S_STATUS_LIST}</select></td>
	</tr>

#
#----------[ AFTER, ADD ]-------------------------------
#

	<tr> 
	  <td class="row1">{L_FORUM_EXTERNAL}</td>
	  <td class="row2"> 
		<input type="radio" name="forum_external" value="1" {FORUM_EXTERNAL_YES} />
		<span class="gen">{L_YES}</span>&nbsp;&nbsp; 
		<input type="radio" name="forum_external" value="0" {FORUM_EXTERNAL_NO} />
		<span class="gen">{L_NO}</span></td>
	</tr>
	<tr> 
	  <td class="row1">{L_FORUM_REDIRECT_URL}</td>
	  <td class="row2"><input class="post" type="text" name="forum_redirect_url" value="{FORUM_REDIRECT_URL}" size="60" class="post" /></td>
	</tr>
	<tr> 
	  <td class="row1">{L_FORUM_EXT_NEWWIN}</td>
	  <td class="row2"> 
		<input type="radio" name="forum_ext_newwin" value="1" {FORUM_EXT_NEWWIN_YES} />
		<span class="gen">{L_YES}</span>&nbsp;&nbsp; 
		<input type="radio" name="forum_ext_newwin" value="0" {FORUM_EXT_NEWWIN_NO} />
		<span class="gen">{L_NO}</span></td>
	</tr>
	<tr> 
	  <td class="row1">{L_FORUM_EXT_IMAGE}</td>
	  <td class="row2"><input class="post" type="text" name="forum_ext_image" value="{FORUM_EXT_IMAGE}" size="60" class="post" /></td>
	</tr>

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

#
#----------[ FIND ]-------------------------------------
#
<a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">

#
#----------[ IN-LINE FIND ]------------------------------
#
<a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">

#
#----------[ IN-LINE REPLACE WITH ]-----------------------------
#
<a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink" {catrow.forumrow.TARGET}>

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