Subversion Repositories Applications.gtt

Rev

Rev 34 | Rev 73 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
48 jpm 20
		$GLOBALS['_GTT_']['identification'] = new Auth('DB', $params, null, false);
21
		$GLOBALS['_GTT_']['identification']->setSessionname(GTT_AUTH_SESSION_NOM);
22
		$GLOBALS['_GTT_']['identification']->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
23
		$GLOBALS['_GTT_']['identification']->start();
34 jpm 24
		setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
48 jpm 25
		if ($GLOBALS['_GTT_']['identification']->getAuth()) {
26
			require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
27
			$GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($GLOBALS['_GTT_']['identification']->getUserName()));
34 jpm 28
    		$aso_identification['nom'] = $GLOBALS['_GTT_']['Utilisateur']->getNom();
29
    		$aso_identification['prenom'] = $GLOBALS['_GTT_']['Utilisateur']->getPrenom();
30
			$this->getRegistre()->ajouterSquelette('identification', 'identite.tpl.html');
31
    		//echo '<pre>'.print_r($aso_identification, true).'</pre>';
32
			$this->getRegistre()->ajouterDonnee('identification', $aso_identification);
33
    	} else {
34
    		$this->setSuivant('Deconnexion', 1);
35
    	}
11 jpm 36
    }
34 jpm 37
 
11 jpm 38
    public function executerDeconnexion()
39
    {
40
    	$aso_connexion = array();
41
		$this->getRegistre()->setTitre('Bienvenue sur GTT!');
34 jpm 42
    	$this->getRegistre()->ajouterSquelette('identification', 'connexion.tpl.html');
11 jpm 43
    	// Création de l'url de réponse du formulaire
44
		$aso_connexion['url'] = 'index.php?action='.GTT_ACTION_CONNEXION;
48 jpm 45
    	$GLOBALS['_GTT_']['identification']->logout();
34 jpm 46
 
11 jpm 47
    	//echo '<pre>'.print_r($aso_connexion, true).'</pre>';
48
		$this->getRegistre()->ajouterDonnee('identification', $aso_connexion);
34 jpm 49
		$this->getRegistre()->set('action_finale', true);
11 jpm 50
    }
51
}
52
?>