############################################################## 
## MOD Title: Online/Offline Indicator
## MOD Author: romans1423 < romans1423@hotmail.com > (Rick Beckman) www.beckman-ministries.com Adapter for torrentpier 775 by Paskal
## MOD Description: This MOD outputs graphically a user's online status in Topics and the Memberlist.
## MOD Version: 1.3.3 Adapted for TorrentPier II by InKomen
## 
## Installation Level: easy
## Installation Time: 5 Minutes 
## Files To Edit: viewtopic.php
##		  memberlist.php
##		  includes/page_header.php
##		  templates/default/viewtopic.tpl 
##		  templates/default/memberlist.tpl
##		  templates/default/tpl_config.php
##		  language/lang_russian/lang_main.php
## Included Files: icon_online.gif
##		   icon_offline.gif
##		   icon-hidden.gif
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/phpBB/catdb.php?db=1 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/phpBB/catdb.php?db=1
############################################################## 
## Author Notes: 
## 	This MOD is based upon Online/Offline 1.0.0 by John B. Abela (abela@phpbb.com), stitch626,
##	and an unknown author. Lots of thanks!
##	The Online, Offline, and Hidden icons are from www.forumimages.com and were created
##	by Daz. Thanks for the wonderful images.
##	Additional images for various themes can be found at http://www.forumimages.com/.
##
##	Upgrading should be pretty self-explanatory, so no upgrade path is provided.
##
##To Do:
##	- UserGroup member lists support.
##	- Profile support.
##	- Support for both graphical & text output. Thanks to Daz for indirectly making me think of this one.
##	- Suggestions => romans1423@hotmail.com
############################################################## 
## MOD History: 
##
## 1.3.3 - Adapted for TorrentPier II by InKomen 
## 1.3.2 - Fixed some typos in this install file. Oops!
## 1.3.1 - Fixed another typo in the install file; the "copy" commands at the bottom had
##	   a discrepancy in file names which is now fixed.
## 1.3.0 - Added online/offline indicators for Memberlist.
##	 - Name changed to "Online/Offline Indicator"
## 1.2.1 - Fixed a typo in the install file (this file); the "files to edit" list was incomplete.
## 	     There is no need to update any of your files.
## 1.2.0 - Removed textual variant (i.e., "Online" or "Offline" instead of using images.)
##	 - Added support for Hidden users
##	 - Included status icons from www.forumimages.com.
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

#
#-----[ SQL ]-------------------------------------------
#
# Remember to change the table prefix used on your database

ALTER TABLE `bb_users` ADD `user_timer` INT( 11 ) NOT NULL AFTER `user_session_time`;
ALTER TABLE `bb_users` ADD `user_allow_viewonline` tinyint(1) NOT NULL default '1';

# 
#-----[ OPEN ]------------------------------------------ 
# 
viewtopic.php

# 
#-----[ FIND ]------------------------------------------ 
# 
$sql = "
	SELECT
	  u.username, u.user_id,

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

 u.user_timer, u.user_allow_viewonline, 

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

	$template->assign_block_vars('postrow', array(

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

	//Online/Offline
	if (($postrow[$i]['user_timer'] >= ( time() - 300 )) && ($postrow[$i]['user_allow_viewonline']))
	{
		$on_off_hidden = '<img src="' . $images['icon_online'] . '" alt="' . $lang['Online'] . '" title="' . $lang['Online'] . '" border="0" />';
	}
	else if ($postrow[$i]['user_allow_viewonline'] == 0)
	{
		$on_off_hidden = '<img src="' . $images['icon_hidden'] . '" alt="' . $lang['Hidden'] . '" title="' . $lang['Hidden'] . '" border="0" />';
	}
	else if ($poster_id == ANONYMOUS)
	{
		$on_off_hidden = '';
	}
	else
	{
		$on_off_hidden = '<img src="' . $images['icon_offline'] . '" alt="' . $lang['Offline'] . '" title="' . $lang['Offline'] . '" border="0" />';
	}

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

		'POSTER_AVATAR' => $poster_avatar,

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

		'POSTER_ONLINE' => $on_off_hidden,

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

memberlist.php

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

	'PAGE_TITLE' => $lang['MEMBERLIST'],

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

	'L_ON_OFF_STATUS' => $lang['On_off_status'],

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

// per-letter selection end

$sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email

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

, user_allow_viewonline, user_timer

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

		$template->assign_block_vars('memberrow', array(

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

		//Online/Offline
		if (($row['user_timer'] >= ( time() - 300 )) && ($row['user_allow_viewonline']))
		{
			$on_off_hidden = '<img src="' . $images['icon_online'] . '" alt="' . $lang['Online'] . '" title="' . $lang['Online'] . '" border="0" />';
		}
		else if ($row['user_allow_viewonline'] == 0)
		{
			$on_off_hidden = '<img src="' . $images['icon_hidden'] . '" alt="' . $lang['Hidden'] . '" title="' . $lang['Hidden'] . '" border="0" />';
		}
		else
		{
			$on_off_hidden = '<img src="' . $images['icon_offline'] . '" alt="' . $lang['Offline'] . '" title="' . $lang['Offline'] . '" border="0" />';
		}

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

			'PM' => $pm,

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

			'USER_ONLINE' => $on_off_hidden,


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

includes/page_header.php

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

$in_out = ($logged_in) ? 'in' : 'out';
$template->assign_block_vars("switch_user_logged_{$in_out}", array());

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

if ($userdata['user_id'] > -1)
{
      $timer = time();
      $sql = "UPDATE ". BB_USERS ." SET user_timer = '$timer' WHERE user_id = " . intval($userdata['user_id']);

      if ( !($result = DB()->sql_query($sql)) )
      {
            message_die(GENERAL_ERROR, 'Could not update users table', '', __LINE__, __FILE__, $sql);
      }
}


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

language/lang_russian/lang_main.php

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

//
// Viewonline
//

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

//
// Online/Offline
//
$lang['Offline'] = ' ';
$lang['Online'] = ' ';
$lang['Hidden'] = '';
$lang['On_off_status'] = '';

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

templates/default/tpl_config.php

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

$images['progress_bar_full']	 = $_main .'progress_bar_full.gif';

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

$images['icon_online']		 = $_lang .'icon_online.gif';
$images['icon_offline'] 	 = $_lang .'icon_offline.gif';
$images['icon_hidden'] 		 = $_lang .'icon_hidden.gif';

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

templates/default/viewtopic.tpl

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

<a class="txtb" href="{PROFILE_URL}{postrow.POSTER_ID}">{PROFILE_IMG}</a>{POST_BTN_SPACER}

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

{postrow.POSTER_ONLINE}

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

templates/default/memberlist.tpl

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

	<th class="{sorter: 'text'}" ><b class="tbs-text">{L_USERNAME}</b></th>

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

	<th class="{sorter: 'text'}" ><b class="tbs-text">{L_ON_OFF_STATUS}</b></th>

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

	<td><b>{memberrow.USER}</b></td>

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

	<td>{memberrow.USER_ONLINE}</td>

# 
#-----[ COPY ]------------------------------------------ 
#

copy templates/default/images/lang_russian/icon_online.gif to templates/default/images/lang_russian/icon_online.gif
copy templates/default/images/lang_russian/icon_offline.gif to templates/default/images/lang_russian/icon_offline.gif
copy templates/default/images/lang_russian/icon_hidden.gif to templates/default/images/lang_russian/icon_hidden.gif

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