Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1174 Rev 1666
Line 14... Line 14...
14
* @version 0.1
14
* @version 0.1
15
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
15
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
16
*/
16
*/
17
class Utilisateurs extends RestService {
17
class Utilisateurs extends RestService {
Line 18... Line 18...
18
 
18
 
19
	
19
 
20
	private $parametres = array();
20
	private $parametres = array();
21
	private $ressources = array();
21
	private $ressources = array();
22
	private $methode = null;
22
	private $methode = null;
23
	private $projetNom = array();
23
	private $projetNom = array();
24
	private $serviceNom = array();
24
	private $serviceNom = array();
Line 25... Line 25...
25
	private $cheminCourant = null;
25
	private $cheminCourant = null;
26
 
26
 
27
	private $conteneur;
27
	private $conteneur;
28
	
28
 
Line 29... Line 29...
29
	/** Indique si oui (true) ou non (false), on veut utiliser les paramètres bruts. */
29
	/** Indique si oui (true) ou non (false), on veut utiliser les paramètres bruts. */
30
	protected $utilisationParametresBruts = true;
30
	protected $utilisationParametresBruts = true;
Line 47... Line 47...
47
		}
47
		}
48
		$reponseHttp->emettreLesEntetes();
48
		$reponseHttp->emettreLesEntetes();
49
		$corps = $reponseHttp->getCorps();
49
		$corps = $reponseHttp->getCorps();
50
		return $corps;
50
		return $corps;
51
	}
51
	}
52
	
52
 
53
	public function modifier($ressources, $parametres) {
53
	public function modifier($ressources, $parametres) {
54
		$this->methode = 'modifier';
54
		$this->methode = 'modifier';
55
		$resultat = '';
55
		$resultat = '';
56
		$reponseHttp = new ReponseHttp();
56
		$reponseHttp = new ReponseHttp();
57
		try {
57
		try {
Line 64... Line 64...
64
		}
64
		}
65
		$reponseHttp->emettreLesEntetes();
65
		$reponseHttp->emettreLesEntetes();
66
		$corps = $reponseHttp->getCorps();
66
		$corps = $reponseHttp->getCorps();
67
		return $corps;
67
		return $corps;
68
	}
68
	}
69
	
69
 
70
	private function initialiserRessourcesEtParametres($ressources, $parametres) {
70
	private function initialiserRessourcesEtParametres($ressources, $parametres) {
71
		$this->ressources = $ressources;
71
		$this->ressources = $ressources;
72
		$this->parametres = $parametres;
72
		$this->parametres = $parametres;
73
	}
73
	}
Line 76... Line 76...
76
		$retour = '';
76
		$retour = '';
77
		$this->initialiserProjet();
77
		$this->initialiserProjet();
78
		$retour = $this->initialiserService();
78
		$retour = $this->initialiserService();
79
		return $retour;
79
		return $retour;
80
	}
80
	}
81
	
81
 
Line 82... Line 82...
82
 
82
 
83
	/*------------------------------------------------------------------------------------------------------------------
83
	/*------------------------------------------------------------------------------------------------------------------
84
										CONFIGURATION DU PROJET
84
										CONFIGURATION DU PROJET
85
	------------------------------------------------------------------------------------------------------------------*/
85
	------------------------------------------------------------------------------------------------------------------*/
Line 96... Line 96...
96
 
96
 
97
	/*------------------------------------------------------------------------------------------------------------------
97
	/*------------------------------------------------------------------------------------------------------------------
98
								CONFIGURATION DU SERVICE
98
								CONFIGURATION DU SERVICE
99
	------------------------------------------------------------------------------------------------------------------*/
99
	------------------------------------------------------------------------------------------------------------------*/
100
	private function initialiserService() {
100
	private function initialiserService() {
101
		
101
 
102
		$this->chargerNomService();
102
		$this->chargerNomService();
103
				
103
 
104
		$classe = $this->obtenirNomClasseService($this->serviceNom);
104
		$classe = $this->obtenirNomClasseService($this->serviceNom);
105
		$chemins = array();
105
		$chemins = array();
106
		$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
106
		$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
107
		$chemins[] = $this->cheminCourant.'commun'.DS.$classe.'.php';
107
		$chemins[] = $this->cheminCourant.'commun'.DS.$classe.'.php';
108
		$retour = '';
108
		$retour = '';
109
		$service = null;
109
		$service = null;
110
		foreach ($chemins as $chemin) {
110
		foreach ($chemins as $chemin) {
111
			if (file_exists($chemin)) {
111
			if (file_exists($chemin)) {
112
				$this->conteneur->chargerConfiguration('config_'.$this->projetNom.'.ini');
112
				$this->conteneur->chargerConfiguration('config_'.$this->projetNom.'.ini');
113
				
113
 
114
				require_once $chemin;
114
				require_once $chemin;
115
				$service = new $classe($this->conteneur);
115
				$service = new $classe($this->conteneur);
116
				if ($this->methode == 'consulter') {
116
				if ($this->methode == 'consulter') {
117
					$retour = $service->consulter($this->ressources, $this->parametres);
117
					$retour = $service->consulter($this->ressources, $this->parametres);
118
				} elseif ($this->methode == 'ajouter') {
118
				} elseif ($this->methode == 'ajouter') {
119
					$retour = $service->ajouter($this->ressources, $this->parametres);				
119
					$retour = $service->ajouter($this->ressources, $this->parametres);
120
				} elseif ($this->methode == 'modifier') {
120
				} elseif ($this->methode == 'modifier') {
121
					$retour = $service->modifier($this->ressources, $this->parametres);				
121
					$retour = $service->modifier($this->ressources, $this->parametres);
122
				}
122
				}
123
			}
123
			}
124
		}
124
		}
125
		
125
 
126
		if (is_null($service)) {
126
		if (is_null($service)) {
127
			$message = "Le service demandé '{$this->serviceNom}' n'existe pas dans le projet {$this->projetNom} !";
127
			$message = "Le service demandé '{$this->serviceNom}' n'existe pas dans le projet {$this->projetNom} !";
128
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
128
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
129
			throw new Exception($message, $code);
129
			throw new Exception($message, $code);
130
		}
130
		}
131
		return $retour;
131
		return $retour;
132
	}
132
	}
133
	
133
 
134
	private function chargerNomService() {
134
	private function chargerNomService() {
135
		//S'il n'y a pas de ressources => envoyer sur identification anonyme
135
		//S'il n'y a pas de ressources => envoyer sur identification anonyme
136
		if (!isset($this->ressources) || empty($this->ressources)) {
136
		if (!isset($this->ressources) || empty($this->ressources)) {
137
			$this->serviceNom = 'identification-anonyme';
137
			$this->serviceNom = 'identification-anonyme';
Line 151... Line 151...
151
 
151
 
152
	private function obtenirNomClasseService($mot) {
152
	private function obtenirNomClasseService($mot) {
153
		$classeNom = str_replace(' ', '', ucwords(strtolower(str_replace('-', ' ', $mot))));
153
		$classeNom = str_replace(' ', '', ucwords(strtolower(str_replace('-', ' ', $mot))));
154
		return $classeNom;
154
		return $classeNom;
155
	}
-
 
156
 
-
 
157
 
155
	}
158
}
156
}
159
?>
157
?>