Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1821 Rev 1922
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Service fournissant des informations concernant les commentaire de DEL au format RSS1, RSS2 ou ATOM.
4
 * Service fournissant des informations concernant les commentaire de DEL au format RSS1, RSS2 ou ATOM.
5
 *
5
 *
6
 * @category   DEL
6
 * @category   DEL
7
 * @package    Services
7
 * @package    Services
8
 * @subpackage Syndication
8
 * @subpackage Syndication
9
 * @version    0.1
9
 * @version    0.1
10
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
10
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
11
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
11
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
12
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
12
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
13
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
13
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
14
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
14
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
15
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
15
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
16
 */
16
 */
17
class Commentaires {
17
class Commentaires {
18
 
18
 
19
	private $categorie = 'Commentaires';
19
	private $categorie = 'Commentaires';
20
	private $conteneur;
20
	private $conteneur;
21
	private $contexte;
21
	private $contexte;
22
	private $bdd;
22
	private $bdd;
23
	private $navigation;
23
	private $navigation;
24
	private $mapping = array();
24
	private $mapping = array();
25
	private $syndication;
25
	private $syndication;
26
 
26
 
27
	public function __construct(Conteneur $conteneur = null) {
27
	public function __construct(Conteneur $conteneur = null) {
28
		$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
28
		$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
29
		$this->contexte = $this->conteneur->getContexte();
29
		$this->contexte = $this->conteneur->getContexte();
30
		$this->bdd = $this->conteneur->getBdd();
30
		$this->bdd = $this->conteneur->getBdd();
31
		$this->navigation = $this->conteneur->getNavigation();
31
		$this->navigation = $this->conteneur->getNavigation();
32
		$this->syndication = $this->conteneur->getSyndicationOutils();
32
		$this->syndication = $this->conteneur->getSyndicationOutils();
33
		$this->mapping = $this->conteneur->getParametreTableau('syndication.mapping');
33
		$this->mapping = $this->conteneur->getParametreTableau('syndication.mapping');
34
	}
34
	}
35
 
35
 
36
	public function consulter() {
36
	public function consulter() {
37
		if ($this->syndication->fluxAdminDemande()) {
37
		if ($this->syndication->fluxAdminDemande()) {
38
			$this->syndication->demanderAutorisationAdmin();
38
			$this->syndication->demanderAutorisationAdmin();
39
		}
39
		}
40
 
40
 
41
		$donnees_brutes = $this->getDerniersCommentaires();
41
		$donnees_brutes = $this->getDerniersCommentaires();
42
		$commentaires_formates = $this->formaterPourRss($donnees_brutes) ;
42
		$commentaires_formates = $this->formaterPourRss($donnees_brutes) ;
43
		return $commentaires_formates;
43
		return $commentaires_formates;
44
	}
44
	}
45
 
45
 
46
	private function formaterPourRss($elements) {
46
	private function formaterPourRss($elements) {
47
		$derniere_info_en_date = reset($elements);
47
		$derniere_info_en_date = reset($elements);
48
		$donnees = $this->syndication->construireDonneesCommunesAuFlux('commentaire', $derniere_info_en_date['date']);
48
		$donnees = $this->syndication->construireDonneesCommunesAuFlux('commentaire', $derniere_info_en_date['date']);
49
		foreach ($elements as $element) {
49
		foreach ($elements as $element) {
50
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
50
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
51
		}
51
		}
52
		return $donnees;
52
		return $donnees;
53
	}
53
	}
54
 
54
 
55
	private function construireDonneesCommunesAuxItems($info) {
55
	private function construireDonneesCommunesAuxItems($info) {
56
		$item = array();
56
		$item = array();
57
		$date_modification_timestamp = $this->syndication->convertirDateHeureMysqlEnTimestamp($info['date']);
57
		$date_modification_timestamp = $this->syndication->convertirDateHeureMysqlEnTimestamp($info['date']);
58
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
58
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
59
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
59
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
60
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
60
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
61
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
61
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
62
		$item['titre'] = $this->creerTitre($info);
62
		$item['titre'] = $this->creerTitre($info);
63
		$item['guid'] = $this->creerGuidItem($info);
63
		$item['guid'] = $this->creerGuidItem($info);
64
		$item['lien'] = $this->creerLienItem($info);
64
		$item['lien'] = $this->creerLienItem($info);
65
		$item['categorie'] = htmlentities($this->categorie);
65
		$item['categorie'] = htmlentities($this->categorie);
66
		$item['description'] = $this->creerDescription($info, $item);
66
		$item['description'] = $this->creerDescription($info, $item);
67
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
67
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
68
		$item['modifier_par'] = $this->creerAuteur($info);
68
		$item['modifier_par'] = $this->creerAuteur($info);
69
		return $item;
69
		return $item;
70
	}
70
	}
71
 
71
 
72
	private function creerTitre($element) {
72
	private function creerTitre($element) {
73
		$nomPropose = htmlspecialchars($element['nom_sel']);
73
		$nomPropose = htmlspecialchars($element['nom_sel']);
74
		$intitule = ($element['nom_sel'] != '') ? "Proposition $nomPropose" : 'Commentaire';
74
		$intitule = ($element['nom_sel'] != '') ? "Proposition $nomPropose" : 'Commentaire';
75
		$auteur = htmlspecialchars($this->creerAuteur($element));
75
		$auteur = htmlspecialchars($this->creerAuteur($element));
76
		$nomSelActuel = htmlspecialchars($element['dob_nom_sel']);
76
		$nomSelActuel = htmlspecialchars($element['dob_nom_sel']);
77
		$zoneGeo = htmlspecialchars((($element['dob_zone_geo'] != '') ? $element['dob_zone_geo'] : '?'));
77
		$zoneGeo = htmlspecialchars((($element['dob_zone_geo'] != '') ? $element['dob_zone_geo'] : '?'));
78
		$dateObs = htmlspecialchars(strftime('%d %B %Y', strtotime($element['dob_date_observation'])));
78
		$dateObs = htmlspecialchars(strftime('%d %B %Y', strtotime($element['dob_date_observation'])));
79
 
79
 
80
		$titre = "$intitule par $auteur pour $nomSelActuel à $zoneGeo le $dateObs";
80
		$titre = "$intitule par $auteur pour $nomSelActuel à $zoneGeo le $dateObs";
81
		return $titre;
81
		return $titre;
82
	}
82
	}
83
 
83
 
84
	private function creerAuteur($info) {
84
	private function creerAuteur($info) {
85
		$auteur = 'Anonyme';
85
		$auteur = 'Anonyme';
86
		if ($info['utilisateur_prenom'] != '' && $info['utilisateur_nom'] != '') {
86
		if ($info['utilisateur_prenom'] != '' && $info['utilisateur_nom'] != '') {
87
			$auteur = $info['utilisateur_prenom'].' '.$info['utilisateur_nom'];
87
			$auteur = $info['utilisateur_prenom'].' '.$info['utilisateur_nom'];
88
		}
88
		}
89
		return $auteur;
89
		return $auteur;
90
	}
90
	}
91
 
91
 
92
	private function creerGuidItem($element) {
92
	private function creerGuidItem($element) {
93
		$guid = sprintf($this->conteneur->getParametre('syndication.commentaire_guid_tpl'), $element['id_commentaire']);
93
		$guid = sprintf($this->conteneur->getParametre('syndication.commentaire_guid_tpl'), $element['id_commentaire']);
94
		return $guid;
94
		return $guid;
95
	}
95
	}
96
 
96
 
97
	private function creerLienItem($element) {
97
	private function creerLienItem($element) {
98
		$lien = sprintf($this->conteneur->getParametre('obs_fiche_tpl'), $element['dob_id_observation']);
98
		$lien = sprintf($this->conteneur->getParametre('obs_fiche_tpl'), $element['dob_id_observation']);
99
		return $lien;
99
		return $lien;
100
	}
100
	}
101
 
101
 
102
	private function creerDescription($donnees, $item) {
102
	private function creerDescription($donnees, $item) {
103
		$idCommentaire = $donnees['id_commentaire'];
103
		$idCommentaire = $donnees['id_commentaire'];
104
		$idObs = $donnees['dob_id_observation'];
104
		$idObs = $donnees['dob_id_observation'];
105
		$nomPropose = ($donnees['nom_sel'] != '') ? htmlspecialchars($donnees['nom_sel']) : '';
105
		$nomPropose = ($donnees['nom_sel'] != '') ? htmlspecialchars($donnees['nom_sel']) : '';
106
		$dateCommentaire = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', $this->syndication->convertirDateHeureMysqlEnTimestamp($donnees['date'])));
106
		$dateCommentaire = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', $this->syndication->convertirDateHeureMysqlEnTimestamp($donnees['date'])));
107
		$nomSelActuel = htmlspecialchars($donnees['dob_nom_sel']);
107
		$nomSelActuel = htmlspecialchars($donnees['dob_nom_sel']);
108
		$etreProposition = ($nomPropose != '') ? true : false;
108
		$etreProposition = ($nomPropose != '') ? true : false;
109
		$intitule = ($etreProposition) ? 'Proposition' : 'Commentaire';
109
		$intitule = ($etreProposition) ? 'Proposition' : 'Commentaire';
110
		$txt = ($donnees['texte'] != '') ? htmlspecialchars($donnees['texte']) : '';
110
		$txt = ($donnees['texte'] != '') ? htmlspecialchars($donnees['texte']) : '';
111
		$auteur = htmlspecialchars($this->creerAuteur($donnees)).
111
		$auteur = htmlspecialchars($this->creerAuteur($donnees)).
112
			($this->syndication->fluxAdminDemande() ? ' ('.$donnees['utilisateur_courriel'].')' : '');
112
			($this->syndication->fluxAdminDemande() ? ' ('.$donnees['utilisateur_courriel'].')' : '');
113
		$lieuObs = htmlspecialchars((($donnees['dob_zone_geo'] != '') ? $donnees['dob_zone_geo'] : '?'));
113
		$lieuObs = htmlspecialchars((($donnees['dob_zone_geo'] != '') ? $donnees['dob_zone_geo'] : '?'));
114
		$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['dob_date_observation']));
114
		$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['dob_date_observation']));
