============================================================================================================================
Modification Title: Subforums On Index v2.0

Author: GuldantheWarlock and John Briggs

Updated By: John Briggs, Steven Waters, vanderaj

Description:
This modification will list the subforums under a forum on the index page.
This modification will hide subforums from people who are not authorized to view them.
This modification will provide an option to enable or disable displaying subforums on index.

Copyright:  2005-2010 XMBGarage.com. All Rights Reserved.

Compatability: XMB 1.9.5 SP1

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

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 XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.
============================================================================================================================
=======
Step 1:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================
======================================
Copy and Paste SQL Code Below and Click Submit
======================================

ALTER TABLE `$table_settings` ADD `showsubs` char(3) default 'on' NOT NULL;

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

        $spacecatson = $spacecatsoff = '';
        if ($SETTINGS['space_cats'] == "on") {
            $spacecatson = $selHTML;
        } else {
            $spacecatsoff = $selHTML;
        }

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

        // Subforums On Index Mod Begin
        $showsubson = $showsubsoff = '';
        switch ($SETTINGS['showsubs']) {
            case 'on':
                $showsubson  = $selHTML;
                break;
            default:
                $showsubsoff = $selHTML;
                break;
        }
        // Subforums On Index Mod End

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

        printsetting1($lang['space_cats'], 'space_catsnew',$spacecatson, $spacecatsoff);

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

        // Subforums On Index Mod Begin
        printsetting1($lang['showsubs'], 'showsubsnew', $showsubson, $showsubsoff);
        // Subforums On Index Mod End

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

        $resetSigNew = ($resetSigNew == 'on') ? 'on' : 'off';

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

        // Subforums On Index Mod Begin
        $showsubsnew = ($showsubsnew == 'on') ? 'on' : 'off';
        // Subforums On Index Mod End

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

$db->query("UPDATE $table_settings SET

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

");

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

, showsubs='$showsubsnew'");

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

    global $timecode, $dateformat, $lang, $xmbuser, $self, $lastvisit2, $timeoffset, $hideprivate, $addtime, $oldtopics, $lastvisit;

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

    // Subforums On Index Mod Begin
    global $index_subforums;
    // Subforums On Index Mod End

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

            $forum['moderator'] = '('.$lang['textmodby'].' '.$forum['moderator'].')';
        }

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

        // Subforums On Index Mod Begin
        $subforums = array();
        if (count($index_subforums) > 0) {
            for ($i=0; $i < count($index_subforums); $i++) {
                $sub = $index_subforums[$i];
                if ($sub['fup'] == $forum['fid']) {
                    if (X_SADMIN || $hideprivate == 'off' || privfcheck($sub['private'], $sub['userlist'])) {
                        $subforums[] = '<a href="forumdisplay.php?fid='.intval($sub['fid']).'">'.stripslashes($sub['name']).'</a>';
                    }
                }
            }
        }

        if (!empty($subforums)) {
            $subforums = implode(', ', $subforums);
            $subforums = '<br /><strong>'.$lang['textsubforums'].'</strong> '.$subforums;
        } else {
            $subforums = '';
        }
        // Subforums On Index Mod End

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

while ($thing = $db->fetch_array($fquery)) {

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

// Subforums On Index Mod Begin
if ($SETTINGS['showsubs'] == 'on') {
    // create sub-forums on index
    $index_subforums = array();
    if ($SETTINGS['catsonly'] != 'on' || $gid > 0) {
        $query = $db->query("SELECT fid, fup, name, private, userlist FROM $table_forums WHERE status='on' AND type='sub' ORDER BY fup, displayorder");
        while ($queryrow = $db->fetch_array($query)) {
            $index_subforums[] = $queryrow;
        }
        $db->free_result($query);
    }
}
// Subforums On Index Mod End

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

// Subforums On Index Mod Begin
$lang['showsubs'] = "Sub-forums on index status:<br /><span class=\"smalltxt\">This will enable or disable sub-forums display on index.</span>";
$lang['textsubforums'] = "Sub-Forums:";
// Subforums On Index Mod End

============================================================================================================================
=======
Step 6:
=======
===============================
Go To Administration Panel --> Templates
===============================
=====================
Edit template: index_forum
=====================
==========
Find Code:
==========

$forum[description]

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

$forum[description]$subforums

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