bcbcb530e57442e999daff01ad96573002fbb17a
[atutor.git] / docs / mods / _standard / faq / add_topic.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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 /****************************************************************/
13 // $Id$
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
16
17 authenticate(AT_PRIV_FAQ);
18
19 if (isset($_POST['cancel'])) {
20         $msg->addFeedback('CANCELLED');
21         header('Location: index_instructor.php');
22         exit;
23 } else if (isset($_POST['submit'])) {
24         if (trim($_POST['name']) == '') {
25                 $msg->addError('NAME_EMPTY');
26         }
27
28         if (!$msg->containsErrors()) {
29                 $_POST['name'] = $addslashes($_POST['name']);
30                 //This will truncate the content of the length to 240 as defined in the db.
31                 $_POST['name'] = validate_length($_POST['name'], 250);
32
33                 $sql    = "INSERT INTO ".TABLE_PREFIX."faq_topics VALUES (NULL, $_SESSION[course_id], '$_POST[name]')";
34                 $result = mysql_query($sql,$db);
35                 
36                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
37                 header('Location: index_instructor.php');
38                 exit;
39         }
40 }
41
42 $onload = 'document.form.name.focus();';
43
44 require(AT_INCLUDE_PATH.'header.inc.php');
45
46
47 $savant->display('instructor/faq/add_topic.tmpl.php');
48 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>