################################################################################### 
## 
## Hack Title:   Add new field to profile (bbcode, smilees, html usage possible)
## Hack Version: 1.0.1 (ex phpBB 2.0.4)
## Author        Acid
## Support:	 http://www.phpbbhacks.com/
##
## Description:  Just a simple way to add a new field to profile. "infos" can be
##		 changed to "whatever" of course but be aware of the spelling (e.g.
##		 "INFOS", "infos", "user_infos").
##		 If you want to add more than one field duplicate the following
##		 steps and change "infos" (be aware of the spelling).	 
##		 It supports bbcode, html and smilees.
##
## Files to edit:	8
##			admin/admin_users.php
##	                language/lang_english/lang_main.php
##              	includes/usercp_viewprofile.php 
##	                includes/usercp_register.php
##      	        includes/usercp_avatar.php 
##              	templates/xxx/admin/user_edit_body.tpl
## 	                templates/xxx/profile_add_body.tpl 
##      	        templates/xxx/profile_view_body.tpl 
## 
################################################################################### 
## 
## Installation/Author Notes: 
## First always make a backup from the files that you're going to edit. 
## 
## This hack adds two new fields to your 'user' table. 
##
################################################################################### 
## 
## Revision History:
## 
## v1.0.1
##	- added HTML-Status to profile_add_body.tpl/user_edit_body.tpl
##	- bbcode will be parsed in admin part now
## v1.0.0
##	- Initial Release
## 
##########################################################################################
#
#-----[ SQL ]-------------------------------------------
#  
# You may have to change your database prefix.

ALTER TABLE phpbb_users ADD user_infos TEXT;
ALTER TABLE phpbb_users ADD user_infos_bbcode_uid VARCHAR (255);

## alternate you can use table_update.php to alter the database automatically
## (just upload and run the file)


# 
#-----[ OPEN ]------------------------------------------ 
#  
# language/lang_english/lang_main.php
# 
#-----[ FIND ]---------------------------------------------------
# 
$lang['Signature_explain'] = 'This is a block of text that can be added to posts you make. There is a %d character limit';

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
$lang['Infos'] = 'Infos';
$lang['Infos_explain'] = 'This is a block of text that will be displayed in your profile.';



# 
#-----[ OPEN ]------------------------------------------ 
#  
# includes/usercp_viewprofile.php
# 
#-----[ FIND ]---------------------------------------------------
# 
$page_title = $lang['Viewing_profile'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
$infos = (  $profiledata['user_infos'] != '' ) ? $profiledata['user_infos'] : '';
$infos_bbcode_uid = $profiledata['user_infos_bbcode_uid'];
if ( $board_config['allow_bbcode'] )
{
        if ( $infos != '' && $infos_bbcode_uid != '' )
        {
                $infos = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($infos, $infos_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $infos);
        }
}
if ( $infos != '' )
{
        $infos = make_clickable($infos);
}
if ( $board_config['allow_smilies'] )
{
        if ( $profiledata['user_allowsmile'] && $infos != '' )
        {
                $infos = smilies_pass($infos);
        }
}
if ( $infos != '' )
{
        $infos = str_replace("\n", "\n<br />\n", $infos);
}

# 
#-----[ FIND ]---------------------------------------------------
# 
	'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : '&nbsp;',

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	'INFOS' => $infos,

# 
#-----[ FIND ]---------------------------------------------------
# 
	'L_INTERESTS' => $lang['Interests'],

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	'L_INFOS' => $lang['Infos'],



# 
#-----[ OPEN ]------------------------------------------ 
#  
# includes/usercp_register.php
# 
#-----[ FIND (2 times) ]---------------------------------------------------
# 
		$interests = stripslashes($interests);

# 
#-----[ BELOW ADD (2 times) ]---------------------------------------------------
# 
		$infos = stripslashes($infos);

# 
#-----[ FIND ]---------------------------------------------------
# 
		$signature = prepare_message($signature, $allowhtml, $allowbbcode, $allowsmilies, $signature_bbcode_uid);
	}

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	if ( $infos != '' )
	{
		if ( $infos_bbcode_uid == '' )
		{
			$infos_bbcode_uid = ( $allowbbcode ) ? make_bbcode_uid() : '';
		}
		$infos = prepare_message($infos, $allowhtml, $allowbbcode, $allowsmilies, $infos_bbcode_uid);
	}

