Commit e7140ca2 authored by Loïc DAYOT's avatar Loïc DAYOT
Browse files

fix(): top of the page displayed twice when identification required

fixed cleaning the output buffer before to display identification form.
parent db7d4220
......@@ -49,7 +49,7 @@ class user
}
return $ret;
}
private function get_from_sql($sql)
{
$ret = $this->query($sql);
......@@ -68,7 +68,7 @@ class user
{
$sql =
"SELECT id FROM {$GLOBALS['db_tablename_prefix']}users WHERE login=".
$this->db->quote_smart($login).
$this->db->quote_smart($login).
($exceptId!=null ? " AND id<>". $this->db->quote_smart($exceptId) : "");
$row = $this->get_from_sql($sql);
return is_object($row) ? $row->id : false;
......@@ -88,7 +88,7 @@ class user
function get()
{
$sql = "select * from {$GLOBALS['db_tablename_prefix']}users where id=" .
$sql = "select * from {$GLOBALS['db_tablename_prefix']}users where id=" .
$this->db->quote_smart(!isset($this->id) ? $this->session->value("agenda_libre_id") : $this->id);
$row = $this->get_from_sql($sql);
if (! $row || ! is_object($row)) return false;
......@@ -120,10 +120,10 @@ class user
$this->message = returnError("La requête <i>". $sql. "</i> a échoué");
return false;
}
if (!isset($this->id))
$this->id = $this->db->insertid();
return true;
} // end function save();
......@@ -136,7 +136,7 @@ class user
$this->message = returnError("La requête <i>". $sql. "</i> a échoué");
return false;
}
return true;
} // end function delete();
......@@ -188,6 +188,7 @@ class user
{
if (! isset($_POST['__user_identify']))
{
ob_end_clean();
put_header("Accès réservé");
echo "<h2>Identification</h2>";
......@@ -212,6 +213,7 @@ class user
}
else
{
ob_end_clean();
put_header("Accès réservé");
echo returnError("Mauvais identifiant/mot de passe");
put_footer();
......@@ -220,7 +222,7 @@ class user
}
}
}
/* Presente un formulaire d'edition d'utilisateur */
function edit($postUrl='moderateusers.php')
{
......@@ -249,16 +251,16 @@ class user
echo "<tr><td>Rôle*:</td>".
"<td><label>Le rôle d'administrateur donne le droit de gérer les comptes de tous les utilisateurs</label>".
"<br/><select name='__user_admin'/>".
"<option value='0'". ($this->admin ? '' : ' selected').
"<option value='0'". ($this->admin ? '' : ' selected').
($this->id==$this->session->value("agenda_libre_id") ? ' disabled' : ''). ">modérateur</option>".
"<option value='1'". ($this->admin ? ' selected' : ''). ">administrateur</option>";
"</td></tr>\n";
echo "<tr class='even'><td></td><td><input type=\"submit\" name=\"__user_form\" value=\"Envoyer\"></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
/* Presente un formulaire de suppression d'utilisateur */
function delForm($postUrl='moderateusers.php')
{
......@@ -279,7 +281,7 @@ class user
function fromForm()
{
$afieldName = array('id', 'login', 'password',
$afieldName = array('id', 'login', 'password',
'password2', 'email', 'lastname', 'firstname');
foreach ($afieldName as $fieldName)
{
......@@ -288,13 +290,13 @@ class user
else
unset($this->$fieldName);
}
if (isset($_POST['__user_admin']))
$this->admin = ($_POST['__user_admin'] == 1);
return true;
}
function check()
{
if (!isset($_POST['__user_form']))
......@@ -329,7 +331,7 @@ class user
$this->message .= returnError("Identifiant déjà utilisé.");
return (""==$this->message);
}
function checkDel()
{
if (!isset($_POST['__user_delform']))
......@@ -354,7 +356,7 @@ class user
$output .= "<td>". ($this->admin ? 'admin' : ''). "</td>";
return $output;
}
function listHTML()
{
$return = "<table class='stats'>\n";
......@@ -369,7 +371,7 @@ class user
$return .= "<tr". ($impair ? " class='even'" : ""). ">". $this->formatTrHtml();
$return .= "<td>".
"<a href='?op=edit&id={$this->id}'>Editer</a>".
($this->session->value("agenda_libre_id")!=$this->id && !$this->admin ?
($this->session->value("agenda_libre_id")!=$this->id && !$this->admin ?
" - <a href='?op=del&id={$this->id}'>Supprimer</a>" : "").
"</td>";
$return .= "</tr>\n";
......@@ -379,5 +381,5 @@ class user
$return .= "</table>\n";
return $return;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment