Title: Military Branch Selection v2.0

Author: John Briggs

Description:
This modification will provide an option to select a Military Branch image in your member control panel.
This modification will display your selected Military Branch image in your profile, control panel, profile editor and threads.

Copyright:  2009 John Briggs. All rights reserved.

Compatability: XMB 1.9.8 Engage Final SP3

Updated for 1.9.8 SP3 by: WormHole @ XMB Garage

Install Note: Before adding this modification to your forum, you should back up all files related to this mod.

License Note: This modification is released under the GPL License. A copy is provided with this software package.

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.

=======================================================================================================================================================
=======
Step 1:
=======
==============================
Go To Admin Panel --> Insert Raw SQL
==============================

Upload provided file named "SQL.txt" & click "Submit Changes" button.

=======================================================================================================================================
=======
Step 2:
=======
=================
Edit File: member.php
=================
==========
Find Code:
==========

loadtemplates(

==================
Replace Code With:
==================

loadtemplates(
'member_profile_military',

==========
Find Code:
==========

                $langfileselect = createLangFileSelect($SETTINGS['langfile']);

===============
Add Code Below:
===============
            
                // Military Branch Selection Mod Begin
                $mbs = array();
                $mbs[] = '<option value="">'.$lang['militarynone'].'</option>';
                $dp = opendir(ROOT.'images/military');
                while ($file = readdir($dp)) {
                    if ($file != '.' AND $file != '..' AND $file != 'index.html') {
                        $militaryname = $file;
                        $militaryname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $militaryname);
                        $mbs[] = '<option value="'.$file.'">'.$militaryname.'</option>';
                    }
                }
                closedir($dp);
                natcasesort($mbs);
                $militaryselect = '<select name="military" onchange="document.getElementById(\'militaryimg\').src = (this.options[this.selectedIndex].value != \'\') ? \'images/military/\'+this.options[this.selectedIndex].value : \'./images/pixel.gif\';" />'.implode("\n", $mbs).'</select>';
                $militaryimg  = '<img src="'.ROOT.'images/pixel.gif" id="militaryimg" alt="" />';
                if ($memberinfo['military'] != '') {
                    $militaryimg = '<img src="'.ROOT.'images/military/'.$memberinfo['military'].'" alt="'.str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $memberinfo['military']).'" id="militaryimg" />';
                }
                // Military Branch Selection Mod End

==========
Find Code:
==========

                $sig = postedVar('sig', 'javascript', ($SETTINGS['sightml']=='off'), TRUE, TRUE);

===============
Add Code Below:
===============

                // Military Branch Selection Mod Begin
                $military = postedVar($military, '', '', 'javascript', TRUE, TRUE, TRUE);
                // Military Branch Selection Mod End

=================
Find Code (2 Times):
=================

                $db->query("INSERT INTO ".X_PREFIX."members (username

===============================
Find Code In-Line In Above 2 Statements:
===============================

) VALUES ('$username'

================
Replace Code With:
================

, military) VALUES ('$username'

===================================
Find Code At End Of Above Query Statements:
===================================

)");

================
Replace Code With:
================

, '$military')");

==========
Find Code:
==========

                if ($memberinfo['customstatus'] != '') {
                    $showtitle = $rank['title'];
                    $customstatus = '<br />'.censor($memberinfo['customstatus']);
                } else {
                    $showtitle = $rank['title'];
                    $customstatus = '';
                }

===============
Add Code Below:
===============
            
                // Military Branch Selection Mod Begin
                $militaryblock = '';
                if ($memberinfo['military'] != '') {
                    $militaryname = $memberinfo['military'];
                    $militaryname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $militaryname);
                    if (file_exists(ROOT.'images/military/'.$memberinfo['military'])) {
                        $militaryimg = '<img src="'.ROOT.'images/military/'.$memberinfo['military'].'" alt="'.$militaryname.'" title="'.$militaryname.'" border="0" /><br />'.$militaryname;
                        $memberinfo['military'] = $militaryimg;
                        eval('$militaryblock = "'.template('member_profile_military').'";');
                    }
                }
                // Military Branch Selection Mod End

=======================================================================================================================================
=======
Step 3:
=======
=================
Edit File: memcp.php
=================
==========
Find Code:
==========

        $langfileselect = createLangFileSelect($member['langfile']);

