Subversion Repositories Applications.annuaire

Rev

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

Rev 395 Rev 401
1
<?php
1
<?php
2
/**
2
/**
3
* PHP Version 5
3
* PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   annuaire
6
* @package   annuaire
7
* @author    aurelien <aurelien@tela-botanica.org>
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2010 Tela-Botanica
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
10
* @version   SVN: <svn_id>
11
* @link      /doc/annuaire/
11
* @link      /doc/annuaire/
12
*/
12
*/
13
 
13
 
14
Class IdentificationControleur extends AppControleur {
14
Class IdentificationControleur extends AppControleur {
15
 
15
 
16
	private $nom_cookie_persistant = '';
16
	private $nom_cookie_persistant = '';
17
	private $duree_identification = '0';
17
	private $duree_identification = '0';
18
	private $fonction_cryptage_mdp_cookie = 'md5';
18
	private $fonction_cryptage_mdp_cookie = 'md5';
19
	private $objet_identification = null;
19
	private $objet_identification = null;
20
 
20
 
21
	public function afficherFormulaireIdentification($id_annuaire, $donnees = array()) {
21
	public function afficherFormulaireIdentification($id_annuaire, $donnees = array()) {
22
		$this->chargerModele('AnnuaireModele');
22
		$this->chargerModele('AnnuaireModele');
23
		$annuaire = $this->AnnuaireModele->chargerAnnuaire($id_annuaire);
23
		$annuaire = $this->AnnuaireModele->chargerAnnuaire($id_annuaire);
24
 
24
 
25
		if (!isset($donnees['informations'])) {
25
		if (!isset($donnees['informations'])) {
26
			$donnees['informations'] = array();
26
			$donnees['informations'] = array();
27
		}
27
		}
28
 
28
 
29
		$donnees['id_annuaire'] = $id_annuaire;
29
		$donnees['id_annuaire'] = $id_annuaire;
30
 
30
 
31
		return $this->getVue(Config::get('dossier_squelettes_formulaires').'identification',$donnees);
31
		return $this->getVue(Config::get('dossier_squelettes_formulaires').'identification',$donnees);
32
	}
32
	}
33
 
33
 
34
	public function loggerUtilisateur($utilisateur, $pass) {
34
	public function loggerUtilisateur($utilisateur, $pass) {
35
		$this->objet_identification = Config::get('objet_identification');
35
		$this->objet_identification = Config::get('objet_identification');
36
 
36
 
37
		$this->creerCookie($utilisateur, $pass);
37
		$this->creerCookie($utilisateur, $pass);
38
 
38
 
39
		// Loguer l'utilisateur
39
		// Loguer l'utilisateur
40
		$this->objet_identification->username = $utilisateur;
40
		$this->objet_identification->username = $utilisateur;
41
		$this->objet_identification->password = $pass;
41
		$this->objet_identification->password = $pass;
42
		$this->objet_identification->login();
42
		$this->objet_identification->login();
43
 
43
 
44
		return true;
44
		return true;
45
	}
45
	}
46
 
46
 
47
	public function deLoggerUtilisateur() {
47
	public function deLoggerUtilisateur() {
48
		$this->objet_identification = Config::get('objet_identification');
48
		$this->objet_identification = Config::get('objet_identification');
49
		$this->objet_identification->logout();
49
		$this->objet_identification->logout();
50
		return true;
50
		return true;
51
	}
51
	}
52
 
52
 
53
	public function setUtilisateur($nom_utilisateur) {
53
	public function setUtilisateur($nom_utilisateur) {
54
		$this->objet_identification = Config::get('objet_identification');
54
		$this->objet_identification = Config::get('objet_identification');
55
		$this->objet_identification->setAuth($nom_utilisateur);
55
		$this->objet_identification->setAuth($nom_utilisateur);
56
		$pass = $this->objet_identification->password;
56
		$pass = $this->objet_identification->password;
-
 
57
 
57
		$this->creerCookie($nom_utilisateur, $pass, true);
58
		$this->creerCookie($nom_utilisateur, $pass, true);
58
	}
59
	}
59
 
60
 
60
	public function creerCookie($utilisateur, $pass, $pass_deja_crypte = false) {
61
	public function creerCookie($utilisateur, $pass, $pass_deja_crypte = false) {
61
		$this->objet_identification = Config::get('objet_identification');
62
		$this->objet_identification = Config::get('objet_identification');
62
 
63
 
63
		// Expiration si l'utilisateur ne referme pas son navigateur
64
		// Expiration si l'utilisateur ne referme pas son navigateur
64
		$this->objet_identification->setExpire(0);
65
		$this->objet_identification->setExpire(0);
65
		$this->objet_identification->setIdle(0);
66
		$this->objet_identification->setIdle(0);
66
 
67
 
67
		// Création d'un cookie pour rendre permanente l'identification de Papyrus
68
		// Création d'un cookie pour rendre permanente l'identification de Papyrus
68
		if (!$pass_deja_crypte) {
-
 
69
			$pass_crypt = md5($pass);
69
		$pass_crypt = (!$pass_deja_crypte) ? md5($pass) : $pass;
70
		} else {
-
 
71
			$pass_crypt = $pass;
-
 
72
		}
-
 
73
		$cookie_val = $pass_crypt.$utilisateur;
70
		$cookie_val = $pass_crypt.$utilisateur;
74
		setcookie(session_name().'-memo', $cookie_val, 0, '/');
71
		setcookie(session_name().'-memo', $cookie_val, 0, '/');
75
	}
72
	}
76
 
73
 
77
	public function obtenirLoginUtilisateurParCookie() {
74
	public function obtenirLoginUtilisateurParCookie() {
78
		$nom_session = Config::get('nom_session');
75
		$nom_session = Config::get('nom_session');
79
 
76
 
80
		if (isset($_COOKIE[$nom_session])) {
77
		if (isset($_COOKIE[$nom_session])) {
81
			$cookie_val = $_COOKIE[$nom_session];
78
			$cookie_val = $_COOKIE[$nom_session];
82
			$login_utilisateur = substr($cookie_val, '32', strlen($cookie_val));
79
			$login_utilisateur = substr($cookie_val, '32', strlen($cookie_val));
83
			return $login_utilisateur;
80
			return $login_utilisateur;
84
		} else {
81
		} else {
85
			return false;
82
			return false;
86
		}
83
		}
87
	}
84
	}
88
}
85
}
89
?>
86
?>