115
		$observateur = htmlspecialchars($this->creerObservateur($donnees));
115
		$observateur = htmlspecialchars($this->creerObservateur($donnees));
116
 
116
 
117
		$contenuCommentaire = '';
117
		$contenuCommentaire = '';
118
		if ($etreProposition) {
118
		if ($etreProposition) {
119
			$contenuCommentaire =
119
			$contenuCommentaire =
120
				'<li><span class="champ">'."Nom proposé :</span> <em>$nomPropose</em></li>".
120
				'<li><span class="champ">'."Nom proposé :</span> <em>$nomPropose</em></li>".
121
				((!empty($txt)) ? '<li><span class="champ">'."Argumentaire :</span> $txt</li>" : '').
121
				((!empty($txt)) ? '<li><span class="champ">'."Argumentaire :</span> $txt</li>" : '').
122
				'<li><span class="champ">'."Auteur de la proposition :</span> $auteur</li>".
122
				'<li><span class="champ">'."Auteur de la proposition :</span> $auteur</li>".
123
				'<li><span class="champ">'."Proposé le :</span> $dateCommentaire</li>";
123
				'<li><span class="champ">'."Proposé le :</span> $dateCommentaire</li>";
124
		} else {
124
		} else {
125
			$contenuCommentaire =
125
			$contenuCommentaire =
126
				'<li><span class="champ">'."Commentaire #$idCommentaire :</span> <pre>$txt</pre></li>".
126
				'<li><span class="champ">'."Commentaire #$idCommentaire :</span> <pre>$txt</pre></li>".
127
				'<li><span class="champ">'."Auteur du commentaire :</span> $auteur</li>".
127
				'<li><span class="champ">'."Auteur du commentaire :</span> $auteur</li>".
128
				'<li><span class="champ">'."Commenté le :</span> $dateCommentaire</li>";
128
				'<li><span class="champ">'."Commenté le :</span> $dateCommentaire</li>";
129
		}
129
		}
