* @version 1.0
 * @copyright Copyright (c) 2008,2009 University of Nottingham
 * @package
 */
require_once "../../../config.php";
include "../user_library.php";
include "../deletion_library.php";
include "../template_status.php";
_load_language_file("/website_code/php/templates/delete_template.inc");
$database_id = database_connect("delete template database connect success", "delete template database connect failed");
/*
 * get the folder id to delete
 */
if (is_numeric($_POST['template_id'])) {
    $safe_template_id = mysql_real_escape_string($_POST['template_id']);
    if (!is_template_syndicated($safe_template_id)) {
        if (is_user_creator($safe_template_id)) {
            $query_for_folder_id = "select * from " . $xerte_toolkits_site->database_table_prefix . "templaterights where template_id=\"" . $safe_template_id . "\"";
            $query_for_folder_id_response = mysql_query($query_for_folder_id);
            $row = mysql_fetch_array($query_for_folder_id_response);
            // delete from the database
            $query_to_delete_template = "update " . $xerte_toolkits_site->database_table_prefix . "templaterights set folder=\"" . get_recycle_bin() . "\" where template_id=\"" . $safe_template_id . "\" and user_id=\"" . $_SESSION['toolkits_logon_id'] . "\"";
            if (mysql_query($query_to_delete_template)) {
                receive_message($_SESSION['toolkits_logon_username'], "ADMIN", "CRITICAL", "Moved file to users recycle bin", "Moved file to users recycle bin");
            } else {
                receive_message($_SESSION['toolkits_logon_username'], "ADMIN", "CRITICAL", "Failed to move file to the recycle bin", "Failed to move file to the recycle bin");
            }
        } else {
            echo DELETE_TEMPLATE_NOT_CREATOR;
        }
    } else {
function publish_display($template_id)
{
    global $xerte_toolkits_site;
    $prefix = $xerte_toolkits_site->database_table_prefix;
    $database_id = database_connect("Properties template database connect success", "Properties template database connect failed");
    // User has to have some rights to do this
    if (has_rights_to_this_template($_POST['template_id'], $_SESSION['toolkits_logon_id']) || is_user_admin()) {
        echo "<p class=\"header\"><span>" . PUBLISH_TITLE . "</span></p>";
        $query_for_names = "select td.template_name, td.date_created, td.date_modified, otd.template_framework from {$prefix}templatedetails td, " . "{$prefix}originaltemplatesdetails otd where td.template_id= ? and td.template_type_id = otd.template_type_id";
        $params = array($template_id);
        $row = db_query_one($query_for_names, $params);
        echo "<p>" . PUBLISH_DESCRIPTION . "</p>";
        $template_access = template_access_settings($template_id);
        echo "<p><b>" . PUBLISH_ACCESS . "</b><br>" . PUBLISH_ACCESS_DESCRIPTION . "</p>";
        if ($template_access == "Private") {
            echo "<p><img src=\"website_code/images/bullet_error.gif\" align=\"absmiddle\" /><b>" . PUBLISH_ACCESS_STATUS . "</b></p>";
        } else {
            echo "<p>" . PUBLISH_ACCESS_IS . " " . $template_access . ".</p>";
        }
        echo "<p><b>" . PUBLISH_RSS . "</b><br>" . PUBLISH_RSS_DESCRIPTION . "</p>";
        if (!is_template_rss($_POST['template_id'])) {
            echo "<p><b>" . PUBLISH_RSS_NOT_INCLUDE . "</b></p>";
        } else {
            echo "<p>" . PUBLISH_RSS_INCLUDE . "</p>";
        }
        include "../../../modules/" . $row['template_framework'] . "/module_functions.php";
        display_publish_engine();
        echo "<p><b>" . PUBLISH_SYNDICATION . "</b><br>" . PUBLISH_SYNDICATION_DESCRIPTION . "</p>";
        if (!is_template_syndicated($template_id)) {
            echo "<p><b>" . PUBLISH_SYNDICATION_STATUS_OFF . "</b></p>";
        } else {
            echo "<p>" . PUBLISH_SYNDICATION_STATUS_ON . "</p>";
        }
        if ($template_access != "") {
            /**
             *
             * This section using $_SESSION['webct'] is for people using the integration option for webct. If you integration option has the ability to post back a URL then you would modify this code to allow for your systems working methods.
             *
             **/
            echo "<p><button type=\"button\" class=\"xerte_button\" onclick=\"publish_project(window.name);\">" . PUBLISH_BUTTON_LABEL . "</button></p>";
            echo "<p>" . PUBLISH_WEB_ADDRESS . " <a target='_blank' href='" . $xerte_toolkits_site->site_url . url_return("play", $template_id) . "'>" . $xerte_toolkits_site->site_url . url_return("play", $template_id) . "</a></p>";
        }
    } else {
        echo "<p><img src=\"website_code/images/Bttn_PublishDis.gif\" /></p>";
    }
}