============================================================================================================================
Mod Title: Merge Forums Tool

Mod Version: 1.0

Mod Author: John Briggs

Mod Description:
This mod will provide a tool in admin panel to merge threads from one forum to another with complete ease.

Mod Copyright:  2007-2008 XMBMods.com. All rights reserved.

Mod Compatibility: XMB 1.9.8 Engage Final SP2

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

Mod License Note: This mod is released under the GPL v3 License. A copy is provided with this software.

Mod Author Note:
This modification is developed and released for use with XMB 1.9.8 Engage Final SP2 which is provided by XMBMods.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:
===============

    <!-- Merge Forums Tool Mod Begin -->
    &raquo;&nbsp;<a href="tools.php?action=mergeforums"><?php echo $lang['mergeforumstxt']?></a><br />
    <!-- Merge Forums Tool Mod End -->

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

// Merge Forums Tool Mod Begin
$lang['mergeforumstxt'] = "Merge Forums";
$lang['mergeforums_note'] = "Note: Here you can merge threads from one forum to another by selecting the forum to merge threads to.";
$lang['mergeforums_newfid'] = "To New Forum:";
$lang['mergeforums_oldfid'] = "From Old Forum:";
$lang['mergeforum_newfid_none'] = "You did not select an new forum.";
$lang['mergeforum_oldfid_none'] = "You did not select an old forum.";
$lang['tool_mergeforums'] = "Forums merged successfully.";
// Merge Forums Tool Mod End

============================================================================================================================
=======
Step 3:
=======
===============
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:
===============

    // Merge Forums Tool Mod Begin
    case 'mergeforums':
        if (!X_SADMIN) {
            error($lang['superadminonly'], false, '</td></tr></table></td></tr></table><br />');
        }

        if (noSubmit('mergesubmit')) {
            $old_fid = forumList('old_fid', false, false);
            $new_fid = forumList('new_fid', false, false);
            ?>
            <tr bgcolor="<?php echo $THEME[altbg2]?>">
            <td>
            <form method="post" action="tools.php?action=mergeforums">
            <table cellspacing="0" cellpadding="0" border="0" width="550" align="center">
            <tr>
            <td bgcolor="<?php echo $THEME[bordercolor]?>">
            <table border="0" cellspacing="<?php echo $THEME[borderwidth]?>" cellpadding="<?php echo $THEME[tablespace]?>" width="100%">
            <tr class="category">
            <td colspan="2"><strong><font color="<?php echo $THEME[cattext]?>"><?php echo $lang['mergeforumstxt']?></font></strong></td>
            </td>
            <tr class="tablerow">
            <td bgcolor="<?php echo $THEME[altbg2]?>" colspan="2"><?php echo $lang['mergeforums_note']?></td>
            </tr>
            <tr class="tablerow">
            <td bgcolor="<?php echo $THEME[altbg1]?>" width="22%"><?php echo $lang['mergeforums_oldfid']?></td>
            <td bgcolor="<?php echo $THEME[altbg2]?>">
            <?php echo $old_fid?>
            </td>
            </tr>
            <tr class="tablerow">
            <td bgcolor="<?php echo $THEME[altbg1]?>" width="22%"><?php echo $lang['mergeforums_newfid']?></td>
            <td bgcolor="<?php echo $THEME[altbg2]?>">
            <?php echo $new_fid?>
            </td>
            </tr>
            <tr class="ctrtablerow" bgcolor="<?php echo $THEME[altbg2]?>">
            <td colspan="2"><input class="submit" type="submit" name="mergesubmit" value="<?php echo $lang['textsubmitchanges']?>" />
            </table>
            </td>
            </tr>
            </table>
            </form>
            </td>
            </tr>
            <?php
        }

        if (onSubmit('mergesubmit')) {
            if ($new_fid == '' || !is_numeric($new_fid)) {
                error($lang['mergeforum_newfid_none'], false, '</td></tr></table></td></tr></table><br />');
            }

            if ($old_fid == '' || !is_numeric($old_fid)) {
                error($lang['mergeforum_oldfid_none'], false, '</td></tr></table></td></tr></table><br />');
            }

            $new_fid = (int) $new_fid;
            $old_fid = (int) $old_fid;

            if (isset($new_fid) && is_numeric($new_fid) && isset($old_fid) && is_numeric($old_fid)) {
                $newfidvar = '';
                if ($new_fid != 0) {
                    $newfidvar = "fid=$new_fid";
                }

                $oldfidvar = '';
                if ($old_fid != 0) {
                    $oldfidvar = "fid=$old_fid";
                }

                $db->query("UPDATE ".X_PREFIX."threads SET $newfidvar WHERE $oldfidvar");
                $db->query("UPDATE ".X_PREFIX."posts SET $newfidvar WHERE $oldfidvar");

                updatethreadcount($new_fid);
                updatethreadcount($old_fid);
                updateforumcount($new_fid);
                updateforumcount($old_fid);
                nav($lang['tools']);
                echo '<tr bgcolor="'.$THEME['altbg2'].'" class="ctrtablerow"><td>'.$lang['tool_completed'].' - '.$lang['tool_mergeforums'].'</td></tr></table></table>';
                end_time();
                eval('echo "'.template('footer').'";');
                exit;
            }
        }
        break;

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