Subversion Repositories Applications.gtt

Rev

Rev 34 | Rev 73 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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