=======================================================================================================================================
Modification Title: Close Inactive Threads

Modification Version: 1.2

Modification Author: John Briggs, Area51Mafia

Modification Description:
This modification will provide a new tool in admin panel to close inactive threads.
This modification will provide an option to choose the number of days.
This modification will provide the option to assign a single fid or multiple fids in which to close inactive threads in.

Modification Copyright:  2009 John Briggs. All rights reserved.

Modification Compatibility: XMB 1.9.8 SP3

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

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

Modification Author Note:
This modification is developed and released for use with XMB 1.9.8 SP3 which is provided by XMBGarage.com.

=======================================================================================================================================
=======
Step 1:
=======
=======================
Edit File: include/admin.inc.php
=======================
==========
Find Code:
==========

    &raquo;&nbsp;<a href="cp2.php?action=prune"><?php echo $lang['textprune']?></a><br />

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

    <!-- Close Inactive Threads Mod Begin -->
    &raquo;&nbsp;<a href="tools.php?action=closeinactivethreads"><?php echo $lang['inactivethreads']?></a><br />
    <!-- Close Inactive Threads Mod End -->

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

    case 'checktables':
        $start = true;
        @set_time_limit(180);
        $tables = $db->fetch_tables($dbname);
        $q = array();
        foreach($tables as $key=>$val) {
            if ($start) {
                dump_query($db->query('CHECK TABLE `'.$val.'`'));
                $start = false;
            } else {
                dump_query($db->query('CHECK TABLE `'.$val.'`'), false);
            }
        }
        break;

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

    // Close Inactive Threads Mod Begin
    case 'closeinactivethreads':
        if (noSubmit('yessubmit')) {
            ?>
            <form action="tools.php?action=closeinactivethreads" method="post">
            <tr class="category">
            <td colspan="2"><strong><font color="<?php echo $cattext?>"><?php echo $lang['inactivethreads']?></font></strong></td>
            </td>
            <tr class="tablerow">
            <td bgcolor="<?php echo $altbg2?>" colspan="2"><?php echo $lang['fid_to_close_note']?></td>
            </tr>
            <tr class="tablerow">
            <td bgcolor="<?php echo $altbg1?>" width="22%"><?php echo $lang['fid_to_close']?></td>
            <td bgcolor="<?php echo $altbg2?>"><input type="text" name="fid" size="4" /></td>
            </tr>
            <tr class="tablerow">
            <td bgcolor="<?php echo $altbg1?>" width="22%"><?php echo $lang['num_days_forthreads']?></td>
            <td bgcolor="<?php echo $altbg2?>"><input type="text" name="num_days" size="4" /></td>
            </tr>
            <tr class="ctrtablerow" bgcolor="<?php echo $altbg2?>">
            <td colspan="2"><input class="submit" type="submit" name="yessubmit"  value="<?php echo $lang['textsubmitchanges']?>" />
            </form>
            <?php
        }

        if (onSubmit('yessubmit')) {
            if ($num_days == '' || !is_numeric($num_days)) {
                error($lang['num_days_forthreads_not_there'], false, '</table></table><br />');
            }

            if (!isset($fid) || !is_numeric($fid)) {
                error($lang['fid_forthreads_not_there'], false, '</table></table><br />');
            }

            $fid = (int) $fid;

            if (isset($num_days) && is_numeric($num_days)) {
                $old = time() - (60*60*24*$num_days);
                $diddl = '';
                if ($fid != 0) {
                    $diddl = "fid='$fid' AND ";
                }
                $db->query("UPDATE ".X_PREFIX."threads SET closed='yes' WHERE $diddl lastpost < $old");
                nav($lang['tools']);
                echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>'.$lang['tool_completed'].' - '.$lang['tool_inactivethreads'].'</td></tr></table></table>';
                end_time();
                eval('echo "'.template('footer').'";');
                exit;
            }
        }
        break;
    // Close Inactive Threads Mod End

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

// Close Inactive Threads Mod Begin
$lang['inactivethreads'] = "Close Inactive Threads";
$lang['tool_inactivethreads'] = "Inactive Threads Closed.";
$lang['num_days_forthreads'] = "The number of days:";
$lang['num_days_forthreads_not_there'] = "You did not enter the number of days to close inactive threads!";
$lang['fid_forthreads_not_there'] = "You did not enter the fid number to close inactive threads in!";
$lang['fid_to_close'] = "The fid to close threads in:";
$lang['fid_to_close_note'] = "Here you can close all threads where none have been replied to for a certain number of days.";
// Close Inactive Threads Mod End

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