Title: Forum Based Thread Count Control v1.0

Author: GuldantheWarlock @ XMB Garage

Description:
This modification will provide an option in your forum options to allow/disallow thread count increase for members.
You Must have the Thread Totals hack installed in order to use this hack.

Compatability: XMB 1.9.8 SP3

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. A copy is provided with this software package.

Author Note:
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.

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

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

=======================================================================================================================================
=======
Step 2:
=======

==============
Edit File: cp.php
==============

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

        $type31 = $type32 = $type33 = $type34 = '';
        if ($forum['private'] == 2) {
            $type32 = $selHTML;
        } else if ($forum['private'] == 3) {
            $type33 = $selHTML;
        } else if ($forum['private'] == 4) {
            $type34 = $selHTML;
        } else if ($forum['private'] == 1) {
            $type31 = $selHTML;
        }

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

        // Forum Based Thread Count Control Mod Begin
        $ftcountyes = $ftcountno = '';
        switch ($forum['ftcount']) {
            case 'yes':
                $ftcountyes = $selHTML;
                break;
            default:
                $ftcountno  = $selHTML;
                break;
        }
        // Forum Based Thread Count Control Mod End

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

        <input type="checkbox" name="guestpostingnew" value="on" <?php echo $checked8?> /><?php echo $lang['textanonymousposting']?><br />
        </td>
        </tr>

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

        <!-- Forum Based Thread Count Control Mod Begin -->
        <tr class="tablerow">
        <td bgcolor="<?php echo $THEME['altbg1']?>"><?php echo $lang['ftcountstatus']?></td>
        <td bgcolor="<?php echo $THEME['altbg2']?>">
        <select name="ftcountnew">
        <option value="yes" <?php echo $ftcountyes?>><?php echo $lang['textyes']?></option>
        <option value="no" <?php echo $ftcountno?>><?php echo $lang['textno']?></option>
        </select>
        </td>
        </tr>
        <!-- Forum Based Thread Count Control Mod End -->

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

        if ($newfname != $lang['textnewforum']) {
            $newfname = addslashes($newfname);
            $db->query("INSERT INTO ".X_PREFIX."forums (type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting) VALUES ('forum', '$newfname', '$newfstatus', '', '', ".(int)$newforder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newffup.", '1|1', 'yes', 'on', 'on', '', 'off')");
        }

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


) VALUES ('forum',

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

, ftcount) VALUES ('forum',

============================
Find Code At End Of The Same Line:
============================

)");

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

, 'yes')");

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

        if ($newgname != $lang['textnewgroup']) {
            $newgname = addslashes($newgname);
            $db->query("INSERT INTO ".X_PREFIX."forums (type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting) VALUES ('group', '$newgname', '$newgstatus', '', '', ".(int)$newgorder.", '', '', '', '', '', '', 0, 0, 0, 0, '', '', '', '', '', 'off')");
        }

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

) VALUES ('group',

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

, ftcount) VALUES ('group',

============================
Find Code At End Of The Same Line:
============================

)");

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

, 'yes')");

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

        if ($newsubname != $lang['textnewsubf']) {
            $newsubname = addslashes($newsubname);
            $db->query("INSERT INTO ".X_PREFIX."forums (type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting) VALUES ('sub', '$newsubname', '$newsubstatus', '', '', ".(int)$newsuborder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newsubfup.", '1|1', 'yes', 'on', 'on', '', 'off')");
        }

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

) VALUES ('sub',

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

, ftcount) VALUES ('sub',

============================
Find Code At End Of The Same Line:
============================

)");

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

, 'yes')");

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

        $guestpostingnew = formOnOff('guestpostingnew');

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

        // Forum Based Thread Count Control Mod Begin
        $ftcountnew = formYesNo('ftcountnew');
        // Forum Based Thread Count Control Mod End

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

        $db->query("UPDATE ".X_PREFIX."forums SET

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

        $db->query("UPDATE ".X_PREFIX."forums SET
            ftcount='$ftcountnew',

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

                $db->query("UPDATE ".X_PREFIX."members SET threadnum=threadnum+1, postnum=postnum+1 WHERE username like '$username'");

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

                $threadtxt = ($forum['ftcount'] == 'yes') ? "threadnum=threadnum+1, " : '';
                $db->query("UPDATE ".X_PREFIX."members SET $threadtxt postnum=postnum+1 WHERE username like '$username'");

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

                $db->query("UPDATE ".X_PREFIX."members SET threadnum=threadnum+1, postnum=postnum+1 WHERE username='$username'");

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

                $threadtxt = ($forum['ftcount'] == 'yes') ? "threadnum=threadnum+1, " : '';
                $db->query("UPDATE ".X_PREFIX."members SET $threadtxt postnum=postnum+1 WHERE username='$username'");

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

                        $db->query("UPDATE ".X_PREFIX."members SET threadnum=threadnum-1, postnum=postnum-1 WHERE username='$orig[author]'");

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

                        
                        $threadtxt = ($forum['ftcount'] == 'yes') ? "threadnum=threadnum-1, " : '';
                        $db->query("UPDATE ".X_PREFIX."members SET $threadtxt postnum=postnum-1 WHERE username='$orig[author]'");

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

                                $db->query("UPDATE ".X_PREFIX."members SET threadnum=threadnum-1, postnum=postnum-1 WHERE username='$result[author]'");

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

                                $threadtxt = ($forum['ftcount'] == 'yes') ? "threadnum=threadnum-1, " : '';
                                $db->query("UPDATE ".X_PREFIX."members SET $threadtxt postnum=postnum-1 WHERE username='$result[author]'");

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

                            $db->query("UPDATE ".X_PREFIX."members SET postnum=postnum-1 WHERE username='$orig[author]'");

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

                            $threadtxt = ($forum['ftcount'] == 'yes') ? "threadnum=threadnum-1, " : '';
                            $db->query("UPDATE ".X_PREFIX."members SET $threadtxt postnum=postnum-1 WHERE username='$orig[author]'");

=======================================================================================================================================
=======
Step 4:
=======
====================
Edit File: topicadmin.php
====================

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

                    $db->query("UPDATE ".X_PREFIX."members SET threadnum=threadnum-1, postnum=postnum-1 WHERE username='$result[author]'");

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

                    $threadtxt = ($forum['ftcount'] == 'yes') ? "threadnum=threadnum-1, " : '';
                    $db->query("UPDATE $table_members SET $threadtxt postnum=postnum-1, money=money-'$ssettings[std]' WHERE username='$result[author]'");
                } else {
                    $db->query("UPDATE $table_members SET postnum=postnum-1, money=money-'$ssettings[spd]' WHERE username='$result[author]'");
                }
            }

=======================================================================================================================================
=======
Step 5:
=======
=======================
Edit File: lang/English.lang.php
=======================
==================================
Add Code At Very Bottom Of File Above ?>
==================================

// Forum Based Thread Count Controls Mod Begin
$lang['ftcountstatus'] = "Allow Thread count increases in this forum?";
// Forum Based Thread Count Controls Mod End

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