11 |
jpm |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class GttCtrlActionIdentification extends aControlleurAction {
|
34 |
jpm |
4 |
|
11 |
jpm |
5 |
public function __construct(Registre $Registre)
|
|
|
6 |
{
|
|
|
7 |
$Registre->ajouterEspace('Identification', 'identification');
|
|
|
8 |
}
|
34 |
jpm |
9 |
|
11 |
jpm |
10 |
public function executer()
|
|
|
11 |
{
|
|
|
12 |
$aso_identification = array();
|
34 |
jpm |
13 |
$params = array('dsn' => GTT_BDD_DSN,
|
|
|
14 |
'table' => 'gestion_utilisateur',
|
|
|
15 |
'usernamecol' => 'gu_email',
|
|
|
16 |
'passwordcol' => 'gu_password',
|
|
|
17 |
'cryptype' => 'md5',
|
|
|
18 |
'db_fields' => '*');
|
|
|
19 |
// Création de l'objet auth
|
|
|
20 |
$a = new Auth('DB', $params, null, false);
|
|
|
21 |
$a->setSessionname(GTT_AUTH_SESSION_NOM);
|
|
|
22 |
$a->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
|
|
|
23 |
$a->start();
|
|
|
24 |
$GLOBALS['_GTT_']['auth'] = $a;
|
|
|
25 |
setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
|
|
|
26 |
if ($GLOBALS['_GTT_']['auth']->getAuth()) {
|
|
|
27 |
require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
|
|
|
28 |
$GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($a->getUserName()));
|
|
|
29 |
|
|
|
30 |
$aso_identification['nom'] = $GLOBALS['_GTT_']['Utilisateur']->getNom();
|
|
|
31 |
$aso_identification['prenom'] = $GLOBALS['_GTT_']['Utilisateur']->getPrenom();
|
|
|
32 |
$this->getRegistre()->ajouterSquelette('identification', 'identite.tpl.html');
|
|
|
33 |
//echo '<pre>'.print_r($aso_identification, true).'</pre>';
|
|
|
34 |
$this->getRegistre()->ajouterDonnee('identification', $aso_identification);
|
|
|
35 |
} else {
|
|
|
36 |
$this->setSuivant('Deconnexion', 1);
|
|
|
37 |
}
|
11 |
jpm |
38 |
}
|
34 |
jpm |
39 |
|
11 |
jpm |
40 |
public function executerDeconnexion()
|
|
|
41 |
{
|
|
|
42 |
$aso_connexion = array();
|
|
|
43 |
$this->getRegistre()->setTitre('Bienvenue sur GTT!');
|
34 |
jpm |
44 |
$this->getRegistre()->ajouterSquelette('identification', 'connexion.tpl.html');
|
11 |
jpm |
45 |
// Création de l'url de réponse du formulaire
|
|
|
46 |
$aso_connexion['url'] = 'index.php?action='.GTT_ACTION_CONNEXION;
|
|
|
47 |
$GLOBALS['_GTT_']['auth']->logout();
|
34 |
jpm |
48 |
|
11 |
jpm |
49 |
//echo '<pre>'.print_r($aso_connexion, true).'</pre>';
|
|
|
50 |
$this->getRegistre()->ajouterDonnee('identification', $aso_connexion);
|
34 |
jpm |
51 |
$this->getRegistre()->set('action_finale', true);
|
11 |
jpm |
52 |
}
|
|
|
53 |
}
|
|
|
54 |
?>
|