130
 
130
 
131
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
131
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
132
			'<h2>'."$intitule identiPlante #$idCommentaire pour l'observation #$idObs".'</h2>'.
132
			'<h2>'."$intitule identiPlante #$idCommentaire pour l'observation #$idObs".'</h2>'.
133
			'<div class="gauche">'.
133
			'<div class="gauche">'.
134
			"	<h3>Observation #$idObs</h3>".
134
			"	<h3>Observation #$idObs</h3>".
135
			'	<ul>'.
135
			'	<ul>'.
136
			'		<li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
136
			'		<li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
137
			'		<li><span class="champ">'."Lieu :</span> $lieuObs</li>".
137
			'		<li><span class="champ">'."Lieu :</span> $lieuObs</li>".
138
			'		<li><span class="champ">'."Date :</span> $dateObs</li>".
138
			'		<li><span class="champ">'."Date :</span> $dateObs</li>".
139
			'		<li><span class="champ">'."Auteur :</span> $observateur</li>".
139
			'		<li><span class="champ">'."Auteur :</span> $observateur</li>".
140
			'	</ul>'.
140
			'	</ul>'.
141
			'</div>'.
141
			'</div>'.
142
			'<div class="gauche">'.
142
			'<div class="gauche">'.
143
			"	<h3>$intitule #$idCommentaire</h3>".
