2 /****************************************************************/
\r
4 /****************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\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
15 define('AT_INCLUDE_PATH', '../../../include/');
\r
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
\r
17 authenticate(AT_PRIV_FAQ);
\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
24 header('Location: edit_topic.php?id=' . $item);
\r
27 } else if (isset($_GET['delete'], $_GET['item'])) {
\r
28 $item = intval($_GET['item']);
\r
30 if (substr($_GET['item'], -1) == 'q') {
\r
31 header('Location: delete_question.php?id=' . $item);
\r
33 header('Location: delete_topic.php?id=' . $item);
\r
36 } else if (!empty($_GET)) {
\r
37 $msg->addError('NO_ITEM_SELECTED');
\r
40 require(AT_INCLUDE_PATH.'header.inc.php');
\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
47 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
\r
48 <table class="data" style="width: 90%;">
\r
52 <th style="width: 100%;"><?php echo _AT('name'); ?></th>
\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
61 <?php if ($row = mysql_fetch_assoc($result)) : ?>
\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
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
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
78 <?php } while ($entry_row = mysql_fetch_assoc($entry_result)); else: ?>
\r
81 <td><?php echo _AT('no_questions'); ?></td>
\r
84 <?php } while($row = mysql_fetch_assoc($result)); ?>
\r
88 <td colspan="2"><strong><?php echo _AT('none_found'); ?></strong></td>
\r
94 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>