user questions

This commit is contained in:
Philip Häusler 2011-06-02 23:45:54 +02:00
parent 3afd05636e
commit 0d6499f7f1
7 changed files with 125 additions and 30 deletions

View File

@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 02. Juni 2011 um 20:39
-- Erstellungszeit: 02. Juni 2011 um 21:45
-- Server Version: 5.1.44
-- PHP-Version: 5.3.1
@ -71,18 +71,19 @@ CREATE TABLE IF NOT EXISTS `Counter` (
--
INSERT INTO `Counter` (`URL`, `Anz`) VALUES
('news', 73),
('login', 18),
('logout', 11),
('start', 23),
('news', 78),
('login', 20),
('logout', 12),
('start', 24),
('faq', 4),
('credits', 3),
('register', 3),
('admin_rooms', 70),
('admin_angel_types', 69),
('user_settings', 115),
('user_messages', 102),
('admin_groups', 86);
('user_settings', 116),
('user_messages', 107),
('admin_groups', 94),
('user_questions', 30);
-- --------------------------------------------------------
@ -126,21 +127,22 @@ 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=28 ;
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=33 ;
--
-- Daten für Tabelle `GroupPrivileges`
--
INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES
(32, -2, 8),
(24, -1, 5),
(3, -2, 3),
(4, -2, 4),
(31, -2, 11),
(30, -2, 9),
(23, -1, 2),
(6, -4, 6),
(7, -4, 7),
(8, -2, 8),
(9, -2, 9),
(29, -2, 3),
(28, -2, 4),
(12, -5, 10);
-- --------------------------------------------------------
@ -192,8 +194,6 @@ CREATE TABLE IF NOT EXISTS `Messages` (
INSERT INTO `Messages` (`id`, `Datum`, `SUID`, `RUID`, `isRead`, `Text`) VALUES
(2, 1307042342, 1, 147, 'Y', 'asdfasdfasdfasdf'),
(4, 1307042622, 1, 147, 'Y', 'asdfasdfasdf'),
(5, 1307042643, 1, 147, 'Y', 'foobar'),
(6, 1307042663, 1, 147, 'Y', 'foobar'),
(7, 1307042692, 147, 1, 'Y', 'foobar');
-- --------------------------------------------------------
@ -254,7 +254,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=11 ;
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
--
-- Daten für Tabelle `Privileges`
@ -270,7 +270,8 @@ INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES
(7, 'admin_angel_types', 'Engel Typen administrieren'),
(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');
(10, 'admin_groups', 'Manage usergroups and their rights'),
(11, 'user_questions', 'Let users ask questions');
-- --------------------------------------------------------
@ -285,12 +286,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=21 ;
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Fragen und Antworten' AUTO_INCREMENT=4 ;
--
-- Daten für Tabelle `Questions`
--
INSERT INTO `Questions` (`QID`, `UID`, `Question`, `AID`, `Answer`) VALUES
(3, 1, 'Ficken?', 0, '');
-- --------------------------------------------------------
@ -999,7 +1002,9 @@ INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES
('pub_messages_Neu', 'DE', 'Neu'),
('pub_messages_Neu', 'EN', 'New'),
('admin_groups', 'DE', 'Gruppenrechte'),
('admin_groups', 'EN', 'Grouprights');
('admin_groups', 'EN', 'Grouprights'),
('user_questions', 'DE', 'Erzengel fragen'),
('user_questions', 'EN', 'Ask arch angel');
-- --------------------------------------------------------
@ -1042,7 +1047,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', 1307046926, '0000-00-00 00:00:00', '', '', ''),
(1, 'admin', '', '', 0, '', '', '', '', '', '', 'L', '21232f297a57a5a743894a0e4a801fc3', 0, 0, 0, 10, 'DE', 115, 'L', 1307051093, '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', '', '', '');
-- --------------------------------------------------------

View File

@ -0,0 +1,41 @@
<?php
function user_questions() {
global $user;
if (!isset ($_REQUEST['action'])) {
$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>';
return template_render('../templates/user_questions.html', array (
'link' => page_link_to("user_questions"),
'open_questions' => $open_questions
));
} else {
switch ($_REQUEST['action']) {
case 'ask' :
$question = trim(preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['question'])));
if ($question != "") {
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!");
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 && $question[0]['UID'] == $user['UID']) {
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.");
break;
}
}
}
?>

View File

@ -23,6 +23,7 @@ function make_navigation() {
$menu .= make_navigation_for(Get_Text('inc_schicht_engel'), array (
"news",
"user_messages",
"user_questions",
"user_settings"
));

View File

@ -0,0 +1,52 @@
Not yet answered questions:
<table>
<thead>
<tr>
<th>
Question
</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>
&nbsp;
</th>
</tr>
</thead>
<tbody>
%answered_questions%
</tbody>
</table>
<hr/>
<form action="%link%&action=ask" method="post">
<table>
<tr>
<td>
Question:
</td>
<td>
<textarea name="question"></textarea>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Ask" />
</form>

View File

@ -1,12 +1,12 @@
* MD5-Passwörter mit Salt speichern
* Passwort-Mindestanforderungen stellen
* User-Avatare
* User-Avatare (code liegt auskommentiert in user_settings.php)
* user_messages schön machen
* Formulare weg von Tabellen
* user_news lässt sich nicht bedienen (POST ohne redirects...)
* Privilegien korrigieren (an die vom CVS anpassen)
* Beim Raum-Management die benötigten Engel anzeigen
* Löschen nur mit Rückfrage
* schichten ueber monatsgrenzen einbaue im moment werden die tage nur
hochgezaehlt und die monatzgrenzen werden ignoriert

View File

@ -1,8 +0,0 @@
<?php
require_once ('../bootstrap.php');
include ("includes/header.php");
include ("includes/footer.php");
?>

View File

@ -38,6 +38,10 @@ if (in_array($p, $privileges)) {
elseif ($p == "user_messages") {
$content = user_messages();
}
elseif ($p == "user_questions") {
require_once ('includes/pages/user_questions.php');
$content = user_questions();
}
elseif ($p == "user_settings") {
require_once ('includes/pages/user_settings.php');
$content = user_settings();