===============
Add Code Below:
===============

        // Military Branch Selection Mod Begin
        $mbs = array();
        $mbs[] = '<option value="">'.$lang['militarynone'].'</option>';
        $dp = opendir(ROOT.'images/military');
        while ($file = readdir($dp)) {
            if ($file != '.' AND $file != '..' AND $file != 'index.html') {
                $militaryname = $file;
                $militaryname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $militaryname);
                if ($member['military'] == $file) {
                    $mbs[] = '<option value="'.$file.'" selected="selected">'.$militaryname.'</option>';
                } else {
                    $mbs[] = '<option value="'.$file.'">'.$militaryname.'</option>';
                }
            }
        }
        closedir($dp);
        natcasesort($mbs);
        $militaryselect = '<select name="newmilitary" onchange="document.getElementById(\'militaryimg\').src = (this.options[this.selectedIndex].value != \'\') ? \'images/military/\'+this.options[this.selectedIndex].value : \'./images/pixel.gif\';" />'.implode("\n", $mbs).'</select>';
        $militaryimg  = '<img src="'.ROOT.'images/pixel.gif" id="militaryimg" alt="" />';
        if ($member['military'] != '') {
            $militaryimg = '<img src="'.ROOT.'images/military/'.$member['military'].'" alt="'.str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $member['military']).'" id="militaryimg" />';
        }
        // Military Branch Selection Mod End

==========
Find Code:
==========

        $sig = isset($_POST['newsig']) ? checkInput($_POST['newsig'], '', $SETTINGS['sightml'], '', false) : '';

===============
Add Code Below:
===============

        // Military Branch Selection Mod Begin
        $newmilitary = formVar('newmilitary');
        $military = $newmilitary ? checkInput($newmilitary, 'no', 'yes', 'javascript', false) : '';
        // Military Branch Selection Mod End

==========
Find Code:
==========

        $sig = addslashes($sig);

===============
Add Code Below:
===============

        // Military Branch Selection Mod Begin
        $military = addslashes($military);
        // Military Branch Selection Mod End

==========
Find Code:
==========

        $db->query("UPDATE ".X_PREFIX."members SET $pwtxt

=======================================
Find Code In-Line At End Of Above Query Australianment:
=======================================

 WHERE username='$xmbuser'");

==================
Replace Code With:
==================

, military='$newmilitary' WHERE username='$xmbuser'");

==========
Find Code:
==========

    if ($member['mood'] != '') {
        $member['mood'] = censor($member['mood']);
        $member['mood'] = postify($member['mood'], 'no', 'no', 'yes', 'no', 'yes', 'no', true, 'yes');
    } else {
        $member['mood'] = '';
    }

===============
Add Code Below:
===============

    // Military Branch Selection Mod Begin
    if ($member['military'] != '') {
        $militaryname = $member['military'];
        $militaryname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $militaryname);
        if (file_exists(ROOT.'images/military/'.$member['military'])) {
            $militaryimg = '<img src="'.ROOT.'images/military/'.$member['military'].'" alt="'.$militaryname.'" title="'.$militaryname.'" border="0" /><br />'.$militaryname;
            $member['military'] = $militaryimg;
        }
    }
    // Military Branch Selection Mod End

=======================================================================================================================================
=======
Step 4:
=======
==================
Edit File: editprofile.php
==================
==========
Find Code:
==========

    $langfileselect = createLangFileSelect($member['langfile']);

==============
Add Code Below:
==============

    // Military Branch Selection Mod Begin
    $mbs = array();
    $mbs[] = '<option value="">'.$lang['militarynone'].'</option>';
    $dp = opendir(ROOT.'images/military');
    while ($file = readdir($dp)) {
        if ($file != '.' AND $file != '..' AND $file != 'index.html') {
            $militaryname = $file;
            $militaryname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $militaryname);
            if ($member['military'] == $file) {
                $mbs[] = '<option value="'.$file.'" selected="selected">'.$militaryname.'</option>';
            } else {
                    $mbs[] = '<option value="'.$file.'">'.$militaryname.'</option>';
            }
        }
    }
    closedir($dp);
    natcasesort($mbs);
    $militaryselect = '<select name="newmilitary" onchange="document.getElementById(\'militaryimg\').src = (this.options[this.selectedIndex].value != \'\') ? \'images/military/\'+this.options[this.selectedIndex].value : \'./images/pixel.gif\';" />'.implode("\n", $mbs).'</select>';
    $militaryimg  = '<img src="'.ROOT.'images/pixel.gif" id="militaryimg" alt="" />';
    if ($member['military'] != '') {
        $militaryimg = '<img src="'.ROOT.'images/military/'.$member['military'].'" alt="'.str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $member['military']).'" id="militaryimg" />';
    }
    // Military Branch Selection Mod End

==========
Find Code:
==========

    $sig = isset($_POST['newsig']) ? checkInput($_POST['newsig'], '', $SETTINGS['sightml'], '', false) : '';

===============
Add Code Below:
===============

    // Military Branch Selection Mod Begin
    $newmilitary = formVar('newmilitary');
    $military = $newmilitary ? checkInput($newmilitary, 'no', 'yes', 'javascript', false) : '';
    // Military Branch Selection Mod End

==========
Find Code:
==========

    $sig = addslashes($sig);

===============
Add Code Below:
===============

    // Military Branch Selection Mod Begin
    $military = addslashes($military);
    // Military Branch Selection Mod End

