-
Notifications
You must be signed in to change notification settings - Fork 0
/
faq-manage.php
106 lines (93 loc) · 5.9 KB
/
faq-manage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
//
// TorrentTrader v2.x
// $LastChangedDate: 2011-11-13 22:38:48 +0000 (Sun, 13 Nov 2011) $
// $LastChangedBy: dj-howarth1 $
//
// http://www.torrenttrader.org
//
//
require_once("backend/functions.php");
dbconn(false);
loggedinonly();
if (!$CURUSER || $CURUSER["control_panel"]!="yes"){
show_error_msg(T_("ERROR"), T_("SORRY_NO_RIGHTS_TO_ACCESS"), 1);
}
stdhead(T_("FAQ_MANAGEMENT"));
begin_frame(T_("FAQ_MANAGEMENT"));
// make the array that has all the faq in a nice structured
$res = SQL_Query_exec("SELECT `id`, `question`, `flag`, `order` FROM `faq` WHERE `type`='categ' ORDER BY `order` ASC");
while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) {
$faq_categ[$arr[id]][title] = $arr[question];
$faq_categ[$arr[id]][flag] = $arr[flag];
$faq_categ[$arr[id]][order] = $arr[order];
}
$res = SQL_Query_exec("SELECT `id`, `question`, `flag`, `categ`, `order` FROM `faq` WHERE `type`='item' ORDER BY `order` ASC");
while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) {
$faq_categ[$arr[categ]][items][$arr[id]][question] = $arr[question];
$faq_categ[$arr[categ]][items][$arr[id]][flag] = $arr[flag];
$faq_categ[$arr[categ]][items][$arr[id]][order] = $arr[order];
}
if (isset($faq_categ)) {
// gather orphaned items
foreach ($faq_categ as $id => $temp) {
if (!array_key_exists("title", $faq_categ[$id])) {
foreach ($faq_categ[$id][items] as $id2 => $temp) {
$faq_orphaned[$id2][question] = $faq_categ[$id][items][$id2][question];
$faq_orphaned[$id2][flag] = $faq_categ[$id][items][$id2][flag];
unset($faq_categ[$id]);
}
}
}
// print the faq table
print("<form method=\"post\" action=\"faq-actions.php?action=reorder\">");
foreach ($faq_categ as $id => $temp) {
print("<br />\n<table border=\"0\" class=\"table_head\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\" width=\"95%\">\n");
print("<tr><th class=\"table_head\" colspan=\"2\">Position</th><th class=\"table_head\">Section/Item ".T_("TITLE").": </th><th class=\"table_head\">Status</th><th class=\"table_head\">Actions</th></tr>\n");
print("<tr><td class=\"table_col1\" align=\"center\" width=\"40px\"><select name=\"order[". $id ."]\">");
for ($n=1; $n <= count($faq_categ); $n++) {
$sel = ($n == $faq_categ[$id][order]) ? " selected=\"selected\"" : "";
print("<option value=\"$n\"". $sel .">". $n ."</option>");
}
$status = ($faq_categ[$id][flag] == "0") ? "<font color=\"red\">Hidden</font>" : "Normal";
print("</select></td><td class=\"table_col2\" align=\"center\" width=\"40px\"> </td><td class=\"table_col1\"><b>". stripslashes($faq_categ[$id][title]) ."</b></td><td class=\"ttable_col2\" align=\"center\" width=\"60px\">". $status ."</td><td class=\"ttable_col1\" align=\"center\" width=\"60px\"><a href=\"faq-actions.php?action=edit&id=". $id ."\">edit</a> <a href=\"faq-actions.php?action=delete&id=". $id ."\">delete</a></td></tr>\n");
if (array_key_exists("items", $faq_categ[$id])) {
foreach ($faq_categ[$id][items] as $id2 => $temp) {
print("<tr><td class=\"ttable_col1\" align=\"center\" width=\"40px\"> </td><td class=\"table_col2\" align=\"center\" width=\"40px\"><select name=\"order[". $id2 ."]\">");
for ($n=1; $n <= count($faq_categ[$id][items]); $n++) {
$sel = ($n == $faq_categ[$id][items][$id2][order]) ? " selected=\"selected\"" : "";
print("<option value=\"$n\"". $sel .">". $n ."</option>");
}
if ($faq_categ[$id][items][$id2][flag] == "0") $status = "<font color=\"#ff0000\">Hidden</font>";
elseif ($faq_categ[$id][items][$id2][flag] == "2") $status = "<font color=\"#0000FF\">Updated</font>";
elseif ($faq_categ[$id][items][$id2][flag] == "3") $status = "<font color=\"#008000\">New</font>";
else $status = "Normal";
print("</select></td><td class=\"ttable_col1\">". stripslashes($faq_categ[$id][items][$id2][question]) ."</td><td class=\"table_col2\" align=\"center\" width=\"60px\">". $status ."</td><td class=\"ttable_col1\" align=\"center\" width=\"60px\"><a href=\"faq-actions.php?action=edit&id=". $id2 ."\">edit</a> <a href=\"faq-actions.php?action=delete&id=". $id2 ."\">delete</a></td></tr>\n");
}
}
print("<tr><td colspan=\"5\" align=\"center\"><a href=\"faq-actions.php?action=additem&inid=". $id ."\">Add new item</a></td></tr>\n");
print("</table>\n");
}
}
// print the orphaned items table
if (isset($faq_orphaned)) {
print("<br />\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\" width=\"95%\">\n");
print("<tr><td align=\"center\" colspan=\"3\"><b style=\"color: #ff0000\">Orphaned Items</b></td>\n");
print("<tr><td align=\"left\">Item ".T_("TITLE").": </td><td align=\"center\">Status</td><td align=\"center\">Actions</td></tr>\n");
foreach ($faq_orphaned as $id => $temp) {
if ($faq_orphaned[$id][flag] == "0") $status = "<font color=\"#ff0000\">Hidden</font>";
elseif ($faq_orphaned[$id][flag] == "2") $status = "<font color=\"#0000FF\">Updated</font>";
elseif ($faq_orphaned[$id][flag] == "3") $status = "<font color=\"#008000\">New</font>";
else $status = "Normal";
print("<tr><td>". stripslashes($faq_orphaned[$id][question]) ."</td><td align=\"center\" width=\"60px\">". $status ."</td><td align=\"center\" width=\"60px\"><a href=\"faq-actions.php?action=edit&id=". $id ."\">edit</a> <a href=\"faq-actions.php?action=delete&id=". $id ."\">delete</a></td></tr>\n");
}
print("</table>\n");
}
print("<br />\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\" width=\"95%\">\n<tr><td align=\"center\"><a href=\"faq-actions.php?action=addsection\">Add new section</a></td></tr>\n</table>\n");
print("<p align=\"center\"><input type=\"submit\" name=\"reorder\" value=\"Reorder\" /></p>\n");
print("</form>\n");
print("When the position numbers don't reflect the position in the table, it means the order id is bigger than the total number of sections/items and you should check all the order id's in the table and click \"reorder\"\n");
echo $pagerbottom;
end_frame();
stdfoot();
?>