Subversion Repositories eFlore/Applications.del

Rev

Rev 1820 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1820 Rev 1821
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Service fournissant des informations concernant les votes sur les images de DEL en fonction d'un protocole
4
 * Service fournissant des informations concernant les votes sur les images de DEL en fonction d'un protocole
5
 * au format RSS1, RSS2 ou ATOM.
5
 * au format RSS1, RSS2 ou ATOM.
6
 *
6
 *
7
 * @category   DEL
7
 * @category   DEL
8
 * @package    Services
8
 * @package    Services
9
 * @subpackage Syndication
9
 * @subpackage Syndication
10
 * @version    0.1
10
 * @version    0.1
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
17
 */
17
 */
18
class SyndicationVotesParProtocole {
18
class VotesParProtocole {
19
	/**
-
 
20
	 * Paramètres du service
-
 
21
	 * */
-
 
22
	private $mappingFiltre = array();
-
 
23
	private $conteneur = null;
-
 
24
	private $bdd = null;
-
 
25
	private $navigation = null;
-
 
26
	private $type_rss = null;
-
 
-
 
19
 
-
 
20
	private $categorie = 'Vote protocole';
27
 
21
	private $conteneur;
28
	/**
22
	private $bdd;
29
	 * Constructeur
23
	private $navigation;
-
 
24
	private $syndication;
30
	 * Initialiser les configurations
25
	private $mapping = array();
31
	 * */
26
 
32
	public function __construct(Conteneur $conteneur = null) {
27
	public function __construct(Conteneur $conteneur) {
33
		$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
-
 
34
		$this->conteneur->chargerConfiguration('config_syndication_votesparprotocole.ini');
-
 
35
		$this->mappingFiltre = $this->conteneur->getParametre('mapping_masque');
28
		$this->conteneur = $conteneur;
36
		$this->bdd = $this->conteneur->getBdd();
29
		$this->bdd = $this->conteneur->getBdd();
-
 
30
		$this->navigation = $this->conteneur->getNavigation();
-
 
31
		$this->syndication = $this->conteneur->getSyndicationOutils();
37
		$this->navigation = $this->conteneur->getNavigation();
32
		$this->mapping = $this->conteneur->getParametreTableau('syndication.mapping');
38
	}
-
 
39
 
-
 
40
	/**
-
 
41
	 * Consulter
-
 
42
	 * Méthode par défaut pour récupérer l'ensemble des votes.
-
 
43
	 * Vérifie la configuration et retourne les derniers votes formatés
33
	}
44
	 * */
-
 
45
	public function consulter($params = array()) {
-
 
46
		$this->verifierConfiguration();
34
 
47
		$this->type_rss = $params[1];
35
	public function consulter() {
48
		if ($this->fluxAdminDemande()) {
36
		if ($this->syndication->fluxAdminDemande()) {
49
			$this->demanderAutorisationAdmin();
37
			$this->syndication->demanderAutorisationAdmin();
50
		}
38
		}
51
 
39
 
52
		$donnees_brutes = $this->getDerniersVotesImage();
40
		$donnees_brutes = $this->getDerniersVotesImage();
53
		$commentaires_formates = $this->formaterPourRss($donnees_brutes) ;
41
		$commentaires_formates = $this->formaterPourRss($donnees_brutes) ;
54
		return $commentaires_formates;
42
		return $commentaires_formates;
55
	}
43
	}
56
 
44
 
57
	/**
45
	/**
58
	* Vérifier que le service est bien configuré
-
 
59
	* */
-
 
60
	public function verifierConfiguration() {
-
 
61
		$erreurs = array();
-
 
62
 
-
 
63
		if (empty($this->mappingFiltre)) {
-
 
64
			$erreurs[] = '- le fichier de configuration ne contient pas le tableau [mapping_masque] ou celui-ci est vide ;';
-
 
65
		} else {
-
 
66
			$champsMappingFiltre = array('image', 'protocole');
-
 
67
			foreach ($champsMappingFiltre as $champ) {
-
 
68
				if (!isset($this->mappingFiltre[$champ])) {
-
 
69
					$erreurs[] = '- le mapping du champ "'.$champ.'" pour le commentaire est manquant ;';
-
 
70
				}
-
 
71
			}
-
 
72
		}
-
 
73
 
-
 
74
		if (!empty($erreurs)) {
-
 
75
			$e = 'Erreur lors de la configuration : '."\n";
-
 
76
			$e .= implode("\n", $erreurs);
-
 
77
			throw new Exception($e, RestServeur::HTTP_CODE_ERREUR);
-
 
78
		}
-
 
79
	}
-
 
80
 
-
 
81
	/**
-
 
82
	 * Verifier si le flux admin est demandé
-
 
83
	 */
-
 
84
	private function fluxAdminDemande() {
-
 
85
		return $this->conteneur->getParametre('admin') != null && $this->conteneur->getParametre('admin') == 1;
-
 
86
	}
-
 
87
 
-
 
88
	/**
-
 
89
	 * Si le flux est un flux admin, demander un mot de passe
-
 
90
	 * */
-
 
91
	private function demanderAutorisationAdmin() {
-
 
92
		$verification = $this->conteneur->getControleAcces();
-
 
93
		$verification->demanderAuthentificationAdmin();
-
 
94
	}
-
 
95
 
-
 
96
	/**
-
 
97
	 * Formater les données pour mettre en page le RSS
46
	 * Formater les données pour mettre en page le RSS
98
	 * */
47
	 * */
99
	private function formaterPourRss($elements) {
48
	private function formaterPourRss($elements) {
100
		$donnees = $this->construireDonneesCommunesAuFlux($elements);
-
 
101
		foreach ($elements as $element) {
49
		$derniere_info_en_date = reset($elements);
102
			$identifiants[$element['id_vote']] = $element['id_vote'];
50
		$donnees = $this->syndication->construireDonneesCommunesAuFlux('vote', $derniere_info_en_date['date_vote']);
103
		}
-
 
104
		foreach ($elements as $element) {
51
		foreach ($elements as $element) {
105
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
52
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
106
		}
53
		}
107
		return $donnees;
54
		return $donnees;
108
	}
55
	}
109
 
56
 
110
	/**
57
	/**
111
	 * Générer les métadonnées du flux (titre, dates, editeur etc.)
-
 
112
	 * */
-
 
113
	private function construireDonneesCommunesAuFlux($infos) {
-
 
114
		$donnees = array();
-
 
115
		$donnees['guid'] = htmlspecialchars($this->creerUrlService());
-
 
116
		$donnees['titre'] = 'pictoFlora : votes';
-
 
117
		$donnees['description'] = 'Ce flux regroupe les derniers votes sur les images de pictoFlora';
-
 
118
		$donnees['lien_service'] = htmlspecialchars($this->creerUrlService());
-
 
119
		$donnees['lien_del'] = $this->conteneur->getParametre('pictoAppliLien');
-
 
120
		$donnees['editeur'] = $this->conteneur->getParametre('editeur');
-
 
121
		$derniere_info_en_date = reset($infos);
-
 
122
		$date_modification_timestamp = strtotime($derniere_info_en_date['date_vote']);
-
 
123
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
-
 
124
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
-
 
125
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
-
 
126
		$donnees['annee_courante'] = date('Y');
-
 
127
		$donnees['generateur'] = 'DEL - SyndicationCommentaire';
-
 
128
		$donnees['generateur_version'] = (preg_match('/([0-9]+)/', '$Revision$', $match)) ?  $match[1] : '0';
-
 
129
		return $donnees;
-
 
130
	}
-
 
131
 
-
 
132
	/**
-
 
133
	 * Générer le lien du flux RSS
-
 
134
	 * */
-
 
135
	private function creerUrlService() {
-
 
136
		$url_service = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
-
 
137
		return $url_service;
-
 
138
	}
-
 
139
 
-
 
140
	/**
-
 
141
	 * Générer les données communes & spécifiques à chaque item
58
	 * Générer les données communes & spécifiques à chaque item
142
	 * */
59
	 * */
143
	private function construireDonneesCommunesAuxItems($info) {
60
	private function construireDonneesCommunesAuxItems($info) {
144
		$item = array();
61
		$item = array();
145
		$date_modification_timestamp = strtotime($info['date_vote']);
62
		$date_modification_timestamp = strtotime($info['date_vote']);
146
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
63
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
147
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
64
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
148
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
65
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
149
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
66
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
150
		$item['titre'] = $this->creerTitre($info);
67
		$item['titre'] = $this->creerTitre($info);
151
		$item['guid'] = $this->creerGuidItem($info);
68
		$item['guid'] = $this->creerGuidItem($info);
152
		$item['lien'] = $this->creerLienItem($info);
69
		$item['lien'] = $this->creerLienItem($info);
153
		$item['categorie'] = $this->creerCategorie($item);
70
		$item['categorie'] = htmlentities($this->categorie);
154
		$item['description'] = $this->creerDescription($info, $item);
71
		$item['description'] = $this->creerDescription($info, $item);
155
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
72
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
156
		$item['modifier_par'] = $this->creerVotant($info);
73
		$item['modifier_par'] = $this->creerVotant($info);
157
		return $item;
74
		return $item;
158
	}
75
	}
159
 
-
 
160
	private function creerCategorie($element) {
-
 
161
		$categorie = 'Vote protocole';
-
 
162
		$categorie = htmlentities($categorie);
-
 
163
		return $categorie;
-
 
164
	}
-
 
165
 
76
 
166
	private function creerGuidItem($element) {
77
	private function creerGuidItem($element) {
167
		$guid = sprintf($this->conteneur->getParametre('voteGuidTpl'), $element['id_vote']);
78
		$guid = sprintf($this->conteneur->getParametre('syndication.vote_guid_tpl'), $element['id_vote']);
168
		return $guid;
79
		return $guid;
169
	}
80
	}
170
 
81
 
171
	private function creerLienItem($element) {
82
	private function creerLienItem($element) {
172
		$lien = sprintf($this->conteneur->getParametre('imgFicheTpl'), $element['ce_image']);
83
		$lien = sprintf($this->conteneur->getParametre('img_fiche_tpl'), $element['ce_image']);
173
		return $lien;
84
		return $lien;
174
	}
85
	}
175
 
86
 
176
	private function creerTitre($element) {
87
	private function creerTitre($element) {
177
		$noteVote = $element['valeur'];
88
		$noteVote = $element['valeur'];
178
		$nomSci = htmlspecialchars($element['nom_sel']);
89
		$nomSci = htmlspecialchars($element['nom_sel']);
179
		$votant = htmlspecialchars($this->creerVotant($element));
90
		$votant = htmlspecialchars($this->creerVotant($element));
180
		$observateur = htmlspecialchars($this->creerObservateur($element));
91
		$observateur = htmlspecialchars($this->creerObservateur($element));
181
 
92
 
182
		$titre = "Vote $noteVote par $votant pour $nomSci de $observateur";
93
		$titre = "Vote $noteVote par $votant pour $nomSci de $observateur";
183
		return $titre;
94
		return $titre;
184
	}
95
	}
185
 
96
 
186
	private function creerDescription($donnees, $item) {
97
	private function creerDescription($donnees, $item) {
187
		$idVote = htmlspecialchars($donnees['id_vote']);
98
		$idVote = htmlspecialchars($donnees['id_vote']);
188
		$idObs = htmlspecialchars($donnees['id_observation']);
99
		$idObs = htmlspecialchars($donnees['id_observation']);
189
		$idImg = htmlspecialchars($donnees['ce_image']);
100
		$idImg = htmlspecialchars($donnees['ce_image']);
190
		$urlImg = $this->getUrlImage($donnees['ce_image']);
101
		$urlImg = $this->syndication->getUrlImage($donnees['ce_image']);
191
		$miniatureUrl = $this->getUrlImage($donnees['ce_image'], 'CRS');
102
		$miniatureUrl = $this->syndication->getUrlImage($donnees['ce_image'], 'CRS');
192
		$nomSelActuel = htmlspecialchars($donnees['nom_sel']);
103
		$nomSelActuel = htmlspecialchars($donnees['nom_sel']);
193
		$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['date_observation']));
104
		$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['date_observation']));
194
		$lieuObs = htmlspecialchars($donnees['zone_geo']);
105
		$lieuObs = htmlspecialchars($donnees['zone_geo']);
195
		$protocole = htmlspecialchars($donnees['intitule']);
106
		$protocole = htmlspecialchars($donnees['intitule']);
196
		$votant = htmlspecialchars($this->creerVotant($donnees));
107
		$votant = htmlspecialchars($this->creerVotant($donnees));
197
		$dateVote = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', strtotime($donnees['date_vote'])));
108
		$dateVote = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', strtotime($donnees['date_vote'])));
198
		$observateur = htmlspecialchars($this->creerObservateur($donnees));
109
		$observateur = htmlspecialchars($this->creerObservateur($donnees));
199
 
110
 
200
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
111
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
201
			'<h2>'."Vote pictoFlora #$idVote pour l'image #$idImg de l'observation #$idObs".'</h2>'.
112
			'<h2>'."Vote pictoFlora #$idVote pour l'image #$idImg de l'observation #$idObs".'</h2>'.
202
			'<div class="gauche">'.
113
			'<div class="gauche">'.
203
			'	<a href="'.$urlImg.'">'.
114
			'	<a href="'.$urlImg.'">'.
204
			'		<img src="'.$miniatureUrl.'" alt="Img #'.$idImg.'"/>'.
115
			'		<img src="'.$miniatureUrl.'" alt="Img #'.$idImg.'"/>'.
205
			'	</a>'.
116
			'	</a>'.
206
			'</div>'.
117
			'</div>'.
207
			'<div class="gauche">'.
118
			'<div class="gauche">'.
208
			"	<h3>Image #$idImg de l'observation #$idObs</h3>".
119
			"	<h3>Image #$idImg de l'observation #$idObs</h3>".
209
			'	<ul>'.
120
			'	<ul>'.
210
			'		<li><span class="champ">'."Auteur de l'image :</span> $observateur</li>".
121
			'		<li><span class="champ">'."Auteur de l'image :</span> $observateur</li>".
211
			'		<li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
122
			'		<li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
212
			'		<li><span class="champ">'."Lieu :</span> $lieuObs</li>".
123
			'		<li><span class="champ">'."Lieu :</span> $lieuObs</li>".
213
			'		<li><span class="champ">'."Date :</span> $dateObs</li>".
124
			'		<li><span class="champ">'."Date :</span> $dateObs</li>".
214
			'	</ul>'.
125
			'	</ul>'.
215
			'</div>'.
126
			'</div>'.
216
			'<div class="gauche">'.
127
			'<div class="gauche">'.
217
			"	<h3>Vote #$idVote</h3>".
128
			"	<h3>Vote #$idVote</h3>".
218
			'	<ul>'.
129
			'	<ul>'.
219
			'		<li><span class="champ">'."Protocole :</span> <strong>$protocole</strong></li>".
130
			'		<li><span class="champ">'."Protocole :</span> <strong>$protocole</strong></li>".
220
			'		<li><span class="champ">'."Valeur :</span> <strong>{$donnees['valeur']}</strong>/5</li>".
131
			'		<li><span class="champ">'."Valeur :</span> <strong>{$donnees['valeur']}</strong>/5</li>".
221
			'		<li><span class="champ">'."Votant :</span> $votant</li>".
132
			'		<li><span class="champ">'."Votant :</span> $votant</li>".
222
			'		<li><span class="champ">'."À voté le :</span> $dateVote</li>".
133
			'		<li><span class="champ">'."À voté le :</span> $dateVote</li>".
223
			'	</ul>'.
134
			'	</ul>'.
224
			'</div>';
135
			'</div>';
225
		return $description;
136
		return $description;
226
	}