# 
#-----[ FIND ]---------------------------------------------------
# 
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . "

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
$interests) . "'

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, user_infos = '" . str_replace("\'", "''", $infos) . "', user_infos_bbcode_uid = '$infos_bbcode_uid'


# 
#-----[ FIND ]---------------------------------------------------
# 
	$interests = $userdata['user_interests'];

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	$infos_bbcode_uid = $userdata['user_infos_bbcode_uid'];
	$infos = ( $infos_bbcode_uid != '' ) ? preg_replace("/:(([a-z0-9]+:)?)$infos_bbcode_uid\]/si", ']', $userdata['user_infos']) : $userdata['user_infos'];

# 
#-----[ FIND ]---------------------------------------------------
# 
	display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popuppm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies, $allowviewonline, $user_style, $user_lang, $user_timezone, $user_dateformat);

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
$user_dateformat

# 
#-----[ ADD AFTER ]---------------------------------------------------
# 
, $infos

# 
#-----[ FIND (just a quote) ]--------------------------
#
	$template->assign_vars(array(
		.
		.
		.
		.
		'INTERESTS' => $interests,

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
      		'INFOS' => str_replace('<br />', "\n", $infos),
		'L_INFOS' => $lang['Infos'],
		'L_INFOS_EXPLAIN' => $lang['Infos_explain'],



# 
#-----[ OPEN ]------------------------------------------ 
#  
# includes/usercp_avatar.php
# 
#-----[ FIND ]---------------------------------------------------
# 
function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) 

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
&$dateformat

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, &$infos

# 
#-----[ FIND ]---------------------------------------------------
# 
$params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); 

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
'dateformat'

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, 'infos'



# 
#-----[ OPEN ]------------------------------------------ 
#  
# admin/admin_users.php 
# 
#-----[ FIND ]---------------------------------------------------
# 
		$interests = ( !empty($HTTP_POST_VARS['interests']) ) ? trim(strip_tags( $HTTP_POST_VARS['interests'] ) ) : '';

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
		$infos = ( !empty($HTTP_POST_VARS['infos']) ) ? trim(str_replace('<br />', "\n", $HTTP_POST_VARS['infos'] ) ) : ''; 

# 
#-----[ FIND (2 times) ]---------------------------------------------------
# 
			$interests = htmlspecialchars(stripslashes($interests));

# 
#-----[ BELOW ADD (2 times) ]---------------------------------------------------
# 
			$infos = htmlspecialchars(stripslashes($infos));

# 
#-----[ FIND ]---------------------------------------------------
# 
		//
		// Avatar stuff
		//

# 
#-----[ BEFORE ADD ]---------------------------------------------------
# 
		if( $infos != "" )
		{
			if ( $infos_bbcode_uid == '' )
			{
				$infos_bbcode_uid = ( $allowbbcode ) ? make_bbcode_uid() : '';
			}
			$infos = prepare_message($infos, $allowhtml, $allowbbcode, $allowsmilies, $infos_bbcode_uid);
		}

# 
#-----[ FIND ]---------------------------------------------------
# 
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", $aim) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_sig_bbcode_uid = '$signature_bbcode_uid', user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowavatar = $user_allowavatar, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_allow_pm = $user_allowpm, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_active = $user_status, user_rank = $user_rank" . $avatar_sql . "

# 
#-----[ IN-LINE FIND ]---------------------------------------------------
# 
$interests) . "'

