Name: Forum Based Auto Close New Threads v1.0

Last modified: 05/06/2009 @ 08:00 (EDT)

Description:
This modification will add a new option to forum options which automatically closes new threads.
This modification can be turned on/off on a per forum basis.

Compatibility: XMB v1.9.8 SP3

Tested On: XMB 1.9.8 SP3

Code Developed By: Adam Clarke (http://www.scriptdesign.co.uk & http://www.adam-clarke.co.uk)

MOD History: V1.0 (19/06/2005 @ 19:00) - Initial Release

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

Note: Backup all affected files, templates & database's.

Affected Files: cp.php, post.php, lang/English.lang.php

Affected Templates: NONE

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

Upload SQL.txt and click Submit Changes.

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

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

        $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 Below:
===========

        // Forum Based Auto Close New Threads Mod Begin
        $closethreads_on = $closethreads_off = '';
        switch ($forum['closethreads']) {
            case 'on':
                $closethreads_on = $selHTML;
                break;
            default:
                $closethreads_off = $selHTML;
                break;
        }
        // Forum Based Auto Close New Threads Mod End

================
Find (2nd Instance):
================

        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['texttheme']?></td>
        <td bgcolor="<?php echo $altbg2?>"><?php echo $themelist?></td>
        </tr>

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

        <!-- Forum Based Auto Close New Threads Mod Begin -->
        <?php
        printsetting1($lang['closethreadsstatus'], 'closethreadsnew', $closethreads_on, $closethreads_off);
        ?>
        <!-- Forum Based Auto Close New Threads Mod End -->

======
Find:
======

        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 Code:
=====================

) VALUES ('forum',

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

, closethreads) VALUES ('forum',

=============================
Add Code To End Of Line Before: )");
=============================

, 'off'

======
Find:
======

        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 Code:
=====================

) VALUES ('forum',

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

, closethreads) VALUES ('forum',

=============================
Add Code To End Of Line Before: )");
=============================

, 'off'

======
Find:
======

        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 Code:
=====================

) VALUES ('forum',

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

, closethreads) VALUES ('forum',

=============================
Add Code To End Of Line Before: )");
=============================

, 'off'

======
Find:
======

        $guestpostingnew = formOnOff('guestpostingnew');

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

        // Forum Based Auto Close New Threads Mod Begin
        $closethreadsnew = formOnOff('closethreadsnew');
        // Forum Based Auto Close New Threads Mod End

======
Find:
======

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

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

        $db->query("UPDATE ".X_PREFIX."forums SET
            closethreads='$closethreadsnew',

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

            if ((X_STAFF) && $closetopic == 'yes') {
                $db->query("UPDATE ".X_PREFIX."threads SET closed='yes' WHERE tid='$tid' AND fid='$fid'");
            }

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

            if (((X_STAFF) && $closetopic == 'yes') || $forum['closethreads'] == 'on') {
                $db->query("UPDATE ".X_PREFIX."threads SET closed='yes' WHERE tid='$tid' AND fid='$fid'");
            }

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

// Forum Based Auto Close New Threads Mod Begin
$lang['closethreadsstatus'] = 'Auto Close New Threads Status:';
// Forum Based Auto Close New Threads Mod End

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