137
	}
227
 
-
 
228
	private function getUrlImage($id, $format = 'L') {
-
 
229
		$url_tpl = $this->conteneur->getParametre('celImgUrlTpl');
-
 
230
		$id = sprintf('%09s', $id).$format;
-
 
231
		$url = sprintf($url_tpl, $id);
-
 
232
		return $url;
-
 
233
	}
-
 
234
 
138
 
235
	private function creerVotant($info) {
139
	private function creerVotant($info) {
236
		$votant = 'Anonyme';
140
		$votant = 'Anonyme';
237
		if (isset($info['votant_prenom']) && isset($info['votant_nom'])) {
141
		if (isset($info['votant_prenom']) && isset($info['votant_nom'])) {
238
			$votant = $info['votant_prenom'].' '.$info['votant_nom'];
142
			$votant = $info['votant_prenom'].' '.$info['votant_nom'];
239
		}
143
		}
240
		return $votant;
144
		return $votant;
241
	}
145
	}
242
 
146
 
243
	private function creerObservateur($info) {
147
	private function creerObservateur($info) {
244
		$observateur = 'Anonyme';
148
		$observateur = 'Anonyme';
245
		if ($info['observateur_prenom'] != '' && $info['observateur_nom'] != '') {
149
		if ($info['observateur_prenom'] != '' && $info['observateur_nom'] != '') {
246
			$observateur = $info['observateur_prenom'].' '.$info['observateur_nom'];
150
			$observateur = $info['observateur_prenom'].' '.$info['observateur_nom'];
247
		}
151
		}
248
		return $observateur;
152
		return $observateur;
249
	}
153
	}
