SVN tag for release should only contain scripts in "docs" folder without "mods",...
[atutor.git] / docs / 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 \r
47 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">\r
48 <table class="data" style="width: 90%;">\r
49 <thead>\r
50 <tr>\r
51         <th>&nbsp;</th>\r
52         <th style="width: 100%;"><?php echo _AT('name'); ?></th>\r
53 </tr>\r
54 </thead>\r
55 <tfoot>\r
56 <tr>\r
57         <td colspan="2"><input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> \r
58                                     <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /></td>\r
59 </tr>\r
60 </tfoot>\r
61 <?php if ($row = mysql_fetch_assoc($result)) : ?>\r
62 <tbody>\r
63                 <?php do { ?>\r
64                         <tr onmousedown="document.form['t<?php echo $row['topic_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['topic_id']; ?>_0">\r
65                                 <th style="border-top:1pt solid #e0e0e0;"><input type="radio" name="item" id="t<?php echo $row['topic_id']; ?>" value="<?php echo $row['topic_id']; ?>" /></th>\r
66                                 <th style="border-top:1pt solid #e0e0e0;"><?php echo htmlentities_utf8($row['name']); ?></th>\r
67                         </tr>\r
68                         <?php \r
69                                 $entry_sql = "SELECT * FROM ".TABLE_PREFIX."faq_entries WHERE topic_id=$row[topic_id] ORDER BY question";\r
70                                 $entry_result = mysql_query($entry_sql, $db);\r
71                         ?>\r
72 \r
73                         <?php if ($entry_row = mysql_fetch_assoc($entry_result)) : do { ?>\r
74                                 <tr onmousedown="document.form['q<?php echo $entry_row['entry_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['topic_id']; ?>_<?php echo $entry_row['entry_id']; ?>">\r
75                                         <td><input type="radio" name="item" id="q<?php echo $entry_row['entry_id']; ?>" value="<?php echo $entry_row['entry_id']; ?>q" /></td>\r
76                                         <td><?php echo htmlentities_utf8($entry_row['question']); ?></td>\r
77                                 </tr>\r
78                         <?php } while ($entry_row = mysql_fetch_assoc($entry_result)); else: ?>\r
79                                 <tr>\r
80                                         <td>&nbsp;</td>\r
81                                         <td><?php echo _AT('no_questions'); ?></td>\r
82                                 </tr>\r
83                         <?php endif; ?>\r
84                 <?php } while($row = mysql_fetch_assoc($result)); ?>\r
85 </tbody>\r
86 <?php else: ?>\r
87         <tr>\r
88                 <td colspan="2"><strong><?php echo _AT('none_found'); ?></strong></td>\r
89         </tr>\r
90 <?php endif; ?>\r
91 </table>\r
92 </form>\r
93 \r
94 <?php require(AT_INCLUDE_PATH.'footer.inc.php');  ?>