summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2011-06-03 00:22:11 +0200
committerPhilip Häusler <msquare@notrademark.de>2011-06-03 00:22:11 +0200
commit32b3ce5f900cf0d378f77a6675b989ee0e641f13 (patch)
tree2fa10cafaf731ffd8ba1e795b72cd72f73e6ae8b
parent576c9680cf8650b6120bbb1e8ae3befdeae4155e (diff)
admin questions
-rw-r--r--DB/db_rewrite.sql43
-rw-r--r--includes/pages/admin_questions.php76
-rw-r--r--includes/pages/user_messages.php10
-rw-r--r--includes/pages/user_questions.php17
-rw-r--r--includes/sys_menu.php7
-rw-r--r--templates/admin_questions.html47
-rw-r--r--templates/user_questions.html2
-rw-r--r--www-ssl/index.php8
8 files changed, 181 insertions, 29 deletions
diff --git a/DB/db_rewrite.sql b/DB/db_rewrite.sql
index 6a259c61..5d6b4e2c 100644
--- a/DB/db_rewrite.sql
+++ b/DB/db_rewrite.sql
@@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: localhost
--- Erstellungszeit: 02. Juni 2011 um 21:45
+-- Erstellungszeit: 02. Juni 2011 um 22:21
-- Server Version: 5.1.44
-- PHP-Version: 5.3.1
@@ -71,19 +71,20 @@ CREATE TABLE IF NOT EXISTS `Counter` (
--
INSERT INTO `Counter` (`URL`, `Anz`) VALUES
-('news', 78),
-('login', 20),
-('logout', 12),
-('start', 24),
-('faq', 4),
+('news', 80),
+('login', 24),
+('logout', 13),
+('start', 25),
+('faq', 6),
('credits', 3),
('register', 3),
('admin_rooms', 70),
('admin_angel_types', 69),
('user_settings', 116),
-('user_messages', 107),
-('admin_groups', 94),
-('user_questions', 30);
+('user_messages', 108),
+('admin_groups', 99),
+('user_questions', 53),
+('admin_questions', 41);
-- --------------------------------------------------------
@@ -127,7 +128,7 @@ CREATE TABLE IF NOT EXISTS `GroupPrivileges` (
`privilege_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `group_id` (`group_id`,`privilege_id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=33 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=36 ;
--
-- Daten für Tabelle `GroupPrivileges`
@@ -139,11 +140,12 @@ INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES
(31, -2, 11),
(30, -2, 9),
(23, -1, 2),
-(6, -4, 6),
-(7, -4, 7),
+(34, -4, 12),
+(33, -4, 7),
(29, -2, 3),
(28, -2, 4),
-(12, -5, 10);
+(12, -5, 10),
+(35, -4, 6);
-- --------------------------------------------------------
@@ -254,7 +256,7 @@ CREATE TABLE IF NOT EXISTS `Privileges` (
`desc` varchar(1024) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
--
-- Daten für Tabelle `Privileges`
@@ -271,7 +273,8 @@ INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES
(8, 'user_settings', 'User profile settings'),
(9, 'user_messages', 'Writing and reading messages from user to user'),
(10, 'admin_groups', 'Manage usergroups and their rights'),
-(11, 'user_questions', 'Let users ask questions');
+(11, 'user_questions', 'Let users ask questions'),
+(12, 'admin_questions', 'Answer user''s questions');
-- --------------------------------------------------------
@@ -286,14 +289,14 @@ CREATE TABLE IF NOT EXISTS `Questions` (
`AID` int(11) NOT NULL DEFAULT '0',
`Answer` text NOT NULL,
PRIMARY KEY (`QID`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Fragen und Antworten' AUTO_INCREMENT=4 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Fragen und Antworten' AUTO_INCREMENT=5 ;
--
-- Daten für Tabelle `Questions`
--
INSERT INTO `Questions` (`QID`, `UID`, `Question`, `AID`, `Answer`) VALUES
-(3, 1, 'Ficken?', 0, '');
+(4, 1, 'Hallo?\nEy?', 1, 'Jo,\nJo!');
-- --------------------------------------------------------
@@ -1004,7 +1007,9 @@ INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES
('admin_groups', 'DE', 'Gruppenrechte'),
('admin_groups', 'EN', 'Grouprights'),
('user_questions', 'DE', 'Erzengel fragen'),
-('user_questions', 'EN', 'Ask arch angel');
+('user_questions', 'EN', 'Ask arch angel'),
+('admin_questions', 'DE', 'Fragen beantworten'),
+('admin_questions', 'EN', 'Answer questions');
-- --------------------------------------------------------
@@ -1047,7 +1052,7 @@ CREATE TABLE IF NOT EXISTS `User` (
--
INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`, `Handy`, `email`, `ICQ`, `jabber`, `Size`, `Passwort`, `Gekommen`, `Aktiv`, `Tshirt`, `color`, `Sprache`, `Avatar`, `Menu`, `lastLogIn`, `CreateDate`, `Art`, `kommentar`, `Hometown`) VALUES
-(1, 'admin', '', '', 0, '', '', '', '', '', '', 'L', '21232f297a57a5a743894a0e4a801fc3', 0, 0, 0, 10, 'DE', 115, 'L', 1307051093, '0000-00-00 00:00:00', '', '', ''),
+(1, 'admin', '', '', 0, '', '', '', '', '', '', 'L', '21232f297a57a5a743894a0e4a801fc3', 0, 0, 0, 10, 'DE', 115, 'L', 1307053257, '0000-00-00 00:00:00', '', '', ''),
(147, 'msquare', '', '', 23, '', '', '', 'msquare@notrademark.de', '', '', 'L', 'e10adc3949ba59abbe56e057f20f883e', 0, 0, 0, 6, 'EN', 0, 'L', 1307042703, '2011-06-02 00:55:09', '', '', '');
-- --------------------------------------------------------
diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php
new file mode 100644
index 00000000..5355dd86
--- /dev/null
+++ b/includes/pages/admin_questions.php
@@ -0,0 +1,76 @@
+<?php
+function admin_new_questions() {
+ global $user, $privileges;
+
+ if (in_array("admin_questions", $privileges)) {
+ $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID`=0");
+
+ if ($new_messages > 0)
+ return '<p class="notice"><a href="' . page_link_to("admin_questions") . '">There are unanswered questions!</a></p><hr />';
+ }
+
+ return "";
+}
+
+function admin_questions() {
+ global $user;
+
+ if (!isset ($_REQUEST['action'])) {
+ $open_questions = "";
+ $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`=0");
+ foreach ($questions as $question) {
+ $open_questions .= '<tr><td>' . UID2Nick($question['UID']) . '</td><td>' . str_replace("\n", '<br />', $question['Question']) . '</td>';
+ $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>';
+ $open_questions .= '<td><a href="' . page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'] . '">Delete</a></td><tr>';
+ }
+
+ $answered_questions = "";
+ $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>';
+ $answered_questions .= '<td>' . UID2Nick($question['AID']) . '</td><td>' . str_replace("\n", '<br />', $question['Answer']) . '</td>';
+ $answered_questions .= '<td><a href="' . page_link_to("admin_questions") . '&action=delete&id=' . $question['QID'] . '">Delete</a></td><tr>';
+ }
+
+ return template_render('../templates/admin_questions.html', array (
+ 'link' => page_link_to("admin_questions"),
+ 'open_questions' => $open_questions,
+ 'answered_questions' => $answered_questions
+ ));
+ } else {
+ switch ($_REQUEST['action']) {
+ case 'answer' :
+ if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
+ $id = $_REQUEST['id'];
+ else
+ return error("Incomplete call, missing Question ID.");
+
+ $question = sql_select("SELECT * FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
+ if (count($question) > 0 && $question[0]['AID'] == "0") {
+ $answer = trim(preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['answer'])));
+
+ if ($answer != "") {
+ sql_query("UPDATE `Questions` SET `AID`=" . sql_escape($user['UID']) . ", `Answer`='" . sql_escape($answer) . "' WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
+ header("Location: " . page_link_to("admin_questions"));
+ } else
+ return error("Please enter an answer!");
+ } else
+ return error("No question found.");
+ break;
+ case 'delete' :
+ if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
+ $id = $_REQUEST['id'];
+ else
+ return error("Incomplete call, missing Question ID.");
+
+ $question = sql_select("SELECT * FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
+ if (count($question) > 0) {
+ sql_query("DELETE FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
+ header("Location: " . page_link_to("admin_questions"));
+ } else
+ return error("No question found.");
+ break;
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php
index e3e9a469..30871d9d 100644
--- a/includes/pages/user_messages.php
+++ b/includes/pages/user_messages.php
@@ -1,11 +1,13 @@
<?php
function user_unread_messages() {
- global $user;
+ global $user, $privileges;
- $new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`=" . sql_escape($user['UID']));
+ if (in_array("user_messages", $privileges)) {
+ $new_messages = sql_num_query("SELECT * FROM `Messages` WHERE isRead='N' AND `RUID`=" . sql_escape($user['UID']));
- if ($new_messages > 0)
- return '<p class="notice"><a href="' . page_link_to("user_messages") . '">' . Get_Text("pub_messages_new1") . " " . $new_messages . " " . Get_Text("pub_messages_new2") . '</a></p><hr />';
+ if ($new_messages > 0)
+ return '<p class="notice"><a href="' . page_link_to("user_messages") . '">' . Get_Text("pub_messages_new1") . " " . $new_messages . " " . Get_Text("pub_messages_new2") . '</a></p><hr />';
+ }
return "";
}
diff --git a/includes/pages/user_questions.php b/includes/pages/user_questions.php
index 8201c6d6..4e9daa5a 100644
--- a/includes/pages/user_questions.php
+++ b/includes/pages/user_questions.php
@@ -6,11 +6,20 @@ function user_questions() {
$open_questions = "";
$questions = sql_select("SELECT * FROM `Questions` WHERE `AID`=0 AND `UID`=" . sql_escape($user['UID']));
foreach ($questions as $question)
- $open_questions .= '<tr><td>' . $question['Question'] . '</td><td><a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">Delete</a></td><tr>';
+ $open_questions .= '<tr><td>' . str_replace("\n", '<br />', $question['Question']) . '</td><td><a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">Delete</a></td><tr>';
+
+ $answered_questions = "";
+ $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`>0 AND `UID`=" . sql_escape($user['UID']));
+ foreach ($questions as $question) {
+ $answered_questions .= '<tr><td>' . str_replace("\n", '<br />', $question['Question']) . '</td>';
+ $answered_questions .= '<td>' . UID2Nick($question['AID']) . '</td><td>' . str_replace("\n", '<br />', $question['Answer']) . '</td>';
+ $answered_questions .= '<td><a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">Delete</a></td><tr>';
+ }
return template_render('../templates/user_questions.html', array (
'link' => page_link_to("user_questions"),
- 'open_questions' => $open_questions
+ 'open_questions' => $open_questions,
+ 'answered_questions' => $answered_questions
));
} else {
switch ($_REQUEST['action']) {
@@ -20,7 +29,7 @@ function user_questions() {
sql_query("INSERT INTO `Questions` SET `UID`=" . sql_escape($user['UID']) . ", `Question`='" . sql_escape($question) . "'");
header("Location: " . page_link_to("user_questions"));
} else
- return error("Please enter a Question!");
+ return error("Please enter a question!");
break;
case 'delete' :
if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id']))
@@ -33,7 +42,7 @@ function user_questions() {
sql_query("DELETE FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1");
header("Location: " . page_link_to("user_questions"));
} else
- return error("No Question found.");
+ return error("No question found.");
break;
}
}
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index 6cddf66a..c3dfa041 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -29,6 +29,7 @@ function make_navigation() {
// Admin Navigation
$menu .= make_navigation_for(Get_Text('admin/'), array (
+ "admin_questions",
"admin_angel_types",
"admin_rooms",
"admin_groups"
@@ -39,9 +40,13 @@ function make_navigation() {
function make_navigation_for($name, $pages) {
global $privileges, $p;
+ $specials = array (
+ "faq"
+ );
+
$menu = "";
foreach ($pages as $page)
- if (in_array($page, $privileges))
+ if (in_array($page, $privileges) || in_array($page, $specials))
$menu .= '<li' . ($page == $p ? ' class="selected"' : '') . '><a href="' . page_link_to($page) . '">' . Get_Text($page) . '</a></li>';
if ($menu != "")
diff --git a/templates/admin_questions.html b/templates/admin_questions.html
new file mode 100644
index 00000000..ad8d6572
--- /dev/null
+++ b/templates/admin_questions.html
@@ -0,0 +1,47 @@
+Not yet answered questions:
+<table>
+ <thead>
+ <tr>
+ <th>
+ From
+ </th>
+ <th>
+ Question
+ </th>
+ <th>
+ Answer
+ </th>
+ <th>
+ &nbsp;
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ %open_questions%
+ </tbody>
+</table>
+<hr/> Answered questions:
+<table>
+ <thead>
+ <tr>
+ <th>
+ Question
+ </th>
+ <th>
+ From
+ </th>
+ <th>
+ Answer
+ </th>
+ <th>
+ From
+ </th>
+ <th>
+ &nbsp;
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ %answered_questions%
+ </tbody>
+</table>
diff --git a/templates/user_questions.html b/templates/user_questions.html
index 96b1e980..f5fb46ae 100644
--- a/templates/user_questions.html
+++ b/templates/user_questions.html
@@ -36,7 +36,7 @@ Not yet answered questions:
%answered_questions%
</tbody>
</table>
-<hr/>
+<hr/>Ask an arch angel:
<form action="%link%&action=ask" method="post">
<table>
<tr>
diff --git a/www-ssl/index.php b/www-ssl/index.php
index 831225e6..d722de32 100644
--- a/www-ssl/index.php
+++ b/www-ssl/index.php
@@ -13,6 +13,7 @@ require_once ('includes/sys_user.php');
require_once ('config/config.php');
require_once ('config/config_db.php');
+require_once ('includes/pages/admin_questions.php');
require_once ('includes/pages/user_messages.php');
session_start();
@@ -58,6 +59,9 @@ if (in_array($p, $privileges)) {
require_once ('includes/pages/guest_login.php');
$content = guest_logout();
}
+ elseif ($p == "admin_questions") {
+ $content = admin_questions();
+ }
elseif ($p == "admin_angel_types") {
require_once ('includes/pages/admin_angel_types.php');
$content = admin_angel_types();
@@ -96,6 +100,10 @@ elseif ($p == "faq") {
if (isset ($user) && $p != "user_messages")
$content = user_unread_messages() . $content;
+// Erzengel Hinweis für unbeantwortete Fragen
+if (isset ($user) && $p != "admin_questions")
+ $content = admin_new_questions() . $content;
+
echo template_render('../templates/layout.html', array (
'theme' => isset ($user) ? $user['color'] : $default_theme,
'title' => $title,