============================================================================================================================
Modification Name: Random House Selection (Harry Potter)

Version: 1.1

Author: GuldantheWarlock (GuldantheWarlock@xmbgarage.com)

Last Updated: May 26, 2011

Description:
This modification will sort users into a house at random upon registration.
It will also update the current members and sort them randomly to a house.
It comes with the Harry Potter default options of: Gryffindor, Hufflepuff, Ravenclaw and Slytherin.
This modification will show this selection in both posts, profile and member home page.
This modification will also display an icon for the appropriate house next in posts, profile and member home page.
Version 1.1 now features an admin on/off switch to prevent sorting and to remove the house display.

Supported Version: XMB 1.9.5 SP1

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

Author Note:
You downloaded this modification from XMB Garage. Please backup your files before installing this modification.
Neither XMB Garage nor the author can be held responsible if your board stops functioning properly due to you installing this modification.
Please visit http://www.xmbgarage.com/ for support.

Copyright:  2010 XMB Garage. All Rights Reserved.
============================================================================================================================
=======
Step 1:
=======

====================================
Go To Administration Panel --> Insert Raw SQL
====================================
===================================
Paste The Following Code and Submit Changes:
===================================

ALTER TABLE `$table_settings` ADD `housestatus` SET('on', 'off') default 'on';
ALTER TABLE `$table_members` ADD `house` INT(1) NOT NULL default 0;
UPDATE `$table_members` SET house=FLOOR(1 + (RAND() * 4));

If you don't want super admins sorted then use this code instead:

ALTER TABLE `$table_settings` ADD `housestatus` SET('on', 'off') default 'on';
ALTER TABLE `$table_members` ADD `house` INT(1) NOT NULL default 0;
UPDATE `$table_members` SET house=FLOOR(1 + (RAND() * 4)) WHERE status != 'Super Administrator';

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

// Random House Selection (Harry Potter) Mod Begin
$lang['houseselection1'] = "House:";
$lang['houseselection2'] = "Congratulations! You have been sorted into ";
$lang['houseselection3'] = "House";
$lang['house1name'] = "Gryffindor";
$lang['house2name'] = "Hufflepuff";
$lang['house3name'] = "Ravenclaw";
$lang['house4name'] = "Slytherin";
$lang['housestatus'] = "House Status";
// Random House Selection (Harry Potter) Mod End

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

        $notifycheck[0] = $notifycheck[1] = $notifycheck[2] = false;

===============
Add Code Above:
===============

        // Random House Selection (Harry Potter) Mod Begin
        $housestatuson = $housestatusoff = '';
        switch ($SETTINGS['housestatus']) {
            case 'on':
                $housestatuson = $selHTML;
                break;
            default:
                $housestatusoff = $selHTML;
                break;
        }
        // Random House Selection (Harry Potter) Mod End

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

        printsetting1($lang['reportpoststatus'], 'reportpostnew', $reportposton, $reportpostoff);
    
===============
Add Code Below:
===============

        // Random House Selection (Harry Potter) Mod Begin
        printsetting1($lang['housestatus'], 'housestatusnew', $housestatuson, $housestatusoff);
        // Random House Selection (Harry Potter) Mod End
==========
Find Code:
==========
        $resetSigNew = ($resetSigNew == 'on') ? 'on' : 'off';
    
===============
Add Code Below:
===============

        // Random House Selection (Harry Potter) Mod Begin
        $housestatusnew = ($housestatusnew == 'on') ? 'on' : 'off';
        // Random House Selection (Harry Potter) Mod End