250
 
154
 
251
	/**
155
	/**
252
	 * Retrouver les derniers votes image
156
	 * Retrouver les derniers votes image
253
	 * */
157
	 * */
254
	private function getDerniersVotesImage() {
158
	private function getDerniersVotesImage() {
-
 
159
		$clauseWhere = $this->chargerClauseWhere();
255
		$requete =  'SELECT DISTINCT id_vote, ce_image, valeur, divo.date AS date_vote, '.
160
		$requete =  'SELECT DISTINCT id_vote, ce_image, valeur, divo.date AS date_vote, '.
256
				'	duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, '.
161
				'	duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, '.
257
				'	duv.prenom AS votant_prenom, duv.nom AS votant_nom, '.
162
				'	duv.prenom AS votant_prenom, duv.nom AS votant_nom, '.
258
				'	do.id_observation, do.nom_sel, do.zone_geo, do.date_observation, dip.intitule '.
163
				'	do.id_observation, do.nom_sel, do.zone_geo, do.date_observation, dip.intitule '.
259
				'FROM del_image_vote AS divo '.
164
				'FROM del_image_vote AS divo '.
260
				'	INNER JOIN del_obs_image AS doi '.
165
				'	INNER JOIN del_obs_image AS doi '.
261
				'		ON divo.ce_image = doi.id_image '.
166
				'		ON divo.ce_image = doi.id_image '.
262
				'	INNER JOIN del_observation AS do '.
167
				'	INNER JOIN del_observation AS do '.
263
				'		ON do.id_observation = doi.id_observation '.
168
				'		ON do.id_observation = doi.id_observation '.
264
				'	INNER JOIN del_image_protocole AS dip '.
169
				'	INNER JOIN del_image_protocole AS dip '.
265
				'		ON ce_protocole = id_protocole '.
170
				'		ON ce_protocole = id_protocole '.
266
				'	LEFT JOIN del_utilisateur AS duo '.
171
				'	LEFT JOIN del_utilisateur AS duo '.
267
				'		ON do.ce_utilisateur = duo.id_utilisateur '.
172
				'		ON do.ce_utilisateur = duo.id_utilisateur '.
268
				'	LEFT JOIN del_utilisateur AS duv '.
173
				'	LEFT JOIN del_utilisateur AS duv '.
269
				'		ON if((CHAR_LENGTH(divo.ce_utilisateur) <> 32),CAST(divo.ce_utilisateur AS unsigned),0) '.
174
				'		ON if((CHAR_LENGTH(divo.ce_utilisateur) <> 32),CAST(divo.ce_utilisateur AS unsigned),0) '.
270
				'			= duv.id_utilisateur '.
175
				'			= duv.id_utilisateur '.
271
				$this->chargerClauseWhere().' '.
176
				($clauseWhere != '' ? "WHERE $clauseWhere " : '').
272
				'ORDER BY divo.date DESC '.
177
				'ORDER BY divo.date DESC '.
273
				'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite();
178
				'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().
-
 
179
				' -- '.__FILE__.' : '.__LINE__;
274
 
180
 
275
		$elements = $this->bdd->recupererTous($requete);
181
		$elements = $this->bdd->recupererTous($requete);
276
		return $elements;
182
		return $elements;
277
	}
183
	}
