Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 387 | Rev 979 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 387 Rev 845
Line 23... Line 23...
23
	 * Lance l'interrogation du service de l'annuaire.
23
	 * Lance l'interrogation du service de l'annuaire.
24
	 *
24
	 *
25
	 * @return null.
25
	 * @return null.
26
	 */
26
	 */
27
	public function chargerIdentites() {
27
	public function chargerIdentites() {
28
		$this->identites = $this->getIdentites();
28
		$this->identites = $this->getIdentites($this->courriels);
29
	}
29
	}
Line 30... Line 30...
30
 
30
 
31
	/**
31
	/**
32
	* Retourne après avoir interrogé un service de l'annuaire, les intitulés correspondant aux
32
	* Retourne après avoir interrogé un service de l'annuaire, les intitulés correspondant aux
33
	* courriels des utilisateurs.
33
	* courriels des utilisateurs.
34
	*
34
	*
35
	* @return mixed tableau avec en clé le courriel et en valeur l'intitulé de la personne à
35
	* @return mixed tableau avec en clé le courriel et en valeur l'intitulé de la personne à
36
	* afficher, false en cas d'erreur ou de résultat vide.
36
	* afficher, false en cas d'erreur ou de résultat vide.
37
	*/
37
	*/
38
	public function getIntitules() {
-
 
39
		$intitules = false;
38
	public function getIntitules() {
40
		$this->chargerIdentites();
39
		$this->chargerIdentites();
-
 
40
		if (! $this->identites) return false;
41
		if ($this->identites) {
41
 
42
			$intitules = array();
42
		$intitules = array();
43
			foreach ($this->identites as $courriel => $infos) {
43
		foreach ($this->identites as $courriel => $infos) {
44
				$intitules[$courriel] = $infos['intitule'];
44
			$intitules[$courriel] = $infos['intitule'];
45
			}
-
 
46
		}
45
		}
47
		return $intitules;
46
		return $intitules;
Line 48... Line 47...
48
	}
47
	}
49
 
48
 
50
	/**
49
	/**
51
	 * Retourne un intitulé en fonction d'un courriel.
50
	 * Retourne un intitulé en fonction d'un courriel.
52
	 *
51
	 *
53
	 * @return String l'intitulé de l'utilisateur ou une chaine vide en cas de problème.
52
	 * @return String l'intitulé de l'utilisateur ou une chaine vide en cas de problème.
54
	 */
-
 
55
	public function getIntitule($courriel) {
53
	 */
56
		$intitule = '';
54
	public function getIntitule($courriel) {
57
		if ($this->contenirCourriel($courriel)) {
55
		if ($this->contenirCourriel($courriel)) {
58
			$intitule = $this->identites[$courriel]['intitule'];
56
			return $this->identites[$courriel]['intitule'];
59
		}
57
		}
Line 60... Line 58...
60
		return $intitule;
58
		return '';
61
	}
59
	}
62
 
60
 
63
	/**
61
	/**
64
	 * Retourne l'identifiant de l'utilisateur en fonction d'un courriel.
62
	 * Retourne l'identifiant de l'utilisateur en fonction d'un courriel.
65
	 *
63
	 *
66
	 * @return String l'id de l'utilisateur ou une chaine vide en cas de problème.
-
 
67
	 */
64
	 * @return String l'id de l'utilisateur ou une chaine vide en cas de problème.
68
	public function getId($courriel) {
65
	 */
69
		$id = '';
66
	public function getId($courriel) {
70
		if ($this->contenirCourriel($courriel)) {
67
		if ($this->contenirCourriel($courriel)) {
71
			$id = $this->identites[$courriel]['id'];
68
			return $this->identites[$courriel]['id'];
Line 72... Line 69...
72
		}
69
		}
73
		return $id;
70
		return '';
74
	}
-
 
75
 
-
 
76
	private function contenirCourriel($courriel) {
-
 
77
		$ok = ($this->identites && isset($this->identites[$courriel])) ? true : false;
-
 
78
		return $ok;
-
 
79
	}
-
 
80
 
-
 
81
	private function getIdentites() {
71
	}
Line 82... Line 72...
82
		$utilisateursInfos = $this->consulterServiceAnnuaire();
72
 
83
		$identites = $this->extraireIdentites($utilisateursInfos);
73
	private function contenirCourriel($courriel) {
84
		return $identites;
74
		return ($this->identites && isset($this->identites[$courriel])) ? true : false;
85
	}
75
	}
86
 
76
 
-
 
77
	private function getIdentites($courriels) {
87
	private function consulterServiceAnnuaire() {
78
		// consulterServiceAnnuaire
Line 88... Line 79...
88
		$url = sprintf(self::TPL_URL_WS_ANNUAIRE, implode(',', $this->courriels));
79
		$utilisateursInfos = json_decode($this->clientRest->consulter(sprintf(self::TPL_URL_WS_ANNUAIRE,
89
		$json = $this->clientRest->consulter($url);
80
																			  implode(',', $courriels))),
90
		$utilisateurs = json_decode($json, true);
81
										 true);
91
		return $utilisateurs;
82
		return self::extraireIdentites($utilisateursInfos, $this->courriels);
92
	}
83
	}
93
 
84
 
94
	private function extraireIdentites($utilisateursInfos) {
85
	static function extraireIdentites($utilisateursInfos, $courriels) {
95
		$identites = array();
86
		$identites = array();
96
		foreach ($this->courriels as $courriel) {
87
		foreach ($courriels as $courriel) {
97
			$info = array('id' => null, 'intitule' => '');
88
			$info = array('id' => null, 'intitule' => '');
98
			if (isset($utilisateursInfos[$courriel])) {
89
			if (isset($utilisateursInfos[$courriel])) {
99
				$info['intitule'] = $utilisateursInfos[$courriel]['intitule'];
90
				$info['intitule'] = $utilisateursInfos[$courriel]['intitule'];
100
				$info['id'] = $utilisateursInfos[$courriel]['id'];
91
				$info['id'] = $utilisateursInfos[$courriel]['id'];
101
			} else {
92
			} else {
Line 102... Line 93...
102
				$info['intitule'] = $this->tronquerCourriel($courriel);
93
				$info['intitule'] = self::tronquerCourriel($courriel);
103
			}
94
			}
104
			$identites[$courriel] = $info;
-
 
105
		}
95
			$identites[$courriel] = $info;
106
		return $identites;
96
		}
107
	}
97
		return $identites;
108
 
98
	}