==========
Find Code:
==========

        $db->query("UPDATE $table_settings SET langfile='$langfilenew'

================================
Add Code To End Of Statement Before  ");
================================

, housestatus='$housestatusnew'

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

            <td><strong><font color="<?php echo $cattext?>"><?php echo $lang['textcusstatus']?></font></strong></td>
    
===============
Add Code Below:
===============

            <!-- Random House Selection (Harry Potter) Mod Begin -->
            <td><strong><font color="<?php echo $cattext?>"><?php echo $lang['houseselection3']?></font></strong></td>
            <!-- Randon House Selection (Harry Potter) Mod End -->
    
==========
Find Code:
==========

            $bothban = "";

            while ($member = $db->fetch_array($query)) {
            
================
Replace Code With:
================

            $bothban = "";

            // Random House Selection (Harry Potter) Mod Begin
            $house0sel = $house1sel = $house2sel = $house3sel = $house4sel = '';
            // Random House Selection (Harry Potter) Mod End

            while ($member = $db->fetch_array($query)) {
            
==========
Find Code:
==========

                    default:
                        $memselect = $selHTML;
                        break;
                }
                
===============
Add Code Below:
===============

                // Random House Selection (Harry Potter) Mod Begin
                switch($member['house']) {
                    case 0:
                        $house1sel = $selHTML;
                        break;
                    case 1:
                        $house1sel = $selHTML;
                        break;
                    case 2:
                        $house2sel = $selHTML;
                        break;
                    case 3:
                        $house3sel = $selHTML;
                        break;
                    case 4:
                        $house4sel = $selHTML;
                        break;
                 }
                 // Random House Selection (Harry Potter) Mod End
               
==========
Find Code:
==========

                <td><input type="text" size="16" name="cusstatus<?php echo $member['uid']?>" value="<?php echo htmlspecialchars(stripslashes($member['customstatus']))?>" /></td>
                
===============
Add Code Below:
===============

                <!-- Random House Selection (Harry Potter) Mod Begin -->
                <td><select name="house<?php echo $member['uid']?>">
                <option value="0" <?php echo $house0sel?>><?php echo $lang['textnone']?></option>
                <option value="1" <?php echo $house1sel?>><?php echo $lang['house1name']?></option>
                <option value="2" <?php echo $house2sel?>><?php echo $lang['house2name']?></option>
                <option value="3" <?php echo $house3sel?>><?php echo $lang['house3name']?></option>
                <option value="4" <?php echo $house4sel?>><?php echo $lang['house4name']?></option>
                </select></td>
                <!-- Random House Selection (Harry Potter) Mod End -->
                
==========
Find Code:
===========

                <?php
                $sadminselect = "";
                $adminselect = "";
                $smodselect = "";
                $modselect = "";
                $memselect = "";
                $banselect = "";
                $noban = "";
                $u2uban = "";
                $postban = "";
                $bothban = "";

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

                // Random House Selection (Harry Potter) Mod Begin
                $house0sel = $house1sel = $house2sel = $house3sel = $house4sel = '';
                // Random House Selection (Harry Potter) Mod End
                
==========
Find Code:
==========

            <td bgcolor="<?php echo $altbg2?>" class="tablerow" align="center" colspan="7"><input type="submit" class="submit" name="membersubmit" value="<?php echo $lang['textsubmitchanges']?>" /><input type="hidden" name="srchmem" value="<?php echo $srchmem?>" /><input type="hidden" name="srchstatus" value="<?php echo $srchstatus?>" /></td>

==================================
What you are looking for here is the colspan="7".
This could be altered due to other modifications.
If you can't find it by the whole line then try searching for:
==================================

<input type="submit" class="submit" name="membersubmit" value="<?php echo $lang['textsubmitchanges']?>" /><input type="hidden" name="srchmem" value="<?php echo $srchmem?>" />

===========================================
and change the colspan number found in the line accordingly.
You will increase it by 1.
===========================================
            
================
Replace Code With:
================

            <td bgcolor="<?php echo $altbg2?>" class="tablerow" align="center" colspan="8"><input type="submit" class="submit" name="membersubmit" value="<?php echo $lang['textsubmitchanges']?>" /><input type="hidden" name="srchmem" value="<?php echo $srchmem?>" /><input type="hidden" name="srchstatus" value="<?php echo $srchstatus?>" /></td>
            
==========
Find Code:
==========

            $delete = "delete".$mem['uid'];
            $delete = isset($_POST[$delete]) ? $_POST[$delete] : '';
            
===============
Add Code Below:
===============

            // Random House Selection (Harry Potter) Mod Begin
            $house = "house".$mem['uid'];
            $house = isset($_POST[$house]) ? $_POST[$house] : '';
            if ($to['status'] == 'Super Administrator') {
                $house = 0;
            }
            // Random House Selection (Harry Potter) Mod End
            
==========
Find Code:
==========

                    $db->query("UPDATE $table_members SET ban='$banstatus'
    
================
Replace Code With:
================

                    $db->query("UPDATE $table_members SET ban='$banstatus', house='$house'

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

loadtemplates(

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

loadtemplates(
'member_profile_house',

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

        $db->query("INSERT INTO $table_members (
        
===============
Add Code Above:
===============

        // Random House Selection (Harry Potter) Mod Begin
        $house = ($SETTINGS['housestatus'] == 'on') ? rand(1, 4) : 0;
        // Random House Selection (Harry Potter) Mod End

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

        $db->query("INSERT INTO $table_members (
        
==============================
Add To Line Just Before  ) VALUES ('',
==============================

, house

================================
Add To End Of Statement Just Before  ')");'
================================

, '$house'

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

"<center><span class=\"mediumtxt \">$lang[regged]</span></center>"

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

"<center><span class=\"mediumtxt \">$lang[regged]".(($SETTINGS['housestatus'] == 'on') ? "<br />$lang[houseselection2]<strong>".$lang['house'.$house.'name']."</strong>" : '')."</span></center>"

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

            if ($memberinfo['showemail'] == "yes") {
                eval("\$emailblock = \"".template("member_profile_email")."\";");
            } else {
                $emailblock = '';
            }
          
===============
Add Code Below:
===============

            // Random House Selection (Harry Potter) Mod Begin
            $housetext = $memberhouse = $houseblock = '';
            if ($SETTINGS['housestatus'] == 'on') {
                $housetext = $lang['houseselection1'];
                if ($memberinfo['house'] != 0) {
                    $house = 'house'.$memberinfo['house'].'name';
                    $memberinfo['house'] = $lang[$house];
                    $memberhouse = "<img src=\"images/".$memberinfo['house'].".gif\" border=\"0\" /> ".$memberinfo['house'];
                    eval('$houseblock = "'.template('member_profile_house').'";');
                }
            }
            // Random House Selection (Harry Potter) Mod End

============================================================================================================================
=======
Step 5:
=======
=================
Edit File: memcp.php
=================
==========
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:
===============

    // Random House Selection (Harry Potter) Mod Begin
    $house = '';
    if ($member['house'] != 0 && $SETTINGS['housestatus'] == 'on') {
        $house = 'house'.$member['house'].'name';
        $house = $lang[$house];
        $house = '<img src="images/'.$house.'.gif" border="0" />&nbsp;'.$house;
    }
    // Random House Selection (Harry Potter) Mod End

============================================================================================================================
=======
Step 6:
=======
===================
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:
===============

            // Random House Selection (Harry Potter) Mod Begin
            $house = '';
            if ($post['house'] != 0) {
                $house = 'house'.$post['house'].'name';
                $post['house'] = $lang[$house];
                $house = "<br />".$lang['houseselection1']." <img src=\"images/".$post['house'].".gif\" border=\"0\" /> ".$post['house'];
            }
            // Random House Selection (Harry Potter) Mod End

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

            $location = '';
            $mood = '';
            
===============
Add Code Below:
===============

            // Random House Selection (Harry Potter) Mod Begin
            $house = '';
            // Random House Selection (Harry Potter) Mod End

============================================================================================================================
=======
Step 7:
=======
===============================
Go To Administration Panel --> Templates
===============================
=======================
Edit Template: member_profile
=======================
==========
Find Code:
==========

<tr>
<td bgcolor="$altbg1" class="tablerow" valign="top">$lang[textstatus]<br /><a href="$sitelink" target="_blank">$memberinfo[avatar]</a></td>
<td bgcolor="$altbg2" class="tablerow">$showtitle$customstatus<br />$stars<br /><br />$rank[avatarrank]</td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" valign="top">$lang[houseselection1]</td>
<td bgcolor="$altbg2">$memberhouse</td>
</tr>

============================================================================================================================
=======
Step 8:
=======
===============================
Go To Administration Panel --> Templates
===============================
======================
Edit Template: memcp_home
======================
==========
Find Code:
==========

<tr class="tablerow">
<td bgcolor="$altbg1" valign="top">$lang[textcusstatus]</td>
<td bgcolor="$altbg2" valign="top">$member[customstatus]</td>
<td bgcolor="$altbg1" valign="top">&nbsp;</td>
<td bgcolor="$altbg2" valign="top">&nbsp;</td>
<td bgcolor="$altbg1" valign="top">&nbsp;</td>
<td bgcolor="$altbg2" valign="top">&nbsp;</td>
</tr>

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

<tr class="tablerow">
<td bgcolor="$altbg1" valign="top">$lang[textcusstatus]</td>
<td bgcolor="$altbg2" valign="top">$member[customstatus]</td>
<td bgcolor="$altbg1" valign="top">$housetext</td>
<td bgcolor="$altbg2" valign="top">$house</td>
<td bgcolor="$altbg1" valign="top">&nbsp;</td>
<td bgcolor="$altbg2" valign="top">&nbsp;</td>
</tr>

============================================================================================================================
=======
Step 9:
=======
===============================
Go To Administration Panel --> Templates
===============================
========================
Edit Template: veiwthread_post
========================
==========
Find Code:
==========

$location

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

$house

============================================================================================================================
========
Step 10:
========

Upload all edited files and upload all images from the "Contents" folder to your forum's "images/" folder.

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