remove old readme
[atutor.git] / mods / _standard / faq / delete_question.php
1 <?php\r
2 /****************************************************************/\r
3 /* ATutor                                                                                                               */\r
4 /****************************************************************/\r
5 /* Copyright (c) 2002-2010                                      */\r
6 /* Inclusive Design Institute                                   */\r
7 /* http://atutor.ca                                                                                             */\r
8 /*                                                              */\r
9 /* This program is free software. You can redistribute it and/or*/\r
10 /* modify it under the terms of the GNU General Public License  */\r
11 /* as published by the Free Software Foundation.                                */\r
12 /****************************************************************/\r
13 // $Id$\r
14 define('AT_INCLUDE_PATH', '../../../include/');\r
15 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
16 \r
17 authenticate(AT_PRIV_FAQ);\r
18 \r
19 if (isset($_POST['submit_no'])) {\r
20         $msg->addFeedback('CANCELLED');\r
21         Header('Location: index_instructor.php');\r
22         exit;\r
23 } else if (isset($_POST['submit_yes'])) {\r
24         $_POST['id'] = intval($_POST['id']);\r
25         $_POST['topic_id'] = intval($_POST['topic_id']);\r
26 \r
27         // check that this topic_id belongs to this course:\r
28         $sql    = "SELECT topic_id FROM ".TABLE_PREFIX."faq_topics WHERE topic_id=$_POST[topic_id] AND course_id=$_SESSION[course_id]";\r
29         $result = mysql_query($sql, $db);\r
30         if ($row = mysql_fetch_assoc($result)) {\r
31                 $sql = "DELETE FROM ".TABLE_PREFIX."faq_entries WHERE entry_id=$_POST[id] AND topic_id=$_POST[topic_id]";\r
32                 $result = mysql_query($sql, $db);\r
33         }\r
34 \r
35         $msg->addFeedback('QUESTION_DELETED');\r
36         header('Location: index_instructor.php');\r
37         exit;\r
38 }\r
39 \r
40 require(AT_INCLUDE_PATH.'header.inc.php');\r
41 \r
42 \r
43 $_GET['id'] = intval($_GET['id']); \r
44 \r
45 $sql = "SELECT question, topic_id FROM ".TABLE_PREFIX."faq_entries WHERE entry_id=$_GET[id]";\r
46 \r
47 $result = mysql_query($sql,$db);\r
48 if ($row = mysql_fetch_assoc($result)) {\r
49         $hidden_vars['topic_id'] = $row['topic_id'];\r
50         $hidden_vars['id'] = $_GET['id'];\r
51 \r
52         $confirm = array('DELETE_FAQ_QUESTION', AT_print($row['question'], 'faqs.question'));\r
53         $msg->addConfirm($confirm, $hidden_vars);\r
54         $msg->printConfirm();\r
55 } else {\r
56         $msg->addError('ITEM_NOT_FOUND');\r
57 }\r
58 \r
59 require(AT_INCLUDE_PATH.'footer.inc.php');\r
60 \r
61 ?>