143
			"	<h3>$intitule #$idCommentaire</h3>".
144
			"	<ul>$contenuCommentaire</ul>".
144
			"	<ul>$contenuCommentaire</ul>".
145
			'</div>';
145
			'</div>';
146
		return $description;
146
		return $description;
147
	}
147
	}
148
 
148
 
149
	private function creerObservateur($info) {
149
	private function creerObservateur($info) {
150
		$observateur = 'Anonyme';
150
		$observateur = 'Anonyme';
151
		if ($info['observateur_prenom'] != '' && $info['observateur_nom'] != '') {
151
		if ($info['observateur_prenom'] != '' && $info['observateur_nom'] != '') {
152
			$observateur = $info['observateur_prenom'].' '.$info['observateur_nom'];
152
			$observateur = $info['observateur_prenom'].' '.$info['observateur_nom'];
153
		}
153
		}
154
		return $observateur;
154
		return $observateur;
155
	}
155
	}
156
 
156
 
157
	private function getDerniersCommentaires() {
157
	private function getDerniersCommentaires() {
-
 
158
		$commentaires = array();
-
 
159
		$idsCommentaires = $this->getIdsDerniersCommentaires();
-
 
160
		if (!empty($idsCommentaires)) {
-
 
161
			$idsCommentairesconcat = implode(', ', $idsCommentaires);
-
 
162
			$requete = 'SELECT DISTINCT dc.*, '.
-
 
163
				'	dob.id_observation AS dob_id_observation, dob.ce_zone_geo AS dob_ce_zone_geo, '.
-
 
164
				'	dob.zone_geo AS dob_zone_geo, dob.date_observation AS dob_date_observation, dob.nom_sel AS dob_nom_sel, '.
-
 
165
				'	duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, duo.courriel AS observateur_courriel '.
-
 
166
				'FROM del_commentaire AS dc '.
-
 
167
				'	INNER JOIN del_observation AS dob '.
-
 
168
				'		ON dob.id_observation = dc.ce_observation '.
-
 
169
				'	LEFT JOIN del_utilisateur AS duo '.
-
 
170
				'		ON dob.ce_utilisateur = duo.id_utilisateur '.
-
 
171
				"WHERE id_commentaire IN ($idsCommentairesconcat) ".
-
 
172
				'ORDER BY dc.date DESC '.
-
 
173
				'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
-
 
174
				' -- '.__FILE__.' : '.__LINE__;
-
 
175
			$commentaires = $this->bdd->recupererTous($requete);
-
 
176
		}
-
 
177
		return $commentaires;
-
 
178
	}
-
 
179
 
-
 
180
	private function getIdsDerniersCommentaires() {
158
		$clauseWhere = $this->chargerClauseWhere();
181
		$clauseWhere = $this->chargerClauseWhere();
159
		$requete = 'SELECT DISTINCT dc.*, '.
182
		$requete = 'SELECT DISTINCT dc.id_commentaire '.
160
			'	dob.id_observation AS dob_id_observation, dob.ce_zone_geo AS dob_ce_zone_geo, '.
-
 
161
			'	dob.zone_geo AS dob_zone_geo, dob.date_observation AS dob_date_observation, dob.nom_sel AS dob_nom_sel, '.
-
 
162
			'	duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, duo.courriel AS observateur_courriel '.
-
 
163
			'FROM del_commentaire AS dc '.
183
			'FROM del_commentaire AS dc '.
164
			'	INNER JOIN del_observation AS dob '.
-
 
165
			'		ON dob.id_observation = dc.ce_observation '.
184
			'	INNER JOIN del_observation AS dob ON (dc.ce_observation = dob.id_observation) '.
166
			'	LEFT JOIN del_utilisateur AS duo '.
-
 
167
			'		ON dob.ce_utilisateur = duo.id_utilisateur '.
185
			'	LEFT JOIN del_utilisateur AS duo ON (dob.ce_utilisateur = duo.id_utilisateur) '.
168
			'WHERE proposition_initiale != 1 '.
186
			'WHERE proposition_initiale != 1 '.
169
			($clauseWhere != '' ? "AND $clauseWhere " : '').
187
			($clauseWhere != '' ? "AND $clauseWhere " : '').
170
			'ORDER BY dc.date DESC '.
188
			'ORDER BY dc.date DESC '.
171
			'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
189
			'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
172
			' -- '.__FILE__.' : '.__LINE__;
190
			' -- '.__FILE__.' : '.__LINE__;
-
 
191
		//echo $requete;
-
 
192
		$resultats = $this->bdd->recupererTous($requete);
-
 
193
 
173
 
194
		$idsCommentaires = array();
-
 
195
		if ($resultats != false && is_array($resultats)) {
-
 
196
			foreach ($resultats as $infos) {
-
 
197
				$idsCommentaires[] = $infos['id_commentaire'];
-
 
198
			}
174
		$elements = $this->bdd->recupererTous($requete);
199
		}
175
		return $elements;
200
		return $idsCommentaires;
176
	}
201
	}
