Subversion Repositories Applications.gtt

Compare Revisions

Ignore whitespace Rev 33 → Rev 34

/trunk/actions/GttCtrlActionIdentification.class.php
1,35 → 1,54
<?php
 
class GttCtrlActionIdentification extends aControlleurAction {
 
public function __construct(Registre $Registre)
{
$Registre->ajouterEspace('Identification', 'identification');
$Registre->ajouterSquelette('identification', 'connexion.tpl.html');
}
 
public function executer()
{
$aso_identification = array();
$this->getRegistre()->ajouterSquelette('identification', 'identite.tpl.html');
//$GLOBALS['_GTT_']['auth']->logout();
$aso_identification['nom'] = $GLOBALS['_GTT_']['Utilisateur']->getNom();
$aso_identification['prenom'] = $GLOBALS['_GTT_']['Utilisateur']->getPrenom();
//echo '<pre>'.print_r($aso_identification, true).'</pre>';
$this->getRegistre()->ajouterDonnee('identification', $aso_identification);
$params = array('dsn' => GTT_BDD_DSN,
'table' => 'gestion_utilisateur',
'usernamecol' => 'gu_email',
'passwordcol' => 'gu_password',
'cryptype' => 'md5',
'db_fields' => '*');
// Création de l'objet auth
$a = new Auth('DB', $params, null, false);
$a->setSessionname(GTT_AUTH_SESSION_NOM);
$a->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
$a->start();
$GLOBALS['_GTT_']['auth'] = $a;
setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
if ($GLOBALS['_GTT_']['auth']->getAuth()) {
require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
$GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($a->getUserName()));
 
$aso_identification['nom'] = $GLOBALS['_GTT_']['Utilisateur']->getNom();
$aso_identification['prenom'] = $GLOBALS['_GTT_']['Utilisateur']->getPrenom();
$this->getRegistre()->ajouterSquelette('identification', 'identite.tpl.html');
//echo '<pre>'.print_r($aso_identification, true).'</pre>';
$this->getRegistre()->ajouterDonnee('identification', $aso_identification);
} else {
$this->setSuivant('Deconnexion', 1);
}
}
 
public function executerDeconnexion()
{
$aso_connexion = array();
$this->getRegistre()->setTitre('Bienvenue sur GTT!');
$this->getRegistre()->ajouterSquelette('identification', 'connexion.tpl.html');
// Création de l'url de réponse du formulaire
$aso_connexion['url'] = 'index.php?action='.GTT_ACTION_CONNEXION;
$GLOBALS['_GTT_']['auth']->logout();
 
//echo '<pre>'.print_r($aso_connexion, true).'</pre>';
$this->getRegistre()->ajouterDonnee('identification', $aso_connexion);
$this->getRegistre()->set('action_finale', true);
}
}
?>