Subversion Repositories Applications.annuaire

Rev

Rev 333 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
332 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Service retournant l'id d'un utilisateur en fonction de son courriel.
5
 *
6
 * @category	php 5.2
7
 * @package		Annuaire::Services
8
 * @author		Aurélien PERONNET <aurelien@tela-botanica.org>
9
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
 * @copyright	Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
13
 * @version		$Id$
14
 */
15
class Utilisateur extends JRestService {
16
 
17
	public function getElement($ressources){
18
		$this->ressources = $ressources;
19
 
20
		$infos = null;
21
 
22
		if (isset($this->ressources[0])) {
23
			$methode_demande = array_shift($this->ressources);
24
			$methode = $this->traiterNomMethodeGet($methode_demande);
25
			if (method_exists($this, $methode)) {
26
				$infos = $this->$methode();
27
			} else {
28
				$this->messages[] = "Ce type de ressource '$methode_demande' n'est pas disponible.";
29
			}
30
		} else {
31
			$this->messages[] = "Le premier paramêtre du chemin du service doit correspondre au type de ressource demandée.";
32
		}
33
 
34
		if (!is_null($infos)) {
35
			$this->envoyerJson($infos);
36
		} else {
37
			$info = 'Un problème est survenu : '.print_r($this->messages, true);
38
			$this->envoyerTxt($info);
39
		}
40
	}
41
 
42
	public function getPrenomNomParCourriel() {
43
		$courriels = explode(',', $this->ressources[0]);
44
		$id_annuaire = Config::get('annuaire_defaut');
45
 
46
	    $controleur = new AnnuaireModele();
47
		$infos = $controleur->obtenirPrenomNomParCourriel($id_annuaire, $courriels);
48
		return $infos;
49
	}
50
}
51
?>