# 
#-----[ AFTER ADD ]---------------------------------------------------
# 
, user_infos = '" . str_replace("\'", "''", $infos) . "', user_infos_bbcode_uid = '$infos_bbcode_uid'

# 
#-----[ FIND ]---------------------------------------------------
# 
		$interests = htmlspecialchars($this_userdata['user_interests']);

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
		$infos = ($this_userdata['user_infos_bbcode_uid'] != '') ? preg_replace('#:' . $this_userdata['user_infos_bbcode_uid'] . '#si', '', $this_userdata['user_infos']) : $this_userdata['user_infos'];
		$infos = preg_replace($html_entities_match, $html_entities_replace, $infos);

# 
#-----[ FIND ]---------------------------------------------------
# 
			$s_hidden_fields .= '<input type="hidden" name="interests" value="' . str_replace("\"", "&quot;", $interests) . '" />';

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
			$s_hidden_fields .= '<input type="hidden" name="infos" value="' . str_replace("\"", "&quot;", $infos) . '" />'; 


# 
#-----[ FIND ]---------------------------------------------------
# 
			'INTERESTS' => $interests,

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
			'INFOS' => str_replace('<br />', "\n", $infos),
			'L_INFOS' => $lang['Infos'],
			'L_INFOS_EXPLAIN' => $lang['Infos_explain'],



# 
#-----[ OPEN ]------------------------------------------ 
#  
# templates/xxx/profile_add_body.tpl
# 
#-----[ FIND ]---------------------------------------------------
# 
	<tr> 
	  <td class="row1"><span class="gen">{L_INTERESTS}:</span></td>
	  <td class="row2"> 
		<input type="text" class="post"style="width: 200px"  name="interests" size="35" maxlength="150" value="{INTERESTS}" />
	  </td>
	</tr>

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	<!-- BEGIN switch_edit_profile -->
	<tr> 
	  <td class="row1"><span class="gen">{L_INFOS}:</span><span class="gensmall"><br />{L_INFOS_EXPLAIN}<br /><br />{HTML_STATUS}<br />{BBCODE_STATUS}<br />{SMILIES_STATUS}</span></td>
	  <td class="row2"> 
		<textarea name="infos"style="width: 300px"  rows="6" cols="30" class="post">{INFOS}</textarea>
	  </td>
	</tr>
	<!-- END switch_edit_profile -->



# 
#-----[ OPEN ]------------------------------------------ 
#  
# templates/xxx/profile_view_body.tpl
# 
#-----[ FIND ]---------------------------------------------------
# 
		  //--></script><noscript>{ICQ_IMG}</noscript></td>
		</tr>
	  </table>
	</td>
  </tr>

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
  <tr> 
	<td colspan="2" class="catLeft" align="center" height="28"><b><span class="gen">{L_INFOS} </span></b></td>
  </tr>
  <tr>
          <td colspan="2" class="row1"><span class="genmed">{INFOS}</span></td>
  </tr>



# 
#-----[ OPEN ]------------------------------------------ 
#  
# templates/xxx/admin/user_edit_body.tpl
# 
#-----[ FIND ]---------------------------------------------------
# 
	<tr> 
	  <td class="row1"><span class="gen">{L_INTERESTS}</span></td>
	  <td class="row2"> 
		<input type="text" name="interests" size="35" maxlength="150" value="{INTERESTS}" />
	  </td>
	</tr>

# 
#-----[ BELOW ADD ]---------------------------------------------------
# 
	<tr> 
	  <td class="row1"><span class="gen">{L_INFOS}:</span><span class="gensmall"><br />{L_INFOS_EXPLAIN}<br /><br />{HTML_STATUS}<br />{BBCODE_STATUS}<br />{SMILIES_STATUS}</span></td>
	  <td class="row2"> <textarea class="post" name="infos"style="width: 300px"  rows="6" cols="30">{INFOS}</textarea> </td>
	</tr>

#############################################################################################################################################################################################
#############################################################################################################################################################################################
#############################################################################################################################################################################################