================
Find Code (2 Times:
================

    $db->query("UPDATE ".X_PREFIX."members SET email='$email'

=======================================
Find Code In-Line At End Of Both Query Statements:
=======================================

 WHERE username='$user'");

================
Replace Code With:
================

, military='$newmilitary' WHERE username='$user'");

=======================================================================================================================================
=======
Step 5:
=======
===================
Edit File: viewthread.php
===================

==========
Find Code:
==========

            if ($post['location'] != '') {
                $post['location'] = censor($post['location']);
                $location = '<br />'.$lang['textlocation'].' '.$post['location'];
            } else {
                $location = '';
            }

===============
Add Code Below:
===============

            // Military Branch Selection Mod Begin
            if ($post['military'] != '') {
                $militaryname = $post['military'];
                $militaryname = str_replace(array('.gif','.jpg','.png','_'), array('','','',' '), $militaryname);
                if (file_exists(ROOT.'images/military/'.$post['military'].'')) {
                    $militaryimg = '<img src="'.ROOT.'images/military/'.$post['military'].'" alt="'.$militaryname.'" title="'.$militaryname.'" border="0" /><br />'.$militaryname.'<br />';
                    $post['military'] = '<br />'.$lang['military'].' '.$militaryimg;
                }
            }
            // Military Branch Selection Mod End

==========
Find Code:
==========

            $location = '';
            $mood = '';

===============
Add Code Below:
===============

            // Military Branch Selection Mod Begin
            $post['military'] = '';
            // Military Branch Selection Mod End

=======================================================================================================================================
=======
Step 6:
=======
=======================
Edit File: lang/English.lang.php
=======================
============================
Add Code To End Of File Above ?>
============================

// Military Branch Selection Mod Begin
$lang['military'] = "Military Branch:";
$lang['militarynone'] = "--Select Military Branch--";
// Military Branch Selection Mod End

=======================================================================================================================================
=======
Step 7:
=======
==========================
Go To Admin Panel --> Templates
==========================
===========================
Edit Template: admintool_editprofile
===========================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="newlocation" size="25" value="$member[location]" /></td>
</tr>

===============
Add Code Below:
===============

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$lang[military]</td>
<td bgcolor="$THEME[altbg2]">$militaryselect&nbsp;<img id="militaryimg" src="./images/military/$member[military]" alt="$militaryname" title="$militaryname" border="0" /></td>
</tr>

=======================================================================================================================================
=======
Step 8:
=======
==========================
Go To Admin Panel --> Templates
==========================
===========================
Edit Template: member_reg_optional
===========================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="location" size="25" value="" /></td>
</tr>

===============
Add Code Below:
===============

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$lang[military]</td>
<td bgcolor="$THEME[altbg2]">$militaryselect&nbsp;<img id="militaryimg" src="./images/military/$member[military]" alt="$militaryname" title="$militaryname" border="0" /></td>
</tr>

=======================================================================================================================================
=======
Step 9:
=======
==========================
Go To Admin Panel --> Templates
==========================
=======================
Edit Template: memcp_profile
=======================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" width="22%">$lang[textlocation]</td>
<td bgcolor="$altbg2"><input type="text" name="newlocation" size="25" value="$member[location]" /></td>
</tr>

===============
Add Code Below:
===============

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%">$lang[military]</td>
<td bgcolor="$THEME[altbg2]">$militaryselect&nbsp;$militaryimg</td>
</tr>

=======================================================================================================================================
========
Step 10:
========
==========================
Go To Admin Panel --> Templates
==========================
========================
Edit Template: viewthread_post
========================
==========
Find Code:
==========

$location

===============
Add Code Below:
===============

$post[military]

=======================================================================================================================================
========
Step 11:
========
==========================
Go To Admin Panel --> Templates
==========================
=======================
Edit Template: member_profile
=======================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1">$lang[textlocation]</td>
<td bgcolor="$altbg2">$memberinfo[location]</td>
</tr>

===============
Add Code Below:
===============

$militaryblock

=======================================================================================================================================
========
Step 12:
========
==========================
Go To Admin Panel --> Templates
==========================
===================================
Create New Template: member_profile_military
===================================
===========================
Add Code & Click Submit Changes
===========================

<tr class="tablerow">
<td bgcolor="$THEME[altbg1]" width="22%" valign="top">$lang[military]</td>
<td bgcolor="$THEME[altbg2]">$memberinfo[military]</td>
</tr>

=======================================================================================================================================
========
Step 13:
========
==========================
Go To Admin Panel --> Templates
==========================
======================
Edit Template: memcp_home
======================
==========
Find Code:
==========

<td bgcolor="$altbg1" valign="top">&nbsp;</td>
<td bgcolor="$altbg2" valign="top">&nbsp;</td>

================
Replace Code With:
================

<td bgcolor="$THEME[altbg1]" valign="top">$lang[military]</td>
<td bgcolor="$THEME[altbg2]" valign="top" align="center">$member[military]</td>

=======================================================================================================================================
========
Step 14:
========

Now upload provided folder named "military" to your forum "/images/" directory.

=======================================================================================================================================
Enjoy!