Subversion Repositories Applications.annuaire

Rev

Rev 401 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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