2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_FAQ);
20 if (isset($_POST['cancel'])) {
21 $msg->addFeedback('CANCELLED');
22 header('Location: index_instructor.php');
26 if (isset($_GET['id'])) {
27 $id = intval($_GET['id']);
29 $id = intval($_POST['id']);
32 if (isset($_POST['submit'])) {
33 if (trim($_POST['name']) == '') {
34 $msg->addError('NAME_EMPTY');
37 if (!$msg->containsErrors()) {
38 $_POST['name'] = $addslashes($_POST['name']);
39 //This will truncate the content of the length to 240 as defined in the db.
40 $_POST['name'] = validate_length($_POST['name'], 250);
42 $sql = "UPDATE ".TABLE_PREFIX."faq_topics SET name='$_POST[name]' WHERE topic_id=$id AND course_id=$_SESSION[course_id]";
43 $result = mysql_query($sql,$db);
45 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
46 header('Location: index_instructor.php');
50 $onload = 'document.form.name.focus();';
52 require(AT_INCLUDE_PATH.'header.inc.php');
55 $msg->printErrors('ITEM_NOT_FOUND');
56 require (AT_INCLUDE_PATH.'footer.inc.php');
60 $sql = "SELECT name FROM ".TABLE_PREFIX."faq_topics WHERE course_id=$_SESSION[course_id] AND topic_id=$id ORDER BY name";
61 $result = mysql_query($sql, $db);
62 if (!$row = mysql_fetch_assoc($result)) {
63 $msg->printErrorS('ITEM_NOT_FOUND');
64 require(AT_INCLUDE_PATH.'footer.inc.php');
66 } else if (!isset($_POST['name'])) {
67 $_POST['name'] = $row['name'];
69 $savant->assign('id', $id);
70 $savant->display('instructor/faq/edit_topic.tmpl.php');
71 require (AT_INCLUDE_PATH.'footer.inc.php'); ?>