######################################################## 
## Mod Title:   Gender 
## Mod Version: 1.0
## Author:       Niels Chr. Denmark < ncr@db9.dk > 
## Made into text format by:  L. Chance <lchance@okbadlands.com>
## Description:  This mod will add a Gender field into your users' profile.
## It will also display "Gender: <image>" in each of their posts.
## This mod is only for phpBB2!!
##
## 
## Installation Level:  Easy 
## Installation Time:   15-25 Minutes 
## Files To Edit:      7 
## Included Files:   icon_minigender_male.gif & icon_minigender_female.gif
######################################################## 
## 
## Installation Notes: 
## 
## This mod has been tested and works on many different systems. 
## The most important thing to keep in mind is, take your time, make 
## sure you are finding the correct lines to modify, then take care to paste the new code.
## Please also keep in mind, if you are using more than one language file or theme at your
## site, you will need to edit the correct files for each occurrence.  Good Luck! 
######################################################## 

# 
#-----[ ACTION ]------------------------------------------ 
# 
#  You will need to add one new field into your users table in your SQL database.

SQL-query: 
ALTER TABLE users ADD user_gender TINYINT not null

# 
#-----[ ACTION ]------------------------------------------ 
# 
#  OPEN FILE:  phpBB2/language/lang_XX/lang_main.php  (make sure to edit this file for every language your board uses).
#  AT THE BOTTOM OF THE PAGE

[ADD]:

//Add on for Gender Mod 
$lang['Gender'] = "Gender";//used in users profile to display witch gender he/she is 
$lang['Male'] = "Male"; 
$lang['Female']="female"; 
$lang['No_gender_specify'] = "None Specified";

# 
#-----[ ACTION ]------------------------------------------ 
# 
## OPEN FILE:  phpBB2/profile.php

[FIND]:

