Alors voila mon pb, j'ai:
Parse error: syntax error, unexpected '}' in C:\Program Files\EasyPHP-5.3.6.0\www\ONP\backoff\class_users.php on line 941
Et voici mon code:
Code : Tout sélectionner
<?php
require_once("class_ONP.php");
class users extends dbquery
{
/**
* @access private
* @var integer
*/
var $the_start;
/**
* SQL argument orderby name
* @access private
* @var string
*/
var $orderby;
/**
* SQL argument orderby
* @access private
* @var string
*/
var $sqlorderby;
/**
* Redefinition of the user object constructor : configure the SQL argument order by
*/
function __construct()
{
}
/**
* To log a user
*
* @param string $s_login user login
* @param string $pass user password
*/
function login($s_login,$pass)
{
// To log a user
$this->connect();
$this->query("select * from user where login = '".$s_login."' and password2 = '".$pass."'");
if($this->nb_result() > 0)
{
unset($_SESSION['user']);
$line = $this->fetch_object();
if($line->actif == 1)
{
$_SESSION['user']['UserId'] = $line->id;
$_SESSION['user']['prenom'] = $line->prenom;
$_SESSION['user']['nom'] = $line->nom;
$_SESSION['user']['tel'] = $line->tel;
$_SESSION['user']['port'] = $line->port;
$_SESSION['user']['fax'] = $line->fax;
$_SESSION['user']['email'] = $line->email;
$_SESSION['user']['id_agence'] = $line->id_agence;
$_SESSION['user']['adresse'] = $line->adresse;
$_SESSION['user']['code_postal'] = $line->code_postal;
$_SESSION['user']['ville'] = $line->ville;
$_SESSION['user']['type_user'] = $line->type_user;
$_SESSION['user']['voir_tt_agence'] = $line->voir_tt_agence;
$_SESSION['user']['recherche'] = array();
$_SESSION['user']['recherche']['an'] = array();
$_SESSION['user']['recherche']['an']['est_active'] =0;
$_SESSION['error'] = "";
setcookie("ONP", "UserId=".$_SESSION['user']['UserId']."&key=".$line->COOKIE_KEY,time()-3600000);
$key = md5(time()."%".$_SESSION['user']['Prenom']."%".$_SESSION['user']['UserId']."%".$_SESSION['user']['UserId']."%".date("dmYHmi")."%");
$this->query("update user set cookie_key = '".$key."', cookie_date = '".date("Y-m-d")." ".date("H:m:i")."' where id = '".$_SESSION['user']['UserId']."' and email = '".$_SESSION['user']['Email']."'");
setcookie("ONP", "UserId=".$_SESSION['user']['UserId']."&key=".$key,time()+3600000);
//$this->load_services();
header("location: annonces.php");
exit;
}
else
{
$_SESSION['error'] = 'Votre compte utilisateur a été suspendu. Pour plus d\'informations, contactez votre administrateur'." <a href=\"mailto:".$_SESSION['config']['adminmail']."\">".$_SESSION['config']['adminname']."</a>";
header("location: login.php");
exit;
}
}
else
{
$_SESSION['error'] = "Mauvais nom d\'utilisateur ou mauvais mot de passe...";
header("location: login.php");
exit;
}
}
/**
* To reopen a session with the user's cookie
*
* @param string $s_UserId user identifier
* @param string $s_key cookie key
*/
function reopen($s_UserId,$s_key)
{
// to reopen a session with the user's cookie
$this->connect();
$this->query("select * from user where id = '".$s_UserId."' and cookie_key = '".$s_key."'");
if($this->nb_result() > 0)
{
$line = $this->fetch_object();
if($line->ENABLED == "Y")
{
$_SESSION['user']['UserId'] = $line->id;
$_SESSION['user']['Prenom'] = $line->prenom;
$_SESSION['user']['Nom'] = $line->nom;
$_SESSION['user']['Tel'] = $line->tel;
$_SESSION['user']['Port'] = $line->port;
$_SESSION['user']['Fax'] = $line->fax;
$_SESSION['user']['Email'] = $line->email;
$_SESSION['user']['AgenceId'] = $line->id_agence;
$_SESSION['user']['Adresse'] = $line->adresse;
$_SESSION['user']['CP'] = $line->code_postal;
$_SESSION['user']['Ville'] = $line->ville;
$_SESSION['user']['type_user'] = $line->type_user;
$_SESSION['user']['Voir_Tt_Agence'] = $line->voir_tt_agence;
$_SESSION['error'] = "";
setcookie("ONP", "UserId=".$_SESSION['user']['UserId']."&key=".$line->COOKIE_KEY,time()-3600000);
$key = md5(time()."%".$_SESSION['user']['prenom']."%".$_SESSION['user']['UserId']."%".$_SESSION['user']['UserId']."%".date("dmYHmi")."%");
$this->query("update user set cookie_key = '".$key."', cookie_date = '".date("Y-m-d")." ".date("H:m:i")."' where id = '".$_SESSION['user']['UserId']."' and email = '".$_SESSION['user']['Email']."'");
setcookie("ONP", "UserId=".$_SESSION['user']['UserId']."&key=".$key,time()+3600000);
header("location: admin.php");
exit;
}
else
{
$_SESSION['error'] = 'Votre compte utilisateur a été suspendu. Pour plus d\'informations, contactez votre administrateur'." <a href=\"mailto:".$_SESSION['config']['adminmail']."\">".$_SESSION['config']['adminname']."</a>";
header("location: login.php");
exit;
}
}
else
{
$_SESSION['erreur']="Login ou mot de passe invalide !";
header("location: login.php");
exit;
}
}
/**
* Build Maarch configuration into sessions vars with an xml configuration file
*/
function build_config()
{
// build Maarch configuration into sessions vars
// $xmlconfig = simplexml_load_file('xml/config.xml');
$initLB= new ONP();
$_SESSION['config']['databaseserver'] = "mysql5-7";
$_SESSION['config']['databasename'] = "onpimmobilier";
$_SESSION['config']['databaseuser'] = "onpimmobilier";
$_SESSION['config']['databasepassword'] = "....";
// $_SESSION['config']['databaseserver'] = "127.0.0.1";
// $_SESSION['config']['databasename'] = "onpimmobilier";
// $_SESSION['config']['databaseuser'] = "root";
// $_SESSION['config']['databasepassword'] = "sqlldm";
$_SESSION['config']['adminmail'] = "";
$_SESSION['config']['adminname'] = "";
$_SESSION['config']['debug'] = "";
$_SESSION['config']['applicationname'] = "";
$_SESSION['config']['OnpURL'] = "";
$initLB->basetosessionONP();
$initLB->agencetosessionONP();
$initLB->negoctosessionONP();
$initLB->rubchartosessionONP();
$initLB->typechartosessionONP();
$initLB->adrmailpubchartosessionONP();
}
/**
* Build the alphabetic list of users letters
*/
/**
* To allow administrator to admin users
*
* @param integer $id user identifier
* @param string $mode allow, ban or del
*/
function adminuser($id,$mode)
{
// To allow administrator to admin users
if(!empty($_SESSION['error']))
{
header("location: index.php?page=users");
exit;
}
else
{
$this->connect();
$this->query("select USER_ID, FirstName, LastName from ".$_SESSION['tablename']['users']." where user_id = '".$id."'");
if($this->nb_result() == 0)
{
$_SESSION['error'] = _USER.' '._UNKNOWN;
header("location: index.php?page=users");
exit;
}
else
{
$info = $this->fetch_object();
$theuser = $info->LastName." ".$info->FirstName;
if($mode == "allow")
{
$this->query("Update ".$_SESSION['tablename']['users']." set enabled = 'Y' where user_id = '".$id."'");
if($_SESSION['history']['usersval'] == "true")
{
require("include/class_history.php");
$users = new history();
$users->add($_SESSION['tablename']['users'], $id,"VAL",_USER_AUTORIZATION." ".$theuser);
}
$_SESSION['error'] = _AUTORIZED_USER;
}
elseif($mode == "ban")
{
$this->query("Update ".$_SESSION['tablename']['users']." set enabled = 'N' where user_id = '".$id."'");
if($_SESSION['history']['usersban'] == "true")
{
require("include/class_history.php");
$users = new history();
$users->add($_SESSION['tablename']['users'], $id,"BAN",_USER_SUSPENSION." : ".$theuser);
}
$_SESSION['error'] = _SUSPENDED_USER;
}
elseif($mode == "del" )
{
$this->query("delete from ".$_SESSION['tablename']['users']." where user_id = '".$id."'");
if($_SESSION['history']['usersdel'])
{
require("include/class_history.php");
$users = new history();
$users->add($_SESSION['tablename']['users'], $id,"DEL",_USER_DELETION." : ".$theuser);
}
$_SESSION['error'] = _DELETED_USER;
}
header("location: index.php?page=users");
exit;
}
}
}
function afficherecherche()
{
$page=$_GET['page'];
$this->connect();
$this->build_config();
$nb_enr;
$nb_enr_liste=16;
$table="" ;
$cond="";
switch($_GET['chtrie'])
{
case 1:
$trie="user.nom";
break;
}
if ($_GET['senstrie']!=0)
$trie.=" desc";
else
$trie.=" asc";
if ($_GET['id_agence']) {
$txt1="select count(user.id) from user, agence where agence.id=user.id_agence and user.id_agence=".$_GET['id_agence'];
$txt2="SELECT user.id,user.nom,user.prenom,user.tel,user.port,user.fax,agence.ville,agence.tel,user.type_user,user.actif from user , agence where agence.id=user.id_agence and user.id_agence=".$_GET['id_agence']." order by ".$trie." LIMIT ".(($page-1)*$nb_enr_liste).",".($page*$nb_enr_liste);
}
else
{
$txt1="select count(user.id) from user left join agence on agence.id=user.id_agence ";
$txt2="SELECT user.id,user.nom,user.prenom,user.tel,user.port,user.fax,agence.ville,agence.tel,user.type_user,user.actif from user left join agence on agence.id=user.id_agence order by ".$trie." LIMIT ".(($page-1)*$nb_enr_liste).",".($page*$nb_enr_liste);
}
// if ($_GET['nom']) $cond.=" and user.non like '%".$_GET['nom']."%'";
// if ($_GET['actif']) $cond.=" and user.actif=".$_GET['actif'];
$this->query($txt1);
$row=$this->fetch_row();
$nb_enr=$row[0];
//SELECT user.id,user.nom,user.prenom,user.tel,user.port,user.fax,agence.ville,agence.tel,user.actif from user,agence where agence.id=user.id_agence
$this->query($txt2);
// construction du fichier xml
//header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
echo '<resultat>';
echo '<enregistrement>';
echo '<nb_enr>'.$nb_enr.'</nb_enr>';
if (($nb_enr%$nb_enr_liste)==0)
echo '<nb_page>'.($nb_enr/$nb_enr_liste).'</nb_page>';
else
echo '<nb_page>'.(($nb_enr/$nb_enr_liste)+1).'</nb_page>';
echo '</enregistrement>';
while ($row=$this->fetch_row())
{
echo '<negoc>';
echo '<ch1>'.$row[0].'</ch1>';
echo '<ch2>'.($row[1]==""?" ":$row[1]).'</ch2>';
echo '<ch3>'.($row[2]==""?" ":$row[2]).'</ch3>';
echo '<ch4>'.($row[3]==""?" ":$row[3]).'</ch4>';
echo '<ch5>'.($row[4]==""?" ":$row[4]).'</ch5>';
echo '<ch6>'.($row[5]==""?" ":$row[5]).'</ch6>';
echo '<ch7>'.($row[6]==""?" ":$row[6]).'</ch7>';
echo '<ch8>'.($row[7]==""?" ":$row[7]).'</ch8>';
switch ($row[8])
{
case 3:
echo "<ch9>Admin</ch9>";
break;
case 2:
echo "<ch9>Chef d'Ag.</ch9>";
break;
case 1:
echo "<ch9>Négoc.</ch9>";
break;
default:
echo "<ch9> </ch9>";
break;
}
echo '<ch10>'.$row[9].'</ch10>';
echo '</negoc>';
}
echo '</resultat>';
}
/**
* Form to add or modify users
*
* @param string $mode up or add
* @param integer $id user identifier, empty by default
*/
function formuser($mode,$id = 0)
{
$suiv;
$prec;
if($mode == "lect")
{
$_SESSION['m_admin']['mode'] = "lect";
$cond="";
if ($_GET['id_agence']) {
$cond.=" where user.id_agence=".$_GET['id_agence'];
}
if ($_GET['nom']) $cond.=" and user.non like '%".$_GET['nom']."%'";
if ($_GET['actif']) $cond.=" and user.actif=".$_GET['actif'];
switch($_GET['chtrie'])
{
case 1:
$trie="user.nom";
break;
}
if ($_GET['senstrie']!=0)
$trie.=" desc";
else
$trie.=" asc";
// if(empty($_SESSION['error']))
// {
$this->connect();
$this->query("select user.id,user.dt_creat,user.nom,user.prenom,user.adresse,user.code_postal,user.ville,user.tel,user.port,user.fax,user.email,user.login,user.type_user,user.voir_tt_agence,user.actif,agence.nom ag from user left join agence on user.id_agence=agence.id ".$cond." order by ".$trie );
$nb=$this->nb_result();
$i=0;
$line = $this->fetch_object();
while ($i<$nb && $line->id!=$id)
{
$prec=$line->id;
$line = $this->fetch_object();
$i++;
}
if($this->nb_result() == 0)
{
$_SESSION['error'] = "utilisateur inconnu";
$state = false;
}
else
{
$_SESSION['m_admin']['users']['id'] = $line->id;
$_SESSION['m_admin']['users']['dt_creat'] = $line->dt_creat;
$_SESSION['m_admin']['users']['nom'] = $line->nom;
$_SESSION['m_admin']['users']['prenom'] = $line->prenom;
$_SESSION['m_admin']['users']['adresse'] = $line->adresse;
$_SESSION['m_admin']['users']['code_postal'] = $line->code_postal;
$_SESSION['m_admin']['users']['ville'] = $line->ville;
$_SESSION['m_admin']['users']['tel'] = $line->tel;
$_SESSION['m_admin']['users']['port'] = $line->port;
$_SESSION['m_admin']['users']['fax'] = $line->fax;
$_SESSION['m_admin']['users']['email'] = $line->email;
$_SESSION['m_admin']['users']['agence'] = $line->ag;
$_SESSION['m_admin']['users']['login'] = $line->login;
$_SESSION['m_admin']['users']['type_user'] = $line->type_user;
$_SESSION['m_admin']['users']['voir_tt_agence'] = $line->voir_tt_agence;
$_SESSION['m_admin']['users']['actif'] = $line->actif;
}
if($line = $this->fetch_object())
$suiv=$line->id;
//header('Content-type : text/plain');
?>
<input style="display:none" type="text" id="id_user" value="<?php echo($_SESSION['m_admin']['users']['id']); ?>"/>
<input style="display:none" type="text" id="id_suiv" value="<?php echo($suiv); ?>"/>
<input style="display:none" type="text" id="id_prec" value="<?php echo($prec); ?>"/>
<input style="display:none" type="text" id="num_enr" value="<?php echo($i+1); ?>"/>
<input style="display:none" type="text" id="nb_enr" value="<?php echo($nb); ?>"/>
<table >
<tr>
<td>
<span id="bt_suiv" style="cursor: pointer" onclick="enr_preced();"><img src="../images/mes%20images/dep_gauche_vert.png" /></span>
</td>
<td>
<fieldset>
<table class="fiche">
<tr>
<td ><span class="bold">Type utilisateur : </span><span class="bold orange kingsize"><?php
if ($_SESSION['m_admin']['users']['type_user']==3)
echo("Administrateur");
else
if ($_SESSION['m_admin']['users']['type_user']==2)
echo("Chef d'agence");
else
echo("Négociateur");
?> </span></td>
</tr>
<tr>
<td><span class="bold">Nom : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['nom']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Prénom : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['prenom']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Adresse : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['adresse']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Code Postal : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['code_postal']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Ville : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['ville']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Tél. : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['tel']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Port. : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['port']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Fax : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['fax']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Email : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['email']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Agence : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['agence']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Login : </span><span class="bold orange kingsize"><?php echo($_SESSION['m_admin']['users']['login']); ?></span></td>
</tr>
<tr>
<td><span class="bold">Activé : </span><span class="bold orange kingsize"><?php
if ($_SESSION['m_admin']['agence']['actif']==0)
echo("Non");
else
echo("Oui");
?></span></td>
</tr>
</table>
</fieldset>
</td>
<td>
<span id="bt_prec" style="cursor: pointer" onclick="enr_suivant();"><img src="../images/mes%20images/dep_droite_vert.png" /></span>
</td>
</tr>
<?
// }
}
if($mode == "modif" )
{
if($id!=0)
{
$_SESSION['m_admin']['mode'] = "modif";
$this->connect();
$this->query("select user.id,user.dt_creat,user.nom,user.prenom,user.adresse,user.code_postal,user.ville,user.tel,user.port,user.fax,user.email,user.login,user.type_user,user.voir_tt_agence,user.actif,user.id_agence ag from user where user.id=".$id );
if($this->nb_result() == 0)
{
$_SESSION['error'] = "utilisateur inconnu";
$state = false;
}
else
{
$line = $this->fetch_object();
$_SESSION['m_admin']['users']['id'] = $line->id;
$_SESSION['m_admin']['users']['nom'] = $line->nom;
$_SESSION['m_admin']['users']['prenom'] = $line->prenom;
$_SESSION['m_admin']['users']['adresse'] = $line->adresse;
$_SESSION['m_admin']['users']['code_postal'] = $line->code_postal;
$_SESSION['m_admin']['users']['ville'] = $line->ville;
$_SESSION['m_admin']['users']['tel'] = $line->tel;
$_SESSION['m_admin']['users']['port'] = $line->port;
$_SESSION['m_admin']['users']['fax'] = $line->fax;
$_SESSION['m_admin']['users']['email'] = $line->email;
$_SESSION['m_admin']['users']['id_agence'] = $line->ag;
$_SESSION['m_admin']['users']['login'] = $line->login;
$_SESSION['m_admin']['users']['type_user'] = $line->type_user;
$_SESSION['m_admin']['users']['voir_tt_agence'] = $line->voir_tt_agence;
$_SESSION['m_admin']['users']['actif'] = $line->actif;
?>
<input style="display:none" type="text" id="id_user" value="<?php echo($_SESSION['m_admin']['users']['id']); ?>"/>
<table class="fiche" style="margin-left:35px;">
<tr>
<td width="230px"><span class="bold orange kingsize">Type utilisateur : </span></td>
<td>
<select name="select" id="type_user" value="<?php echo($_SESSION['m_admin']['users']['type_user']); ?>">
<option value="0" <?php if ($_SESSION['m_admin']['users']['type_user']==0) echo('selected="selected"'); ?>></option>
<option value="1" <?php if ($_SESSION['m_admin']['users']['type_user']==1) echo('selected="selected"'); ?>>Négociateur</option>
<option value="2" <?php if ($_SESSION['m_admin']['users']['type_user']==2) echo('selected="selected"'); ?>>Chef d'agence</option>
<option value="3" <?php if ($_SESSION['m_admin']['users']['type_user']==3) echo('selected="selected"'); ?>>Administrateur</option>
</select>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Nom : </span></td>
<td>
<input name="text" type="text" class="customform w170" id="nom" value="<?php echo($_SESSION['m_admin']['users']['nom']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Prénom : </span></td>
<td>
<input name="text" type="text" class="customform w170" id="prenom" value="<?php echo($_SESSION['m_admin']['users']['prenom']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Adresse : </span></td>
<td>
<input name="text" type="text" class="customform w300" id="adresse" value="<?php echo($_SESSION['m_admin']['users']['adresse']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Code Postal : </span></td>
<td>
<input name="text" type="text" class="customform w60" id="code_postal" value="<?php echo($_SESSION['m_admin']['users']['code_postal']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Ville : </span></td>
<td>
<input name="text" type="text" class="customform w170" id="ville" value="<?php echo($_SESSION['m_admin']['users']['ville']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Tél. : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="tel" value="<?php echo($_SESSION['m_admin']['users']['tel']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Port. : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="port" value="<?php echo($_SESSION['m_admin']['users']['port']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Fax : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="fax" value="<?php echo($_SESSION['m_admin']['users']['fax']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Email : </span></td>
<td>
<input name="text" type="text" class="customform w300" id="email" value="<?php echo($_SESSION['m_admin']['users']['email']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Agence: </span></td>
<td>
<select name="id_agence2" id="id_agence2" >
<?php
$liste=$_SESSION['agence'];
for ($i=0;$i<count($liste);$i++)
{
if ($_SESSION['m_admin']['users']['id_agence']==$_SESSION['agence'][$i]['id'])
echo("<option selected=\"selected\" value='".$_SESSION['agence'][$i]['id']."'>".$_SESSION['agence'][$i]['ville']."</option>");
else
echo("<option value='".$_SESSION['agence'][$i]['id']."'>".$_SESSION['agence'][$i]['ville']."</option>");
}
?>
</select>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Login : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="login" value="<?php echo($_SESSION['m_admin']['users']['login']); ?>"/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Password : </span></td>
<td>
<input name="text" type="password" class="customform w90" id="password1" />
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Vérification password: </span></td>
<td>
<input name="text" type="password" class="customform w90" id="password2" />
</td>
</tr>
<tr>
<td width="230px"><span class="bold orange kingsize">Activée : </span></td>
<td>
<select name="select" id="actif" >
<option value="0" <?php if ($_SESSION['m_admin']['users']['actif']==0) echo('selected="selected"'); ?>>Non</option>
<option value="1" <?php if ($_SESSION['m_admin']['users']['actif']==1) echo('selected="selected"'); ?>>Oui</option>
</select>
</td>
</tr>
<br/>
<!-- <tr>
<td> </td>
</tr>
<tr>
<td><span class="modifier"><img src="../images/toolbox/modifier2.png" /> <a href="produit_edit_divers.html">Modifier cette section</a></span></td>
</tr> -->
</table>
<?
}
}
else // création nouveau user
{
$_SESSION['m_admin']['mode'] = "modif";
?>
<input style="display:none" type="text" id="id_user" value="0"/>
<table class="fiche" style="margin-left:35px;">
<tr>
<td width="230px"><span class="bold orange kingsize">Type utilisateur : </span></td>
<td>
<select name="select" id="type_user" value="1">
<option value="0" ></option>
<option value="1" >Négociateur</option>
<option value="2" >Chef d'agence</option>
<option value="3" >Administrateur</option>
</select>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Nom : </span></td>
<td>
<input name="text" type="text" class="customform w170" id="nom" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Prénom : </span></td>
<td>
<input name="text" type="text" class="customform w170" id="prenom" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Adresse : </span></td>
<td>
<input name="text" type="text" class="customform w300" id="adresse" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Code Postal : </span></td>
<td>
<input name="text" type="text" class="customform w60" id="code_postal" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Ville : </span></td>
<td>
<input name="text" type="text" class="customform w170" id="ville" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Tél. : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="tel" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Port. : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="port" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Fax : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="fax" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Email : </span></td>
<td>
<input name="text" type="text" class="customform w300" id="email" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Agence : </span></td>
<td>
<select name="id_agence2" id="id_agence2" value="<?= $_SESSION['agence'][0]['id'] ?>">
<?php
$liste=$_SESSION['agence'];
for ($i=0;$i<count($liste);$i++)
{
echo("<option value='".$_SESSION['agence'][$i]['id']."'>".$_SESSION['agence'][$i]['ville']."</option>");
}
?>
</select>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Login : </span></td>
<td>
<input name="text" type="text" class="customform w90" id="login" value=""/>
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Password : </span></td>
<td>
<input name="text" type="password" class="customform w90" id="password1" />
</td>
</tr>
<tr>
<td><span class="bold orange kingsize">Vérification password: </span></td>
<td>
<input name="text" type="password" class="customform w90" id="password2" />
</td>
</tr>
<tr>
<td width="230px"><span class="bold orange kingsize">Activée : </span></td>
<td>
<select name="select" id="actif" >
<option value="0" >Non</option>
<option value="1" >Oui</option>
</select>
</td>
</tr>
<br/>
<!-- <tr>
<td> </td>
</tr>
<tr>
<td><span class="modifier"><img src="../images/toolbox/modifier2.png" /> <a href="produit_edit_divers.html">Modifier cette section</a></span></td>
</tr> -->
</table>
<?php
}
}
}
/**
* Return the user information in sessions vars
*
* @param string $mode add or up
*/
function usersinfo($mode)
{
require_once("include/class_usergroup_content.php");
// return the user information in sessions vars
$func = new functions();
if($mode == "add")
{
$_SESSION['m_admin']['users']['UserId'] = $func->wash($_POST['UserId'], "nick", _USER_ID);
$_SESSION['m_admin']['users']['pass'] = md5("test");
}
if($mode == "up")
{
$_SESSION['m_admin']['users']['UserId'] = $func->wash($_POST['id'], "nick", _USER_ID);
}
$_SESSION['m_admin']['users']['FirstName'] = $func->wash($_POST['FirstName'], "no", _FIRSTNAME);
$_SESSION['m_admin']['users']['LastName'] = $func->wash($_POST['LastName'], "no", _LASTNAME);
$_SESSION['m_admin']['users']['Department'] = $func->wash($_POST['Department'], "no", _DEPARTMENT);
if(isset($_POST['Phone']) && !empty($_POST['Phone']))
{
$_SESSION['m_admin']['users']['Phone'] = $_POST['Phone'];
}
$_SESSION['m_admin']['users']['Mail'] = $func->wash($_POST['Mail'], "mail", _MAIL);
if(isset($_POST['Fonction']) && !empty($_POST['Fonction']))
{
$_SESSION['m_admin']['users']['Fonction'] = $_POST['Fonction'];
}
$_SESSION['m_admin']['users']['Elu'] = $_POST['elu'];
$ugc = new usergroup_content();
$primary_set = false;
for($i=0; $i < count($_SESSION['m_admin']['users']['groups']);$i++)
{
if($_SESSION['m_admin']['users']['groups'][$i]['PRIMARY'] == 'Y')
{
$primary_set = true;
break;
}
}
if ($primary_set == false)
{
$ugc->add_error(_NO_PRIMARY_GROUP, "");
}
}
/**
* Add ou modify users in the database
*
* @param string $mode up or add
*/
function addupusers($mode)
{
if(!empty($_SESSION['error']))
{
}
else
{
$this->connect();
if($mode == "add")
{
$this->query("insert into `user` (`nom`,`prenom`,`adresse`,`code_postal`, `ville`, `tel`, `fax`, `port`, `email`, `actif`, `id_agence`, `type_user`,`password2`,`login`) values ('".$_GET['nom']."','".$_GET['prenom']."','".$_GET['adresse']."','".$_GET['code_postal']."','".$_GET['ville']."','".$_GET['tel']."','".$_GET['fax']."','".$_GET['port']."','".$_GET['email']."', ".$_GET['actif'].",".$_GET['id_agence'].",".$_GET['type_user'].",'".$_GET['password1']."','".$_GET['login']."')");
echo(mysql_insert_id());
}
elseif($mode == "up")
{
if(isset($_GET['password1']))
$this->query("update `user` set `nom` = '".$_GET['nom']."', `prenom` = '".$_GET['prenom']."', `adresse` = '".$_GET['adresse']."', `code_postal` = '".$_GET['code_postal']."' , `ville` = '".$_GET['ville']."', `tel` = '".$_GET['tel']."', `fax` = '".$_GET['fax']."', `port` = '".$_GET['port']."', `email` = '".$_GET['email']."', `actif` = ".$_GET['actif'].", `id_agence` = ".$_GET['id_agence'].", `type_user` = ".$_GET['type_user'].",`password2`='".$_GET['password1']."',`login`='".$_GET['login']."' where id = ".$_GET['id']);
else
$this->query("update `user` set `nom` = '".$_GET['nom']."', `prenom` = '".$_GET['prenom']."', `adresse` = '".$_GET['adresse']."', `code_postal` = '".$_GET['code_postal']."' , `ville` = '".$_GET['ville']."', `tel` = '".$_GET['tel']."', `fax` = '".$_GET['fax']."', `port` = '".$_GET['port']."', `email` = '".$_GET['email']."', `actif` = ".$_GET['actif'].", `id_agence` = ".$_GET['id_agence'].", `type_user` = ".$_GET['type_user'].",`login`='".$_GET['login']."' where id = ".$_GET['id']);
}
}
}
/**
* Clear the users add or modification vars
*/
function clearuserinfos()
{
// clear the users add or modification vars
$_SESSION['m_admin']['users'] = array();
$_SESSION['m_admin']['users']['UserId'] = "";
$_SESSION['m_admin']['users']['pass'] = "";
$_SESSION['m_admin']['users']['FirstName'] = "";
$_SESSION['m_admin']['users']['LastName'] = "";
$_SESSION['m_admin']['users']['Phone'] = "";
$_SESSION['m_admin']['users']['Mail'] = "";
$_SESSION['m_admin']['users']['Department'] ="";
$_SESSION['m_admin']['users']['Status'] = "";
$_SESSION['m_admin']['users']['Elu'] = "";
$_SESSION['m_admin']['users']['Fonction'] = "";
$_SESSION['m_admin']['users']['groups'] = array();
$_SESSION['m_admin']['users']['nbbelonginggroups'] = 0;
}
}
?>