admin_questions: More templates + sql fixes

main
Daniel Friesel 14 years ago
parent 200053d720
commit 5d9335fe18

@ -44,7 +44,17 @@ function admin_groups() {
$privileges = sql_select("SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` LEFT OUTER JOIN `GroupPrivileges` ON (`Privileges`.`id` = `GroupPrivileges`.`privilege_id` AND `GroupPrivileges`.`group_id`=" . sql_escape($id) . ") ORDER BY `Privileges`.`name`"); $privileges = sql_select("SELECT `Privileges`.*, `GroupPrivileges`.`group_id` FROM `Privileges` LEFT OUTER JOIN `GroupPrivileges` ON (`Privileges`.`id` = `GroupPrivileges`.`privilege_id` AND `GroupPrivileges`.`group_id`=" . sql_escape($id) . ") ORDER BY `Privileges`.`name`");
$privileges_html = ""; $privileges_html = "";
foreach ($privileges as $priv) foreach ($privileges as $priv)
$privileges_html .= '<tr><td><input type="checkbox" name="privileges[]" value="' . $priv['id'] . '"' . ($priv['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $priv['name'] . '</td><td>' . $priv['desc'] . '</td></tr>'; $privileges_html .= sprintf(
'<tr><td><input type="checkbox" '
. 'name="privileges[]" value="%s" %s />'
. '</td> <td>%s</td> <td>%s</td></tr>',
$priv['id'],
($priv['group_id'] != ""
? 'checked="checked"'
: ''),
$priv['name'],
$priv['desc']
);
$html .= template_render('../templates/admin_groups_edit_form.html', array ( $html .= template_render('../templates/admin_groups_edit_form.html', array (
'link' => page_link_to("admin_groups"), 'link' => page_link_to("admin_groups"),

@ -72,19 +72,29 @@ function admin_language() {
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
if ($k != "TextID") { if ($k != "TextID") {
$sql_test = "SELECT * FROM `Sprache` " . $sql_test = "SELECT * FROM `Sprache` " .
"WHERE `TextID`='" . $_POST["TextID"] . "' AND `Sprache`='$k'"; "WHERE `TextID`='" . sql_escape($_POST["TextID"])
. "' AND `Sprache`='"
. sql_escape($k) . "'";
$erg_test = sql_query($sql_test); $erg_test = sql_query($sql_test);
if (mysql_num_rows($erg_test) == 0) { if (mysql_num_rows($erg_test) == 0) {
$sql_save = "INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) " . $sql_save = "INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) " .
"VALUES ('" . $_POST["TextID"] . "', '$k', '$v')"; "VALUES ('" . sql_escape($_POST["TextID"]) . "', '"
. sql_escape($k) . "', '"
. sql_escape($v) . "')";
$html .= $sql_save . "<br />"; $html .= $sql_save . "<br />";
$Erg = sql_query($sql_save); $Erg = sql_query($sql_save);
$html .= success("$k Save: OK<br />\n"); $html .= success("$k Save: OK<br />\n");
} else } else
if (mysql_result($erg_test, 0, "Text") != $v) { if (mysql_result($erg_test, 0, "Text") != $v) {
$sql_save = "UPDATE `Sprache` SET `Text`='$v' " . $sql_save = "UPDATE `Sprache` SET `Text`='"
"WHERE `TextID`='" . $_POST["TextID"] . "' AND `Sprache`='$k' "; . sql_escape($v) . "' " .
"WHERE `TextID`='"
. sql_escape($_POST["TextID"])
. "' AND `Sprache`='" . sql_escape($k) . "' ";
$html .= $sql_save . "<br />"; $html .= $sql_save . "<br />";
$Erg = sql_query($sql_save); $Erg = sql_query($sql_save);
$html .= success(" $k Update: OK<br />\n"); $html .= success(" $k Update: OK<br />\n");

@ -18,19 +18,28 @@ function admin_questions() {
if (!isset ($_REQUEST['action'])) { if (!isset ($_REQUEST['action'])) {
$open_questions = ""; $open_questions = "";
$questions = sql_select("SELECT * FROM `Questions` WHERE `AID`=0"); $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`=0");
foreach ($questions as $question) { foreach ($questions as $question)
$open_questions .= '<tr><td>' . UID2Nick($question['UID']) . '</td><td>' . str_replace("\n", '<br />', $question['Question']) . '</td>'; $open_questions .= template_render(
$open_questions .= '<td><form action="' . page_link_to("admin_questions") . '&action=answer" method="post"><textarea name="answer"></textarea><input type="hidden" name="id" value="' . $question['QID'] . '" /><br /><input type="submit" name="submit" value="Send" /></form></td>'; '../templates/admin_question_unanswered.html', array (
$open_questions .= '<td><a href="' . page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'] . '">Delete</a></td><tr>'; 'question_nick' => UID2Nick($question['UID']),
} 'question_id' => $question['QID'],
'link' => page_link_to("admin_questions"),
'question' => str_replace("\n", '<br />', $question['Question'])
));
$answered_questions = ""; $answered_questions = "";
$questions = sql_select("SELECT * FROM `Questions` WHERE `AID`>0"); $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`>0");
foreach ($questions as $question) {
$answered_questions .= '<tr><td>' . UID2Nick($question['UID']) . '</td><td>' . str_replace("\n", '<br />', $question['Question']) . '</td>'; foreach ($questions as $question)
$answered_questions .= '<td>' . UID2Nick($question['AID']) . '</td><td>' . str_replace("\n", '<br />', $question['Answer']) . '</td>'; $answered_questions .= template_render(
$answered_questions .= '<td><a href="' . page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'] . '">Delete</a></td><tr>'; '../templates/admin_question_answered.html', array (
} 'question_id' => $question['QID'],
'question_nick' => UID2Nick($question['UID']),
'question' => str_replace("\n", "<br />", $question['Question']),
'answer_nick' => UID2Nick($question['AID']),
'answer' => str_replace("\n", "<br />", $question['Answer']),
'link' => page_link_to("admin_questions"),
));
return template_render('../templates/admin_questions.html', array ( return template_render('../templates/admin_questions.html', array (
'link' => page_link_to("admin_questions"), 'link' => page_link_to("admin_questions"),

@ -0,0 +1,9 @@
<tr>
<td> %question_nick% </td>
<td> %question% </td>
<td> %answer_nick% </td>
<td> %answer% </td>
<td>
<a href="%link%&action=delete&id=%question_id%">Delete</a>
</td>
</tr>

@ -0,0 +1,14 @@
<tr>
<td> %question_nick% </td>
<td> %question% </td>
<td>
<form action="%link%&action=answer" method="post">
<textarea name="answer"></textarea>
<input type="hidden" name="id" value="%question_id%" />
<input type="submit" name="submit" value="Send" />
</form>
</td>
<td>
<a href="%link%&action=delete&id=%question_id%">Delete</a>
</td>
</tr>

@ -24,6 +24,9 @@ Not yet answered questions:
<table> <table>
<thead> <thead>
<tr> <tr>
<th>
From
</th>
<th> <th>
Question Question
</th> </th>
@ -33,9 +36,6 @@ Not yet answered questions:
<th> <th>
Answer Answer
</th> </th>
<th>
From
</th>
<th> <th>
&nbsp; &nbsp;
</th> </th>

Loading…
Cancel
Save