============================================================================================================================
Modification Title: Close Inactive Threads v1.0

Author: John Briggs, Area51Mafia

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.

Copyright:  2010 John Briggs. All rights reserved.

Compatability: XMB 1.9.5 Final 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. 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:
=======
===========================
Edit File: include/admin.user.inc.php
===========================
==========
Find Code:
==========

    &raquo;&nbsp;<a href="cp.php?action=forum"><?php echo $lang['textforums']?></a><br />

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

    <!-- 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 'fixorphanedattachments':
        if (!isset($_POST['orphattachsubmit'])) {
            echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>';
            echo '<form action="tools.php?action=fixorphanedattachments" method="post">';
            echo '<input type="submit" name="orphattachsubmit" value="'.$lang['o_attach_submit'].'" />';
            echo '</form>';
        } else {
            $i = 0;
            $q = $db->query("SELECT aid, pid FROM $table_attachments");
            while ($a = $db->fetch_array($q)) {
                $result = $db->query("SELECT pid FROM $table_posts WHERE pid='$a[pid]'");
                if ($db->num_rows($result) == 0) {
                    $db->query("DELETE FROM $table_attachments WHERE aid='$a[aid]'");
                    $i++;
                }
            }
            echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>';
            echo $i . $lang['o_attachments_found'];
        }
        break;

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

    // Close Inactive Threads Mod Begin
    case 'closeinactivethreads':
        if (!isset($_POST['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 (isset($_POST['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 $table_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!