Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 291 Rev 520
Line 4... Line 4...
4
	const NIVEAU_DEBUTANT = 1;
4
	const NIVEAU_DEBUTANT = 1;
5
	const NIVEAU_INTERMEDIAIRE = 2;
5
	const NIVEAU_INTERMEDIAIRE = 2;
6
	const NIVEAU_EXPERT = 3;
6
	const NIVEAU_EXPERT = 3;
Line 7... Line 7...
7
 
7
 
-
 
8
	private $dureeSauvegarde = null;
-
 
9
	private $nomCookieUtilisateur = '';
-
 
10
	private $nomCookieUtilisateurPersistant = '';
-
 
11
	private $nomCookieNiveau = '';
-
 
12
	private $niveauDefaut = '';
8
	private $dureeSauvegarde = null;
13
	private $urlWsAnnuaire = '';
Line -... Line 14...
-
 
14
	private $restClient = null;
-
 
15
 
-
 
16
	private $niveau = null;
-
 
17
	private $identifie = false;
-
 
18
	private $courriel = null;
-
 
19
	private $md5Mdp = null;
-
 
20
 
-
 
21
	public function __construct(Conteneur $conteneur) {
-
 
22
		$this->dureeSauvegarde = $conteneur->getParametre('cookies.duree');
-
 
23
		$this->nomCookieUtilisateur = $conteneur->getParametre('cookies.utilisateur');
-
 
24
		$this->nomCookieUtilisateurPersistant = $conteneur->getParametre('cookies.utilisateurPersistant');
-
 
25
		$this->nomCookieNiveau = $conteneur->getParametre('cookies.niveau');
-
 
26
		$this->niveauDefaut = $conteneur->getParametre('utilisateur.niveau.defaut');
-
 
27
		$this->urlWsAnnuaire = $conteneur->getParametre('baseUrlServicesAnnuaireTpl');
-
 
28
		$this->restClient = $conteneur->getRestClient();
Line 9... Line 29...
9
	private $niveau = null;
29
		$this->analyserCookies();
10
 
-
 
11
 
30
	}
12
	public function __construct($niveauDefaut) {
31
 
Line 13... Line 32...
13
		$this->niveau = isset($_COOKIE['eflore.niveau']) ? $_COOKIE['eflore.niveau'] : $niveauDefaut;
32
	public function getCourriel() {
14
		$this->dureeSauvegarde = 3600*24*365;
33
		return $this->courriel;
15
	}
34
	}
Line 16... Line 35...
16
 
35
 
17
	public function getNiveau() {
36
	public function getNiveau() {
18
		return $this->niveau;
37
		return $this->niveau;
Line -... Line 38...
-
 
38
	}
-
 
39
 
-
 
40
	public function sauver() {
-
 
41
		setcookie($this->nomCookieNiveau, time()+$this->dureeSauvegarde, '/');
Line 19... Line -...
19
	}
-
 
20
 
42
	}
-
 
43
 
-
 
44
	public function etreIdentifie() {
-
 
45
		$this->analyserCookies();
-
 
46
		return $this->identifie;
-
 
47
	}
-
 
48
 
-
 
49
	public function connecter($courriel, $mdp, $persistance = false) {
-
 
50
		$url = sprintf($this->urlWsAnnuaire, 'Utilisateur');
-
 
51
		$donnees['methode'] = 'connexion';
-
 
52
		$donnees['courriel'] = $courriel;
-
 
53
		$donnees['mdp'] = $mdp;
-
 
54
		$donnees['persistance'] = $persistance;
-
 
55
 
-
 
56
		$json = $this->restClient->ajouter($url, $donnees);
-
 
57
		$forceTableauAssociatif = true;
-
 
58
		$resultat = json_decode($json, $forceTableauAssociatif);
-
 
59
		Debug::printr($resultat);
-
 
60
		return $resultat['identifie'];
-
 
61
	}
-
 
62
 
-
 
63
	private function analyserCookies() {
-
 
64
		$this->analyserCookiesIdentite();
-
 
65
		$this->analyserCookiesNiveau();
-
 
66
	}
-
 
67
 
-
 
68
	private function analyserCookiesIdentite() {
-
 
69
		if ($this->identifie == false) {
-
 
70
			if (isset($_COOKIE[$this->nomCookieUtilisateurPersistant])) {
-
 
71
				$idTela = $_COOKIE[$this->nomCookieUtilisateurPersistant];
-
 
72
				$this->md5Mdp = substr($idTela, 0, 32);
-
 
73
				$this->courriel = substr($idTela, 32);
-
 
74
				$this->identifie = true;
-
 
75
			} else if (isset($_COOKIE[$this->nomCookieUtilisateur])) {
-
 
76
				$this->courriel = $_COOKIE[$this->nomCookieUtilisateur];
-
 
77
				$this->identifie = true;
-
 
78
			}
-
 
79
		}
-
 
80
	}
-
 
81
 
-
 
82
	private function analyserCookiesNiveau() {
-
 
83
		$this->niveau = $this->niveauDefaut;
21
	public function sauver() {
84
		if (isset($_COOKIE[$this->nomCookieNiveau])) {