[Trivialibre] r470 - trivialibre/trunk
trivialibre at enix.org
trivialibre at enix.org
Dim 4 Mar 20:09:45 CET 2007
Author: thomas
Date: Sun Mar 4 20:09:44 2007
New Revision: 470
Log:
Allow everyone to see the questions waiting for moderation.
Modified:
trivialibre/trunk/common.inc.php
trivialibre/trunk/moderation.php
Modified: trivialibre/trunk/common.inc.php
==============================================================================
--- trivialibre/trunk/common.inc.php (original)
+++ trivialibre/trunk/common.inc.php Sun Mar 4 20:09:44 2007
@@ -216,6 +216,8 @@
function user_identify_form ()
{
+ if($_POST['__user_identify'])
+ echo "<p style=\"text-align: center; color: red;\">Mauvais login ou mot de passe</p>";
?>
<table align="center">
<form method="post">
@@ -227,39 +229,62 @@
<?php
}
-function user_identify($db)
+function user_logout_form ()
{
- $session = new session();
+?>
+<form method="post">
+<p style="text-align: center">
+<input type="submit" name="__user_logout" value="Déconnexion"/>
+</p>
+</form>
+<?php
+}
+function user_check_authentication($db, $session)
+{
+ if ($_POST['__user_logout'])
+ {
+ $session->destroy();
+ return FALSE;
+ }
+
+ if ($session->exists("trivialibre_id"))
+ return TRUE;
+
+ if (! $_POST['__user_identify'])
+ return FALSE;
+
+ if (($ret = user_verify ($db, $_POST['__user_login'], $_POST['__user_password'])) > 0)
+ {
+ $session->set("trivialibre_id", $ret);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+function user_identified($session)
+{
/*
* Identification
*/
- if (! $session->exists("trivialibre_id"))
+ if ($session->exists("trivialibre_id"))
+ return TRUE;
+
+ return FALSE;
+}
+
+function user_identify($db)
+{
+ $session = new session();
+
+ if (! user_check_authentication($db, $session))
{
- if (! $_POST['__user_identify'])
- {
- header_show();
- echo "<h1>Identification</h1>";
- user_identify_form();
- footer_show();
- return FALSE;
- }
- else
- {
- if (($ret = user_verify ($db, $_POST['__user_login'], $_POST['__user_password'])) > 0)
- {
- $session->set("trivialibre_id", $ret);
- }
- else
- {
- header_show();
- echo "<h1>Identification</h1>";
- echo "<p style=\"text-align: center; color: red;\">Mauvais login ou mot de passe</p>";
- user_identify_form();
- footer_show();
- return FALSE;
- }
- }
+ header_show();
+ echo "<h1>Identification</h1>";
+ user_identify_form();
+ footer_show();
+ return FALSE;
}
return TRUE;
Modified: trivialibre/trunk/moderation.php
==============================================================================
--- trivialibre/trunk/moderation.php (original)
+++ trivialibre/trunk/moderation.php Sun Mar 4 20:09:44 2007
@@ -24,8 +24,9 @@
require('session.inc.php');
$db = new db();
-if (! user_identify($db))
- exit;
+$session = new session();
+
+user_check_authentication($db, $session);
header_show();
@@ -69,13 +70,27 @@
* If a question is being edited, do not display the
* validate/edit/delete buttons for the other questions.
*/
- echo " <td><a href=\"validate.php?id=" . $item->id . "\">Valider</a><br/>";
- echo " <a href=\"edit.php?id=" . $item->id . "\">Éditer</a><br/>";
- echo " <a href=\"delete.php?id=" . $item->id . "\">Supprimer</a></td>";
+ if (user_identified($session))
+ {
+ echo " <td><a href=\"validate.php?id=" . $item->id . "\">Valider</a><br/>";
+ echo " <a href=\"edit.php?id=" . $item->id . "\">Éditer</a><br/>";
+ echo " <a href=\"delete.php?id=" . $item->id . "\">Supprimer</a></td>";
+ }
echo "</tr>\n";
}
echo "</table>\n";
+if (! user_identified($session))
+{
+ echo "<h1>Identification</h1>";
+ user_identify_form();
+}
+else
+{
+ echo "<h1>Déconnexion</h1>";
+ user_logout_form();
+}
+
footer_show();
?>
Plus d'informations sur la liste de diffusion Trivialibre