======================================================================================================================================
Mod Title: Rename Templates

Mod Version: 1.0

Mod Author: Jonathon Myrick

Mod Updated By: John Briggs

Mod Description:
This mod will provide the option to rename a template in your administration panel.
This mod will require that if you rename the template that you also change the name of the template in loadtemplates() in files.

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

Mod Compatibility: XMB 1.9.8 Engage Final SP2/SP3

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/SP3 which is provided by XMBGarage.com.

=======================================================================================================================================
=======
Step 1:
=======

==================
Edit File: cp2.php
==================

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

if (noSubmit('edit') && noSubmit('editsubmit') && noSubmit('delete') && noSubmit('deletesubmit') && noSubmit('new') && noSubmit('restore') && noSubmit('restoresubmit')) {

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

if (noSubmit('edit') && noSubmit('editsubmit') && noSubmit('delete') && noSubmit('deletesubmit') && noSubmit('new') && noSubmit('restore') && noSubmit('restoresubmit') && noSubmit('rename') && noSubmit('renamesubmit')) {

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

        <input type="submit" class="submit"name="delete" value="<?php echo $lang['deletebutton']?>" />&nbsp;

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

        // Rename Templates Mod Begin
        <input type="submit" class="submit" name="rename" value="<?php echo $lang['template_button']?>" />&nbsp;
        // Rename Templates Mod End

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

    if (onSubmit('deletesubmit')) {
        $db->query("DELETE FROM ".X_PREFIX."templates WHERE id='$tid'");
        echo "<tr bgcolor=\"$altbg2\" class=\"tablerow\"><td align=\"center\">$lang[templatesdelete]</td></tr>";
    }

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

    // Rename Templates Mod Begin
    if (onSubmit('rename') && noSubmit('renamesubmit')) {
        $tid = formVar('tid');
        if ($tid == 'default') {
            error($lang['selecttemplate'], false, '</td></tr></table></td></tr></table><br />');
        }
        ?>
        <tr bgcolor="<?php echo $altbg2?>">
        <td align="center">
        <form method="post" action="cp2.php?action=templates&amp;tid=<?php echo $tid?>">
        <table cellspacing="0" cellpadding="0" border="0" width="550" align="center">
        <tr>
        <td bgcolor="<?php echo $bordercolor?>">
        <table border="0" cellspacing="<?php echo $borderwidth?>" cellpadding="<?php echo $tablespace?>" width="100%">
        <tr>
        <td class="category" colspan="2"><strong><font color="<?php echo $cattext?>"><?php echo $lang['templates']?></font></strong></td>
        </tr>
        <?php
        $query = $db->query("SELECT * FROM ".X_PREFIX."templates WHERE id='$tid' ORDER BY name");
        $template_info = $db->fetch_array($query);
        $db->free_result($query);
        ?>
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['textfrom']?></td>
        <td bgcolor="<?php echo $altbg2?>"><?php echo stripslashes($template_info['name'])?></td>
        </tr>
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['textto']?></td>
        <td bgcolor="<?php echo $altbg2?>"><input type="text" name="new_name" size="30" value="" /></td>
        </tr>
        <tr class="ctrtablerow" bgcolor="<?php echo $altbg2?>">
        <td colspan="2"><input type="submit" name="renamesubmit" class="submit" value="<?php echo $lang['textsubmitchanges']?>" /></td>
        </tr>
        </table>
        </td>
        </tr>
        </table>
        </form>
        </td>
        </tr>
        <?php
    }

    if (onSubmit('renamesubmit') && noSubmit('rename')) {
        $check_newname = $db->query("SELECT name FROM ".X_PREFIX."templates WHERE name='$new_name'");
        if ($db->num_rows($check_newname) != 0) {
            error($lang['templateexists'], false, '</td></tr></table></td></tr></table><br />');
        } else {
            $db->query("UPDATE ".X_PREFIX."templates SET name='$new_name' WHERE id='$tid'");
            echo '<tr bgcolor="'.$altbg2.'" class="ctrtablerow"><td>'.$lang['template_renamed'].'</td></tr>';
            redirect('cp2.php?action=templates', 2.5, X_REDIRECT_JS);
        }
    }
    // Rename Templates Mod End

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

================================
Edit File: lang/English.lang.php
================================

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

?>

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

// Rename Templates Mod Begin
$lang['template_renamed'] = "Template renamed successfully!";
$lang['template_button'] = "Rename";
// Rename Templates Mod End

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