278
 
-
 
279
	/**
-
 
280
	* Charger la clause WHERE en fonction des paramètres de masque
-
 
281
	* */
184
 
282
	private function chargerClauseWhere() {
185
	private function chargerClauseWhere() {
283
		$where = array();
186
		$where = array();
284
		$tableauMasque = $this->navigation->getFiltre();
187
		$filtres = $this->navigation->getFiltre();
285
		if (!empty($tableauMasque)) {
188
		if (!empty($filtres)) {
286
			foreach($tableauMasque as $idMasque => $valeurMasque) {
189
			$filtrePossibles = $this->conteneur->getParametreTableau('syndication.vote_filtres');
287
				$idMasque = str_replace('masque.', '', $idMasque);
190
			foreach ($filtres as $cleFiltre => $valeur) {
288
				switch ($idMasque) {
191
				if (in_array($cleFiltre, $filtrePossibles)) {
289
					case 'image':
192
					$champ = $this->mapping[$cleFiltre];
290
						$where[] = ' '.$this->mappingFiltre[$idMasque].' = '.$this->bdd->proteger($valeurMasque);
-
 
291
					break;
193
					$valeurP = $this->bdd->proteger($valeur);
292
					case 'protocole':
-
 
293
						$where[] = ' '.$this->mappingFiltre[$idMasque].' = '.$this->bdd->proteger($valeurMasque).' ';
-
 
294
					break;
-
 
295
					default:
-
 
296
						$where[] = ' '.$this->mappingFiltre[$idMasque].' = '.$this->bdd->proteger($valeurMasque);
-
 
297
					break;
194
					$where[] = " $champ = $valeurP ";
298
				}
195
				}
299
			}
196
			}
300
		}
197
		}
301
		if (!empty($where)) {
-
 
302
			return ' WHERE '.implode('AND', $where);
-
 
303
		} else {
-
 
304
			return;
-
 
305
		}
-
 
306
	}
-
 
307
 
-
 
308
	private function creerFiltreAuteur($valeurMasque) {
-
 
309
		$masque = '';
-
 
310
		$auteurId = $valeurMasque;
-
 
311
		if (is_numeric($auteurId)) {
-
 
312
			$masque = ' dc.ce_utilisateur = '.$auteurId;
-
 
313
		} else {
-
 
314
			if (strpos($auteurId, '@') === false) {
198
 
315
				$tableauNomPrenom = explode(' ',$auteurId, 2);
-
 
316
				if(count($tableauNomPrenom) == 2) {
-
 
317
					// on teste potentiellement un nom prenom ou bien un prénom nom
-
 
318
					$masque = '('.
-
 
319
						'(dc.utilisateur_nom LIKE '.$this->bdd->proteger($tableauNomPrenom[0].'%').' AND '.
-
 
320
							'dc.utilisateur_prenom LIKE '.$this->bdd->proteger($tableauNomPrenom[1].'%').') OR '.
-
 
321
							'(dc.utilisateur_nom LIKE '.$this->bdd->proteger($tableauNomPrenom[1].'%').' AND '.
-
 
322
							'dc.utilisateur_prenom LIKE '.$this->bdd->proteger($tableauNomPrenom[0].'%').')'.
-
 
323
					')';
-
 
324
				} else {
-
 
325
					$masque = '(
-
 
326
						(dc.utilisateur_nom LIKE '.$this->bdd->proteger($auteurId.'%').' OR '.
-
 
327
						'dc.utilisateur_prenom LIKE '.$this->bdd->proteger($auteurId.'%').')'.
-
 
328
					')';
-
 
329
				}
-
 
330
			} else {
-
 
331
				$masque = " do.utilisateur_courriel LIKE ".$this->bdd->proteger($valeurMasque.'%')." ";
-
 
332
			}
-
 
333
		}
-
 
334
		return $masque;
199
		return (!empty($where)) ? implode('AND', $where) : '';
335
	}
-
 
336
}
-
 
337
?>
200
	}
-
 
201
}
338
202