1ee6a9a0acedceff3c5cbf26ebea08583d876587
[atutor.git] / docs / mods / _standard / faq / delete_topic.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 \r
26         // check that this topic_id belongs to this course:\r
27         $sql = "DELETE FROM ".TABLE_PREFIX."faq_topics WHERE topic_id=$_POST[id] AND course_id=$_SESSION[course_id]";\r
28         $result = mysql_query($sql, $db);\r
29         if (mysql_affected_rows($db) == 1) {\r
30                 $sql = "DELETE FROM ".TABLE_PREFIX."faq_entries WHERE topic_id=$_POST[topic_id]";\r
31                 $result = mysql_query($sql, $db);\r
32         }\r
33 \r
34         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');\r
35         header('Location: index_instructor.php');\r
36         exit;\r
37 }\r
38 \r
39 require(AT_INCLUDE_PATH.'header.inc.php');\r
40 \r
41 \r
42 $_GET['id'] = intval($_GET['id']); \r
43 \r
44 $sql = "SELECT name, topic_id FROM ".TABLE_PREFIX."faq_topics WHERE topic_id=$_GET[id]";\r
45 \r
46 $result = mysql_query($sql,$db);\r
47 if ($row = mysql_fetch_assoc($result)) {\r
48         $hidden_vars['id'] = $_GET['id'];\r
49 \r
50         $confirm = array('DELETE_FAQ_TOPIC', AT_print($row['name'], 'faqs.topic'));\r
51         $msg->addConfirm($confirm, $hidden_vars);\r
52         $msg->printConfirm();\r
53 } else {\r
54         $msg->addError('ITEM_NOT_FOUND');\r
55 }\r
56 \r
57 require(AT_INCLUDE_PATH.'footer.inc.php');\r
58 ?>