| Line 153... |
Line 153... |
| 153 |
}
|
153 |
}
|
| 154 |
return $observateur;
|
154 |
return $observateur;
|
| 155 |
}
|
155 |
}
|
| Line 156... |
Line 156... |
| 156 |
|
156 |
|
| - |
|
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 |
|
| 157 |
private function getDerniersCommentaires() {
|
180 |
private function getIdsDerniersCommentaires() {
|
| 158 |
$clauseWhere = $this->chargerClauseWhere();
|
181 |
$clauseWhere = $this->chargerClauseWhere();
|
| 159 |
$requete = 'SELECT DISTINCT dc.*, '.
|
- |
|
| 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 '.
|
182 |
$requete = 'SELECT DISTINCT dc.id_commentaire '.
|
| 163 |
'FROM del_commentaire AS dc '.
|
- |
|
| 164 |
' INNER JOIN del_observation AS dob '.
|
183 |
'FROM del_commentaire AS dc '.
|
| 165 |
' ON dob.id_observation = dc.ce_observation '.
|
- |
|
| 166 |
' LEFT JOIN del_utilisateur AS duo '.
|
184 |
' INNER JOIN del_observation AS dob ON (dc.ce_observation = dob.id_observation) '.
|
| 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().' '.
|
| - |
|
190 |
' -- '.__FILE__.' : '.__LINE__;
|
| - |
|
191 |
//echo $requete;
|
| Line -... |
Line 192... |
| - |
|
192 |
$resultats = $this->bdd->recupererTous($requete);
|
| 172 |
' -- '.__FILE__.' : '.__LINE__;
|
193 |
|
| - |
|
194 |
$idsCommentaires = array();
|
| - |
|
195 |
if ($resultats != false && is_array($resultats)) {
|
| - |
|
196 |
foreach ($resultats as $infos) {
|
| - |
|
197 |
$idsCommentaires[] = $infos['id_commentaire'];
|
| 173 |
|
198 |
}
|
| 174 |
$elements = $this->bdd->recupererTous($requete);
|
199 |
}
|
| Line 175... |
Line 200... |
| 175 |
return $elements;
|
200 |
return $idsCommentaires;
|
| 176 |
}
|
201 |
}
|
| 177 |
|
202 |
|
| Line 189... |
Line 214... |
| 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:
|
| Line 201... |
Line 226... |
| 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 |
}
|
| Line 208... |
Line 233... |
| 208 |
|
233 |
|
| 209 |
private function creerFiltreAuteur($auteurId) {
|
234 |
private function creerFiltreAuteur($auteurId) {
|
| 210 |
$whereAuteur = '';
|
235 |
$whereAuteur = '';
|
| Line 215... |
Line 240... |
| 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].'%');
|
| Line 225... |
Line 250... |
| 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 |
}
|