2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 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']);
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'];
72 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
73 <input type="hidden" name="id" value="<?php echo $id; ?>" />
75 <div class="input-form">
76 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('edit'); ?></legend>
78 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="name"><?php echo _AT('name'); ?></label><br />
79 <input type="text" name="name" size="50" id="name" value="<?php if (isset($_POST['name'])) echo $stripslashes($_POST['name']); ?>" />
82 <div class="row buttons">
83 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
84 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?> " />
89 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>