Title: Military Branch Selection v1.0

Author: WormHole

Description:
This modification will provide an option to select a branch of the military.
This modification will display your selected branch of the military in your profile, control panel and posts.

Copyright:  2009 XMB Garage. All rights reserved.

Based on the Country Flag Selection modification by John Briggs.

Compatability: XMB 1.9.5 Final

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.

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>';
            // Military Branch Selection Mod End

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

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

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

        // Military Branch Selection Mod Begin
        $military = isset($military) ? checkInput($military, '', '', '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("INSERT INTO $table_members (uid,

===============================
Find Code In-Line In Above Statement:
===============================

) 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 />'.$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('','','',' '), $memeber['military']).'" id="militaryimg" />';
        }
        // Military Branch Selection Mod End

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

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

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

        // Military Branch Selection Mod Begin
        $military = isset($newmilitary) ? checkInput($newmilitary, 'no', 'no', '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 $table_members SET $pwtxt

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

 WHERE username='$xmbuser'");

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

, military='$military' 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
    $militaryimg  = '<img src="'.ROOT.'images/pixel.gif" id="militaryimg" alt="" />';
    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'] != '') ? $member['military'] : './images/pixel.gif').'" alt="" title="" border="0" /><br />';
            $member['military'] = "$militaryimg$militaryname";
        }
    }
    // 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('','','',' '), $memeber['military']).'" id="militaryimg" />';
    }
    // Military Branch Selection Mod End

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

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

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

    // Military Branch Selection Mod Begin
    $military = isset($newmilitary) ? checkInput($newmilitary, 'no', 'no', '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 $table_members SET email='$email'

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

 WHERE username='$user'");

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

, military='$military' 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);
                $militaryimg = '<img src="'.ROOT.'images/pixel.gif" alt="" id="militaryimg" />';
                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 At Very Bottom of File:
==========================

// 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 -> 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 -> member_reg
===========================================

==========
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/pixel.gif" alt="$militaryname" title="$militaryname" border="0" /></td>
</tr>

=======================================================================================================================================
=======
Step 9:
=======

======================================
Go To Admin Panel -> Templates -> 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 -> viewthread_post
=======================================

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

$location

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

$post[military]

=======================================================================================================================================
========
Step 11:
========

======================================
Go To Admin Panel -> Templates -> 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 template name -> 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 -> 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.

=======================================================================================================================================