Subversion Repositories Applications.annuaire

Rev

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

Rev 294 Rev 359
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 IdentificationControleur() {
21
	/*public function IdentificationControleur() {
22
 
22
 
23
		Controleur::__construct();
23
		Controleur::__construct();
24
		$this->cookie_persistant_nom = session_name().'-memo';
24
		$this->cookie_persistant_nom = session_name().'-memo';
25
		$this->cookie_persistant_nom = 'pap-admin_papyrus_-memo';
25
		$this->cookie_persistant_nom = 'pap-admin_papyrus_-memo';
26
		$this->duree_identification = time()+Config::get('duree_session_identification');
26
		$this->duree_identification = time()+Config::get('duree_session_identification');
27
		$this->fonction_cryptage_mdp_cookie = Config::get('fonction_cryptage_mdp_cookie');
27
		$this->fonction_cryptage_mdp_cookie = Config::get('fonction_cryptage_mdp_cookie');
28
		
28
		
29
	}*/
29
	}*/
30
 
30
 
31
	public function afficherFormulaireIdentification($id_annuaire, $donnees = array()) {
31
	public function afficherFormulaireIdentification($id_annuaire, $donnees = array()) {
32
 
32
 
33
		$this->chargerModele('AnnuaireModele');
33
		$this->chargerModele('AnnuaireModele');
34
		$annuaire = $this->AnnuaireModele->chargerAnnuaire($id_annuaire);
34
		$annuaire = $this->AnnuaireModele->chargerAnnuaire($id_annuaire);
35
 
35
 
36
		if(!isset($donnees['informations'])) {
36
		if(!isset($donnees['informations'])) {
37
			$donnees['informations'] = array();
37
			$donnees['informations'] = array();
38
		}
38
		}
39
 
39
 
40
		$donnees['id_annuaire'] = $id_annuaire;
40
		$donnees['id_annuaire'] = $id_annuaire;
41
 
41
 
42
		return $this->getVue(Config::get('dossier_squelettes_formulaires').'identification',$donnees);
42
		return $this->getVue(Config::get('dossier_squelettes_formulaires').'identification',$donnees);
43
	}
43
	}
44
	
44
	
45
	public function loggerUtilisateur($utilisateur, $pass) {
45
	public function loggerUtilisateur($utilisateur, $pass) {
46
		
46
		
47
		$this->objet_identification = Config::get('objet_identification');
47
		$this->objet_identification = Config::get('objet_identification');
48
		
48
		
49
		// on cree le cookie
49
		// on cree le cookie
50
		$this->creerCookie($utilisateur, $pass);
50
		$this->creerCookie($utilisateur, $pass);
51
		
51
		
52
		// On loggue l'utilisateur
52
		// On loggue l'utilisateur
53
		$this->objet_identification->username = $utilisateur;
53
		$this->objet_identification->username = $utilisateur;
54
		$this->objet_identification->password = $pass;
54
		$this->objet_identification->password = $pass;
55
		$this->objet_identification->login();
55
		$this->objet_identification->login();
56
 
56
 
57
		return true;
57
		return true;
58
	}
58
	}
59
	
59
	
60
	public function deLoggerUtilisateur() {
60
	public function deLoggerUtilisateur() {
61
		
61
		
62
		$this->objet_identification = Config::get('objet_identification');
62
		$this->objet_identification = Config::get('objet_identification');
63
		$this->objet_identification->logout();
63
		$this->objet_identification->logout();
64
		
64
		
65
		return true;
65
		return true;
66
	}
66
	}
67
	
67
	
68
	public function setUtilisateur($nom_utilisateur) {
68
	public function setUtilisateur($nom_utilisateur) {
69
		$this->objet_identification = Config::get('objet_identification');
69
		$this->objet_identification = Config::get('objet_identification');
70
		$this->objet_identification->setAuth($nom_utilisateur);
70
		$this->objet_identification->setAuth($nom_utilisateur);
71
		$pass = $this->objet_identification->password;
71
		$pass = $this->objet_identification->password;
72
		$this->creerCookie($nom_utilisateur, $pass, true);
72
		$this->creerCookie($nom_utilisateur, $pass, true);
73
	}
73
	}
74
	
74
	
75
	public function creerCookie($utilisateur, $pass, $pass_deja_crypte = false) {
75
	public function creerCookie($utilisateur, $pass, $pass_deja_crypte = false) {
76
		
76
		
77
		$this->objet_identification = Config::get('objet_identification');
77
		$this->objet_identification = Config::get('objet_identification');
78
		
78
		
79
		// Expiration si l'utilisateur ne referme pas son navigateur
79
		// Expiration si l'utilisateur ne referme pas son navigateur
80
		$this->objet_identification->setExpire(0);
80
		$this->objet_identification->setExpire(0);
-
 
81
		$this->objet_identification->setIdle(0);
81
		// Création d'un cookie pour rendre permanente l'identification de Papyrus
82
		// Création d'un cookie pour rendre permanente l'identification de Papyrus
82
		if(!$pass_deja_crypte) {
83
		if(!$pass_deja_crypte) {
83
			$pass_crypt = md5($pass); 
84
			$pass_crypt = md5($pass); 
84
		} else {
85
		} else {
85
			$pass_crypt = $pass;
86
			$pass_crypt = $pass;
86
		}
87
		}
87
		$cookie_val = $pass_crypt.$utilisateur;
88
		$cookie_val = $pass_crypt.$utilisateur;
88
		setcookie(session_name().'-memo', $cookie_val, 0, '/');		
89
		setcookie(session_name().'-memo', $cookie_val, 0, '/');		
89
	}
90
	}
90
	
91
	
91
	public function obtenirLoginUtilisateurParCookie() {
92
	public function obtenirLoginUtilisateurParCookie() {
92
 
93
 
93
		$nom_session = Config::get('nom_session');
94
		$nom_session = Config::get('nom_session');
94
		
95
		
95
		if(isset($_COOKIE[$nom_session])) {
96
		if(isset($_COOKIE[$nom_session])) {
96
			$cookie_val = $_COOKIE[$nom_session];
97
			$cookie_val = $_COOKIE[$nom_session];
97
			$login_utilisateur = substr($cookie_val, '32', strlen($cookie_val));
98
			$login_utilisateur = substr($cookie_val, '32', strlen($cookie_val));
98
			return $login_utilisateur;
99
			return $login_utilisateur;
99
		} else {
100
		} else {
100
			return false;
101
			return false;
101
		}
102
		}
102
		
103
		
103
	}
104
	}
104
}
105
}
105
?>
106
?>