*
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * 
 * properties template, shows the basic page on the properties window
 *
 * @author Patrick Lockley
 * @version 1.0
 * @package
 */
require_once "../../../config.php";
include "../template_status.php";
include "../screen_size_library.php";
include "../url_library.php";
include "../user_library.php";
include "properties_library.php";
if (!empty($_POST['template_id']) && is_numeric($_POST['template_id'])) {
    $template_id = (int) $_POST['template_id'];
    if (has_rights_to_this_template($template_id, $_SESSION['toolkits_logon_id']) || is_user_admin()) {
        properties_display($xerte_toolkits_site, $template_id, false, "");
        exit(0);
    }
}
properties_display_fail();
<?php

/**
 * 
 * properties template, shows the basic page on the properties window
 *
 * @author Patrick Lockley
 * @version 1.0
 * @copyright Copyright (c) 2008,2009 University of Nottingham
 * @package
 */
require_once "../../../config.php";
include "../template_status.php";
include "../screen_size_library.php";
include "../url_library.php";
include "../user_library.php";
include "properties_library.php";
if (is_numeric($_POST['template_id'])) {
    $tutorial_id = mysql_real_escape_string($_POST['template_id']);
    $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(mysql_real_escape_string($_POST['template_id']), $_SESSION['toolkits_logon_id']) || is_user_admin()) {
        properties_display($xerte_toolkits_site, $tutorial_id, false, "");
    } else {
        properties_display_fail();
    }
}
    $engine = mysql_real_escape_string($_POST['engine']);
    if ($engine != 'flash' && $engine != 'javascript') {
        $engine = 'javascript';
    }
    // Get extra flags
    $row = db_query_one("SELECT td.extra_flags  FROM {$xerte_toolkits_site->database_table_prefix}templatedetails td WHERE td.template_id = ?", array($template_id));
    $extra_flags = explode(";", $row['extra_flags']);
    $found = false;
    for ($i = 0; $i < count($extra_flags); $i++) {
        $parameter = explode("=", $extra_flags[$i]);
        if ($parameter[0] == 'engine') {
            $extra_flags[$i] = "engine=" . $engine;
            $found = true;
            break;
        }
    }
    if (!$found) {
        $extra_flags[] = "engine=" . $engine;
    }
    $db_entry = join(";", $extra_flags);
    $query = "update " . $xerte_toolkits_site->database_table_prefix . "templatedetails SET extra_flags =\"" . str_replace(" ", "_", mysql_real_escape_string($db_entry)) . "\" WHERE template_id =\"" . $template_id . "\"";
    if (mysql_query($query)) {
        if ($_REQUEST['page'] == 'properties') {
            properties_display($xerte_toolkits_site, $template_id, true, "engine");
        } else {
            publish_display($template_id);
        }
    } else {
    }
    mysql_close($database_id);
}
<?php

/**
 * 
 * rename template, allows a user to rename a template
 *
 * @author Patrick Lockley
 * @version 1.0
 * @copyright Copyright (c) 2008,2009 University of Nottingham
 * @package
 */
require_once "../../../config.php";
include "../template_status.php";
include "../screen_size_library.php";
include "../url_library.php";
include "properties_library.php";
if (is_numeric($_POST['template_id'])) {
    $tutorial_id = mysql_real_escape_string($_POST['template_id']);
    $database_id = database_connect("Template rename database connect success", "Template rename database connect failed");
    $query = "update " . $xerte_toolkits_site->database_table_prefix . "templatedetails SET template_name =\"" . str_replace(" ", "_", mysql_real_escape_string($_POST['template_name'])) . "\" WHERE template_id =\"" . mysql_real_escape_string($_POST['template_id']) . "\"";
    if (mysql_query($query)) {
        $query_for_names = "select template_name, date_created, date_modified from " . $xerte_toolkits_site->database_table_prefix . "templatedetails where template_id=\"" . $tutorial_id . "\"";
        $query_names_response = mysql_query($query_for_names);
        $row = mysql_fetch_array($query_names_response);
        echo "~~**~~" . $_POST['template_name'] . "~~**~~";
        properties_display($xerte_toolkits_site, $tutorial_id, true, "name");
    } else {
    }
    mysql_close($database_id);
}