if( !empty($profiledata['user_icq']) )
{
           $icq_status_img = '<a href="http://wwp.icq.com/' . $profiledata['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $profiledata['user_icq'] . '&amp;img=5" width="18" height="18" border="0" /></a>';
           $icq_add_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $profiledata['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" border="0" /></a>';
}
else
{
           $icq_status_img = "&nbsp;";
           $icq_add_img = "&nbsp;";
}

[ADD AFTER]:

if ( !empty($profiledata['user_gender'])) 
{ 
           switch ($profiledata['user_gender']) 
           { 
                      case 1: $gender=$lang['Male'];break; 
                      case 2: $gender=$lang['Female'];break; 
                      default:$gender=$lang['No_gender_specify']; 
           } 
} else $gender=$lang['No_gender_specify'];

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

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

[ADD AFTER]:

"GENDER" => $gender,

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

"L_INTERESTS" => $lang['Interests'],

[ADD AFTER]:

"L_GENDER" => $lang['Gender'], 
"L_GENDER_MALE" =>$lang['Male'], 
"L_GENDER_FEMALE" =>$lang['Female'], 
"L_GENDER_NOT_SPECIFY" =>$lang['No_gender_specify'],

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

$interests = (!empty($HTTP_POST_VARS['interests'])) ?  trim(strip_tags($HTTP_POST_VARS['interests'])) : "";

[ADD AFTER]:

$gender = (!empty($HTTP_POST_VARS['gender'])) ? trim(strip_tags($HTTP_POST_VARS['gender'])) : ""; 
switch ($gender) 
{ 
      case 1: $gender_male_checked="checked=\"checked\"";break; 
      case 2: $gender_female_checked="checked=\"checked\"";break; 
      default:$gender_no_specify_checked="checked=\"checked\""; 
}

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

$interests = stripslashes($interests);

[ADD AFTER]:

$gender=stripslashes($gender);

# 
#-----[ ACTION ]------------------------------------------ 
#

[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("\'", "''", $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 ."
	
[REPLACE WITH]:

$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("\'", "''", $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) . "', user_gender = '$gender' " . $avatar_sql ."
                  	
# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

$sql = "INSERT INTO " . USERS_TABLE . "   (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
                   VALUES ($new_user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', '" . str_replace("\'", "''", $avatar_filename) . "', $viewemail, '" . str_replace("\'", "''", $aim) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popuppm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";
                    
[REPLACE WITH]:

$sql = "INSERT INTO " . USERS_TABLE . "   (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm,user_gender, user_actkey, user_active)                    
                   VALUES ($new_user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', '" . str_replace("\'", "''", $avatar_filename) . "', $viewemail, '" . str_replace("\'", "''", $aim) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popuppm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1,'$gender', ";
                   
# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

"INTERESTS" => $interests,

[ADD AFTER]:

 "GENDER" => $gender,                 
 
# 
#-----[ ACTION ]------------------------------------------ 
#

 $interests = stripslashes($interests);
 
 [ADD AFTER]:
 
 $gender = stripslashes($gender);
 
# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:
$interests = $userdata['user_interests'];

[ADD AFTER]:

$gender = $userdata['user_gender']; 
switch ($gender) 
{ 
      case 1: $gender_male_checked="checked=\"checked\"";break; 
      case 2: $gender_female_checked="checked=\"checked\"";break; 
      default:$gender_no_specify_checked="checked=\"checked\""; 
}

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

$s_hidden_vars .= '<input type="hidden" name="interests" value="' . str_replace("\"", "&quot;", $interests) . '" />';

[ADD AFTER]:

$s_hidden_vars .= '<input type="hidden" name="gender" value="' .$gender . '" />';

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

"INTERESTS" => $interests,

[ADD AFTER]:

"GENDER" => $gender,

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

"L_INTERESTS" => $lang['Interests'],

[ADD AFTER]:

"L_GENDER" =>$lang['Gender'], 
"L_GENDER_MALE" =>$lang['Male'], 
"L_GENDER_FEMALE" =>$lang['Female'], 
"L_GENDER_NOT_SPECIFY" =>$lang['No_gender_specify'],

################################### This completes the changes in profile.php ##############################

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/templates/template_dirXX/profile_view_body.tpl (make sure to edit this file for every theme you use).

[FIND]:

<tr> 
      <td valign="top" align="right"><span class="gen">{L_INTERESTS}:</span></td> 
      <td> <b><span class="gen">{INTERESTS}</span></b></td> 
</tr>

[ADD AFTER]:

<tr> 
      <td valign="top" align="right"><span class="gen">{L_GENDER}:</span></td> 
      <td> <b><span class="gen">{GENDER}</span></b></td> 
</tr>

################################### This completes the changes in profile_view_body.tpl ##############################

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/templates/template_dirXX/profiel_add_body.tpl  (make sure to edit this file for every theme you use).

[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>

[ADD AFTER]:

<tr> 
      <td class="row1"><span class="gen">{L_GENDER}:</span></td> 
      <td class="row2"> 
      <input type="radio" name="gender" value="0" {GENDER_NO_SPECIFY_CHECKED}/> 
      <span class="gen">{L_GENDER_NOT_SPECIFY}</span>&nbsp;&nbsp; 
      <input type="radio" name="gender" value="1" {GENDER_MALE_CHECKED}/> 
      <span class="gen">{L_GENDER_MALE}</span>&nbsp;&nbsp; 
      <input type="radio" name="gender" value="2" {GENDER_FEMALE_CHECKED}/> 
      <span class="gen">{L_GENDER_FEMALE}</span></td> 
</tr>

###########################################
##  END OF PART 1:                                                                                       ##
##  This completes the profile portion of the mod.  Users will now ##
##  be able to change their gender selection, and other users        ##
##  will be able to view their selections.  Users who do not              ##
##  specify a gender, the script will default to "None Specified."    ##
###########################################


###########################################
##  PART 2:					           ##
##  Now lets make users' genders viewable in their posts.              ##
###########################################

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/viewtopic.php

[FIND]:

// 
// Go ahead and pull all data for this topic 
// 
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid

[REPLACE WITH]:

// 
// Go ahead and pull all data for this topic 
// 
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, u.user_gender, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

// 
// Set them to empty string initially, in case we don't find a rank for this dude. 
// 
$poster_rank = ""; 
$rank_image = "";

[ADD AFTER]:

$gender_image = "";

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

// 
// This is redundant, but some day we might wanna stick in a rank for anon. posts. 
// 
$poster_rank = ""; 
$rank_image = "";

[ADD AFTER]:

$gender_image = ""; 
# 
#-----[ ACTION ]------------------------------------------ 
#

$gender_image = "";

if( $poster_id != ANONYMOUS ) 
{ 
   $profile_img = "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"" . $images['icon_profile'] . "\" alt=\"" . $lang['Read_profile'] . "\" title=\"" . $lang['Read_profile'] . "\" border=\"0\" /></a>"; 
   $pm_img = "<a href=\"" . append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$poster_id") . "\"><img src=\"". $images['icon_pm'] . "\" alt=\"" . $lang['Send_private_message'] . "\" title=\"" . $lang['Send_private_message'] . "\" border=\"0\" /></a>";
   
[ADD AFTER]:

if ( !empty($postrow[$i]['user_gender'])) 
   { 
      switch ($postrow[$i]['user_gender']) 
      { 
         case 1 : $gender_image = $lang['Gender'].":<img src=\"" . $images['icon_minigender_male'] . "\" alt=\"" . $lang['Gender'].  ":".$lang['Male']."\" title=\"" . $lang['Gender'] . ":".$lang['Male']. "\" border=\"0\" />"; break; 
         case 2 : $gender_image = $lang['Gender'].":<img src=\"" . $images['icon_minigender_female'] . "\" alt=\"" . $lang['Gender']. ":".$lang['Female']. "\" title=\"" . $lang['Gender'] . ":".$lang['Female']. "\" border=\"0\" />"; break; 
         default : $gender_image=""; 
      } 
   }
   
# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

"POSTER_RANK" => $poster_rank,

[ADD AFTER]:

"POSTER_GENDER" => $gender_image,

# 
#-----[ ACTION ]------------------------------------------ 
#

[FIND]:

 "DELETE_IMG" => $delpost_img,  
 
 [ADD AFTER]:
 
"L_GENDER" => $lang['Gender'],

################################### This completes the changes in viewtopic.php ############################## 

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/templates/template_dirXX/template_name.cfg  (make sure you edit each occurrence of this file for all your themes).

[FIND]:

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

[ADD AFTER]:

$images['icon_minigender_male'] = "$current_template_images/icon_minigender_male.gif"; 
$images['icon_minigender_female'] = "$current_template_images/icon_minigender_female.gif";

################################### This completes the changes in template_name.cfg ############################## 

# 
#-----[ ACTION ]------------------------------------------ 
#

Now you must upload the two image files included with this archive into each image directory used by all your themes.  For example, if all you're
using is the subSilver theme, then upload the two files to your phpBB2/templates/subSilber/images/ directory.  Again, repeat this step for all
your themes.

# 
#-----[ ACTION ]------------------------------------------ 
# 
#OPEN FILE:  phpBB2/templates/template_dirXX/viewtopic_body.tpl   (make sure you edit each occurrence of this file for all your themes).

[FIND]:

{postrow.RANK_IMAGE}{postrow.POSTER_AVATAR}<br /> 
<br />

[ADD AFTER]:

{postrow.POSTER_GENDER}<br />

################################### This completes the changes in viewtopic_body.tpl ############################## 

THAT'S IT!!  You're all done.

// EOF