######################################################## 
## MOD Title:		Configure Member Profile Required Fields
## MOD Version:		1.0.0
## MOD Author:		Mac (Y.C. LIN) < ycl_6@sinamail.com > http://endless-tw.net
##
## MOD Description:	This mod allow admin to configure which information in member profile
##			is required inside admin control panel.
##			The required field will need to be filled in during registration and
##			editing user's own profile.
## 
## Installation Level:	Easy 
## Installation Time:	5 Minutes 
##
## Files To Edit:	5
##	language/lang_english/lang_admin.php
##	language/lang_english/lang_main.php
##	includes/constants.php
##	includes/usercp_register.php
##	templates/subSilver/profile_add_body.tpl
##
## Included Files: 	2
##	admin/admin_profile_field.php
##	templates/subSilver/admin/admin_profile_field.tpl
##
################################################################# 
## 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:
## 	Tested on phpBB 2.0.6, however, should work on all phpBB 2.0.x versions
############################################################## 
## MOD History: 
##
##   2004-01-22 - Version 1.0.0
##      - Initial Release
## 
############################################################## 
## 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
CREATE TABLE `phpbb_profile_config` (
  `config_name` varchar(255) NOT NULL default '',
  `config_value` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`config_name`)
) TYPE=MyISAM;

# 
#-----[ SQL ]------------------------------------------ 
#
# Remember to change the table prefix used on your database
INSERT INTO `phpbb_profile_config` VALUES ('user_email', '1');
INSERT INTO `phpbb_profile_config` VALUES ('user_icq', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_website', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_from', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_sig', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_aim', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_yim', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_msnm', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_occ', '0');
INSERT INTO `phpbb_profile_config` VALUES ('user_interests', '0');

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

# 
#-----[ FIND ]------------------------------------------ 
#
//
// That's all Folks!
// -------------------------------------------------

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
// Configure Member Profile Required Fields
$lang['Profile_config_updated'] = 'Required Field settings have been updated';
$lang['Click_return_profile_config'] = 'Click %sHere%s to return to Profile Required Field Configuration';
$lang['Profile_field_Config'] = 'Profile Required Field Configuration';
$lang['Profile_field_explain'] = 'The form below will allow you to customize if information in member profile is required and should be fill in.';
$lang['Settings'] = 'Settings';
$lang['Email_required'] = 'E-mail Address Required';
$lang['ICQ_required'] = 'ICQ account Required';
$lang['WWW_required'] = 'Website Required';
$lang['From_required'] = 'Location From Required';
$lang['Sig_required'] = 'Signiture Required';
$lang['AIM_required'] = 'AIM account Required';
$lang['YIM_required'] = 'YIM account Required';
$lang['MSN_required'] = 'MSN account Required';
$lang['Occ_required'] = 'Occupation Required';
$lang['Interest_required'] = 'Interest Required';

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

# 
#-----[ FIND ]------------------------------------------ 
#
//
// That's all Folks!
// -------------------------------------------------

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
// Configure Member Profile Required Fields
$lang['Required_field'] = '<b>Required Fields</b>: ';
$lang['Fields_empty_up'] = 'Your Username, Password and Confirm Password is required';
$lang['Fields_empty_email'] = 'Your E-mail Address is Required';
$lang['Fields_empty_icq'] = 'Your ICQ account is Required';
$lang['Fields_empty_website'] = 'Your Website is Required';
$lang['Fields_empty_location'] = 'Your Location is Required';
$lang['Fields_empty_sig'] = 'Your Signiture is Required';
$lang['Fields_empty_aim'] = 'Your AIM account is Required';
$lang['Fields_empty_yim'] = 'Your YIM account is Required';
$lang['Fields_empty_msn'] = 'Your MSN account is Required';
$lang['Fields_empty_occ'] = 'Your Occupation is Required';
$lang['Fields_empty_interest'] = 'Your Interest is Required';

# 
#-----[ OPEN ]------------------------------------------ 
#  
includes/constants.php

# 
#-----[ FIND ]------------------------------------------ 
# 
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');


# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
// Configure Member Profile Required Fields
define('PROFILE_CONFIG_TABLE', $table_prefix.'profile_config');

# 
#-----[ OPEN ]------------------------------------------ 
#  
includes/usercp_register.php

# 
#-----[ FIND ]------------------------------------------ 
# 
//
// Let's make sure the user isn't logged in while registering,
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
// Configure Member Profile Required Fields
$required_info = $lang['Username'] . ", " .  $lang['Password'] . ", " . $lang['Confirm_password'] . ", ";
$u_email = '';
$u_icq = '';
$u_website = '';
$u_from = '';
$u_sig = '';
$u_aim = '';
$u_yim = '';
$u_msnm = '';
$u_occ = '';
$u_interests = '';

// Get setting
$sql = "SELECT *
	FROM " . PROFILE_CONFIG_TABLE . "";
if( !$result = $db->sql_query($sql) )
{
	message_die(CRITICAL_ERROR, "Could not query profile field required status", "", __LINE__, __FILE__, $sql);
}
else
{
	while( $row = $db->sql_fetchrow($result) )
	{
		switch ($row['config_name'])
		{
			case user_email:
				if($row['config_value']) 
				{
					$u_email = '1';
					$required_info .= $lang['Email_address'] . ", "; 
				}	
				break;

			case user_icq:
				if($row['config_value']) 
				{
					$u_icq = '1';
					$required_info .= $lang['ICQ'] . ", "; 
				}
				break;

			case user_website:
				if($row['config_value']) 
				{
					$u_website = '1';
					$required_info .= $lang['Website'] . ", "; 
				}
				break;
				
			case user_from:
				if($row['config_value']) 
				{
					$u_from = '1';
					$required_info .= $lang['Location'] . ", "; 
				}
				break;
				
			case user_sig:
				if($row['config_value']) 
				{
					$u_sig = '1';
					$required_info .= $lang['Signature'] . ", "; 
				}
				break;
				
			case user_aim:
				if($row['config_value']) 
				{
					$u_aim = '1';
					$required_info .= $lang['AIM'] . ", "; 
				}
				break;
				
			case user_yim:
				if($row['config_value']) 
				{
					$u_yim = '1';
					$required_info .= $lang['YIM'] . ", "; 
				}
				break;
				
			case user_msnm:
				if($row['config_value']) 
				{
					$u_msnm = '1';
					$required_info .= $lang['MSNM'] . ", "; 
				}
				break;
				
			case user_occ:
				if($row['config_value']) 
				{
					$u_occ = '1';
					$required_info .= $lang['Occupation'] . ", "; 
				}
				break;
				
			case user_interests:
				if($row['config_value']) 
				{
					$u_interests = '1';
					$required_info .= $lang['Interests'] . ", "; 
				}
				break;
		}
	}
}

$required_info[strlen($required_info)-2] = ' ';

# 
#-----[ FIND ]------------------------------------------ 
# 
	include($phpbb_root_path . 'includes/usercp_avatar.'.$phpEx);

	$passwd_sql = '';

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	// Configure Member Profile Required Fields
	if ( $u_email && empty($email) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_email'];
	}
	if ( $u_icq && empty($icq) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_icq'];
	}
	if ( $u_website && empty($website) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_website'];
	}
	if ( $u_from && empty($location) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_location'];
	}
	if ( $u_sig && empty($signature) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_sig'];
	}
	if ( $u_aim && empty($aim) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_aim'];
	}
	if ( $u_yim && empty($yim) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_yim'];
	}
	if ( $u_msnm && empty($msn) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_msn'];
	}
	if ( $u_occ && empty($occupation) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_occ'];
	}
	if ( $u_interests && empty($interests) )
	{
		$error = TRUE;
		$error_msg .= ( ( isset($error_msg) ) ? '<br />' : '' ) . $lang['Fields_empty_interest'];
	}

# 
#-----[ FIND ]------------------------------------------ 
# 
		'L_ITEMS_REQUIRED' => $lang['Items_required'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
// Configure Member Profile Required Fields
		'L_REQUIRED_FIELD_INFO' =>  $lang['Required_field'],
		'REQUIRED_FIELD_INFO' => $required_info,

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

# 
#-----[ FIND ]------------------------------------------ 
# 
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
	<tr> 
		<td align="left"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
	</tr>
</table>

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
	<tr> 
		<td align="center"><span class="gen">{L_REQUIRED_FIELD_INFO}{REQUIRED_FIELD_INFO}</span></td>
	</tr>
</table>

# 
#-----[ FIND ]------------------------------------------ 
# 
	<tr> 
		<td class="row2" colspan="2"><span class="gensmall">{L_ITEMS_REQUIRED}</span></td>
	</tr>

# 
#-----[ DELETE ]------------------------------------------ 
# 
	<tr> 
		<td class="row2" colspan="2"><span class="gensmall">{L_ITEMS_REQUIRED}</span></td>
	</tr>

# 
#-----[ FIND ]------------------------------------------ 
# 
{L_USERNAME}: *

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
{L_USERNAME}:

# 
#-----[ FIND ]------------------------------------------ 
# 
{L_USERNAME}: *

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
{L_USERNAME}:

# 
#-----[ FIND ]------------------------------------------ 
# 
{L_EMAIL_ADDRESS}: *

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
{L_EMAIL_ADDRESS}:

# 
#-----[ FIND ]------------------------------------------ 
# 
{L_CURRENT_PASSWORD}: *

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
{L_CURRENT_PASSWORD}:

# 
#-----[ FIND ]------------------------------------------ 
# 
{L_NEW_PASSWORD}: *

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
{L_NEW_PASSWORD}:

# 
#-----[ FIND ]------------------------------------------ 
# 
{L_CONFIRM_PASSWORD}: * 

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
{L_CONFIRM_PASSWORD}:

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

# EoM
