Subversion Repositories Applications.annuaire

Rev

Rev 359 | Rev 401 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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