Title: Rename Template v1.0

Author: Jonathon Myrick

Updated By: John Briggs

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.

Copyright:  2006 Jonathon Myrick. All rights reserved.
Copyright:  2006 John Briggs. All rights reserved.

Compatability: XMB 1.9.5 Final

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

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

Author Note:
You downloaded this hack from XMBMods.com, the #1 source for XMB related downloads.
Please visit http://www.xmbmods.com/ for support.

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

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

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

&& !isset($restoresubmit))

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

&& !isset($restoresubmit) && !isset($rename) && !isset($_POST['renamesubmit']))

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

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

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

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

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

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

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

    if (isset($rename) && !isset($_POST['renamesubmit'])){
        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 $table_templates WHERE id='$tid' ORDER BY name");
        $template_info = $db->fetch_array($query);
        $db->free_result($query);
        ?>
        <tr>
        <td bgcolor="<?php echo $altbg1?>" class="tablerow"><?php echo $lang['textfrom']?></td>
        <td bgcolor="<?php echo $altbg2?>" class="tablerow"><?php echo $template_info['name']?></td>
        </tr>
        <tr>
        <td bgcolor="<?php echo $altbg1?>" class="tablerow"><?php echo $lang['textto']?></td>
        <td bgcolor="<?php echo $altbg2?>" class="tablerow"><input type="text" name="new_name" size="30" value="" /></td>
        </tr>
        <tr>
        <td bgcolor="<?php echo $altbg2?>" class="ctrtablerow" 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 (isset($_POST['renamesubmit']) && !isset($rename)) {
        $check_newname = $db->query("SELECT name FROM $table_templates WHERE name = '$new_name'");
        if ($check_newname && $db->num_rows($check_newname) != 0) {
            error($lang['templateexists'], false, '</td></tr></table></td></tr></table><br />');
        } else {
            $db->query("UPDATE $table_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);
        }
    }

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

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

================================
Add Code At Very Bottom of File:
================================

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

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