2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
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']);
40 $sql = "UPDATE ".TABLE_PREFIX."faq_topics SET name='$_POST[name]' WHERE topic_id=$id AND course_id=$_SESSION[course_id]";
41 $result = mysql_query($sql,$db);
43 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
44 header('Location: index_instructor.php');
48 $onload = 'document.form.name.focus();';
50 require(AT_INCLUDE_PATH.'header.inc.php');
53 $msg->printErrors('ITEM_NOT_FOUND');
54 require (AT_INCLUDE_PATH.'footer.inc.php');
58 $sql = "SELECT name FROM ".TABLE_PREFIX."faq_topics WHERE course_id=$_SESSION[course_id] AND topic_id=$id ORDER BY name";
59 $result = mysql_query($sql, $db);
60 if (!$row = mysql_fetch_assoc($result)) {
61 $msg->printErrorS('ITEM_NOT_FOUND');
62 require(AT_INCLUDE_PATH.'footer.inc.php');
64 } else if (!$_POST['name']) {
65 $_POST['name'] = $row['name'];
70 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
71 <input type="hidden" name="id" value="<?php echo $id; ?>" />
73 <div class="input-form">
75 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="name"><?php echo _AT('name'); ?></label><br />
76 <input type="text" name="name" size="50" id="name" value="<?php if (isset($_POST['name'])) echo $stripslashes($_POST['name']); ?>" />
79 <div class="row buttons">
80 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
81 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?> " />
86 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>