Add a page to report questions

This commit is contained in:
Némunaire 2012-06-19 11:06:28 +02:00
parent e554ed3a66
commit 63e14532f8
2 changed files with 54 additions and 0 deletions

View File

@ -11,6 +11,7 @@ class Question
private $answers = array();
private $added_time;
private $validated = false;
private $reported = false;
private $validator = "";
private $writer = "";
@ -22,6 +23,8 @@ class Question
$this->added_time = $node->getAttribute("addedtime");
if (intval($node->getAttribute("validated")))
$this->validated = true;
if (intval($node->getAttribute("reported")))
$this->reported = true;
$this->validator = $node->getAttribute("validator");
$this->writer = $node->getAttribute("writer");
$this->question = $node->getAttribute("question");
@ -101,6 +104,7 @@ class Question
$qnode->setAttribute("xml:id", $this->id);
$qnode->setAttribute("addedtime", $this->added_time);
$qnode->setAttribute("reported", intval($this->reported));
$qnode->setAttribute("validated", intval($this->validated));
$qnode->setAttribute("validator", $this->validator);
$qnode->setAttribute("writer", $this->writer);
@ -126,6 +130,16 @@ class Question
return $this->added_time;
}
public function getReportId()
{
return md5($this->id);
}
public function setReported($reported = true)
{
$this->reported = $reported;
}
public function getId()
{
return $this->id;

40
report.php Normal file
View File

@ -0,0 +1,40 @@
<?php include("header.html") ?>
<section id="introduction">
<article id="report">
<h2><?php
include("Question.class.php");
include("QuestionsFile.class.php");
if (isset($_POST['id']))
{
$id = $_POST['id'];
$file = new QuestionsFile("questions.xml");
foreach($file->get_questions() as $q)
{
if ($q->getReportId() == $id)
{
$q->setReported();
$id = null;
break;
}
}
if (isset($id))
echo 'La question n\'a pas été trouvée';
else
echo 'La question a été rapporté avec succès';
}
else
header("Location: ./");
?></h2>
<p>
Nemubot vous remercie de l'aider à améliorer la qualité de sa base de données.<br><br>
Vous pouvez vous aussi poser des questions à <a href="./" >cette adresse</a>,
bien simplement essayer de répondre aux questions déjà posées en tapant
<code>!qcm</code> sur un cannal o&ugrave; nemubot est pr&eacute;sent.<br><br>
<span style="text-decoration:line-through;">Amusez-vous</span> R&eacute;visez bien !
</p>
</article>
</section>
</body>
</html>