177
 
202
 
178
	/**
203
	/**
179
	* Charger la clause WHERE en fonction des paramètres de masque
204
	* Charger la clause WHERE en fonction des paramètres de masque
180
	* */
205
	* */
181
	private function chargerClauseWhere() {
206
	private function chargerClauseWhere() {
182
		$where = array();
207
		$where = array();
183
		$filtres = $this->navigation->getFiltre();
208
		$filtres = $this->navigation->getFiltre();
184
		if (!empty($filtres)) {
209
		if (!empty($filtres)) {
185
			$filtrePossibles = $this->conteneur->getParametreTableau('syndication.commentaire_filtres');
210
			$filtrePossibles = $this->conteneur->getParametreTableau('syndication.commentaire_filtres');
186
			foreach ($filtres as $cleFiltre => $valeur) {
211
			foreach ($filtres as $cleFiltre => $valeur) {
187
				if (in_array($cleFiltre, $filtrePossibles)) {
212
				if (in_array($cleFiltre, $filtrePossibles)) {
188
					if (isset($this->mapping[$cleFiltre])) {
213
					if (isset($this->mapping[$cleFiltre])) {
189
						$champ = $this->mapping[$cleFiltre];
214
						$champ = $this->mapping[$cleFiltre];
190
					}
215
					}
191
					switch ($cleFiltre) {
216
					switch ($cleFiltre) {
192
						case 'espece':
217
						case 'espece':
193
							$valeurP = $this->bdd->proteger($valeur.'%');
218
							$valeurP = $this->bdd->proteger($valeur.'%');
194
							$where[] = " dob.$champ LIKE $valeurP OR dc.$champ LIKE $valeurP ";
219
							$where[] = " (dob.$champ LIKE $valeurP OR dc.$champ LIKE $valeurP) ";
195
							break;
220
							break;
196
						case 'auteur':
221
						case 'auteur':
197
							$where[] = $this->creerFiltreAuteur($valeur);
222
							$where[] = $this->creerFiltreAuteur($valeur);
198
							break;
223
							break;
199
						default:
224
						default:
200
							$valeurP = $this->bdd->proteger($valeur);
225
							$valeurP = $this->bdd->proteger($valeur);
201
							$where[] = " $champ = $valeurP ";
226
							$where[] = " $champ = $valeurP ";
202
					}
227
					}
203
				}
228
				}
204
			}
229
			}
205
		}
230
		}
206
		return (!empty($where)) ? implode('AND', $where) : '';
231
		return (!empty($where)) ? implode(' AND ', $where) : '';
207
	}
232
	}
