remove old readme
[atutor.git] / mods / _standard / faq / index_instructor.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 \r
15 define('AT_INCLUDE_PATH', '../../../include/');\r
16 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
17 authenticate(AT_PRIV_FAQ);\r
18 \r
19 if (isset($_GET['edit'], $_GET['item'])) {\r
20         $item = intval($_GET['item']);\r
21         if (substr($_GET['item'], -1) == 'q') {\r
22                 header('Location: edit_question.php?id=' . $item);\r
23         } else {\r
24                 header('Location: edit_topic.php?id=' . $item);\r
25         }\r
26         exit;\r
27 } else if (isset($_GET['delete'], $_GET['item'])) {\r
28         $item = intval($_GET['item']);\r
29 \r
30         if (substr($_GET['item'], -1) == 'q') {\r
31                 header('Location: delete_question.php?id=' . $item);\r
32         } else {\r
33                 header('Location: delete_topic.php?id=' . $item);\r
34         }\r
35         exit;\r
36 } else if (!empty($_GET)) {\r
37         $msg->addError('NO_ITEM_SELECTED');\r
38 }\r
39 \r
40 require(AT_INCLUDE_PATH.'header.inc.php'); \r
41 \r
42 $counter = 1;\r
43 $sql     = "SELECT name, topic_id FROM ".TABLE_PREFIX."faq_topics WHERE course_id=$_SESSION[course_id] ORDER BY name";\r
44 $result  = mysql_query($sql, $db);\r
45 \r
46 $faq_topics = array(); \r
47 while ($row = mysql_fetch_assoc($result)) { \r
48         \r
49         $faq_topics[$row['topic_id']] = $row;\r
50         $entry_sql = "SELECT * FROM ".TABLE_PREFIX."faq_entries WHERE topic_id=$row[topic_id] ORDER BY question";\r
51         $entries = mysql_query($entry_sql, $db);\r
52         \r
53         while ($entry_result = mysql_fetch_assoc($entries))\r
54         {\r
55                 $faq_topics[$row['topic_id']]['entry_rows'][] = $entry_result;\r
56         }\r
57 }\r
58 \r
59 \r
60 \r
61 if ($_SESSION['id'] > 0){\r
62         $savant->assign('faq_topics', $faq_topics);     \r
63 }\r
64 else {\r
65         $savant->assign('faq_topics', $faq_topics);     \r
66         $savant->display('instructor/faq/index_instructor.tmpl.php');\r
67 }\r
68 \r
69 require(AT_INCLUDE_PATH.'footer.inc.php');  ?>