Add a page showing list of questions
This commit is contained in:
parent
ec1ed49996
commit
bb84214a0f
90
list.php
Normal file
90
list.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
include ("header.html");
|
||||
|
||||
session_start();
|
||||
|
||||
require_once("QuestionsFile.class.php");
|
||||
|
||||
if (!empty($_SESSION["connected"]) && !empty($_POST["id"]))
|
||||
{
|
||||
$file = new QuestionsFile("questions.xml");
|
||||
$q = $file->get_question($_POST["id"]);
|
||||
|
||||
if (!empty($q))
|
||||
{
|
||||
$file->del_question($q);
|
||||
$file->save();
|
||||
}
|
||||
header("Location: ./list.php");
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<section id="introduction" style="margin: auto -15%;">
|
||||
<article id="menu">.:
|
||||
<a href="?">Liste des questions non-validées</a> ::
|
||||
<a href="?valid">Liste des questions validées</a> :.
|
||||
</article>
|
||||
<article id="allQuestions">
|
||||
<h2>Liste de toutes les questions <?php if (!isset($_GET["valid"])) echo "non-"; ?>validées</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Question</th>
|
||||
<th>Auteur</th>
|
||||
<th>Soumission</th>
|
||||
<th>Validateur</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
$file = new QuestionsFile("questions.xml");
|
||||
|
||||
date_default_timezone_set("Europe/Paris");
|
||||
|
||||
foreach($file->get_questions() as $q)
|
||||
{
|
||||
if (!isset($_GET["valid"]))
|
||||
{
|
||||
if ($q->isValidated())
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$q->isValidated())
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = $q->getId();
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $q->getQuestion(); ?></td>
|
||||
<td><?php if ($q->get_writer() != null) echo $q->get_writer()->getUsername(); ?></td>
|
||||
<td><?php echo strftime("%d/%m/%y %H:%M", $q->getAddedTime()); ?></td>
|
||||
<td><?php if ($q->get_validator() != null) echo $q->get_validator()->getUsername(); ?>
|
||||
<?php
|
||||
if (!empty($_SESSION["connected"]))
|
||||
{
|
||||
?>
|
||||
<div class="tooltip">
|
||||
<form method="post" action="confirmation.php?norandom"><input type="hidden" name="id" value="<?php echo $id ?>"><input type="submit" value="Relancer"></form>
|
||||
<form method="post" action="confirmation.php"><input type="hidden" name="id" value="<?php echo $id ?>"><input type="submit" value="Revalider"></form>
|
||||
<form method="get" action="changeQuestion.php"><input type="hidden" name="id" value="<?php echo $id ?>"><input type="submit" value="Modifier"></form>
|
||||
<form method="post" action="?del" onsubmit="return confirm('Êtes-vous sûr de vouloir supprimer cette question ?');"><input type="hidden" name="id" value="<?php echo $id ?>"><input type="submit" value="Supprimer"></form>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</article>
|
||||
<?php
|
||||
}
|
||||
include ("footer.html");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user