208
 
233
 
209
	private function creerFiltreAuteur($auteurId) {
234
	private function creerFiltreAuteur($auteurId) {
210
		$whereAuteur = '';
235
		$whereAuteur = '';
211
		if (is_numeric($auteurId)) {
236
		if (is_numeric($auteurId)) {
212
			$whereAuteur = " dc.ce_utilisateur = $auteurId ";
237
			$whereAuteur = " dc.ce_utilisateur = $auteurId ";
213
		} else {
238
		} else {
214
			$auteurIdMotif = $this->bdd->proteger($auteurId.'%');
239
			$auteurIdMotif = $this->bdd->proteger($auteurId.'%');
215
 
240
 
216
			if (strpos($auteurId, '@') !== false) {
241
			if (strpos($auteurId, '@') !== false) {
217
				$whereAuteur = " dc.utilisateur_courriel LIKE $auteurIdMotif ";
242
				$whereAuteur = " dc.utilisateur_courriel LIKE $auteurIdMotif ";
218
			} else {
243
			} else {
219
				$tableauNomPrenom = explode(' ', $auteurId, 2);
244
				$tableauNomPrenom = explode(' ', $auteurId, 2);
220
				if (count($tableauNomPrenom) != 2) {
245
				if (count($tableauNomPrenom) == 1) {
221
					$whereAuteur = "(dc.utilisateur_nom LIKE $auteurIdMotif OR dc.utilisateur_prenom LIKE $auteurIdMotif) ";
246
					$whereAuteur = " (dc.utilisateur_nom LIKE $auteurIdMotif OR dc.utilisateur_prenom LIKE $auteurIdMotif) ";
222
				} else {
247
				} else if (count($tableauNomPrenom) == 2) {
223
					// on teste potentiellement un nom prenom ou bien un prénom nom
248
					// on teste potentiellement un nom prenom ou bien un prénom nom
224
					$nomMotif = $this->bdd->proteger($tableauNomPrenom[0].'%');
249
					$nomMotif = $this->bdd->proteger($tableauNomPrenom[0].'%');
225
					$prenomMotif = $this->bdd->proteger($tableauNomPrenom[1].'%');
250
					$prenomMotif = $this->bdd->proteger($tableauNomPrenom[1].'%');
226
 
251
 
227
					$whereAuteur = ' ('.
252
					$whereAuteur = ' ('.
228
						"(dc.utilisateur_nom LIKE $nomMotif AND dc.utilisateur_prenom LIKE $prenomMotif) ".
253
						"(dc.utilisateur_nom LIKE $nomMotif AND dc.utilisateur_prenom LIKE $prenomMotif) ".
229
						'OR '.
254
						'OR '.
230
						"(dc.utilisateur_nom LIKE $nomMotif AND dc.utilisateur_prenom LIKE $prenomMotif) ".
255
						"(dc.utilisateur_nom LIKE $prenomMotif AND dc.utilisateur_prenom LIKE $nomMotif) ".
231
					') ';
256
					') ';
232
				}
257
				}
233
			}
258
			}
234
		}
259
		}
235
		return $whereAuteur;
260
		return $whereAuteur;
236
	}
261
	}
237
}
262
}