public function getLatestComments($nbComment) { $sousRequete1 = "SELECT\n\t\t\t\tdate_format(c.date," . _('"%e/%m/%Y"') . ") as date,\n\t\t\t\t\t\tc.idUtilisateur,\n\t\t\t\t\t\tc.idEvenement,\n\t\t\t\t\t\tc.commentaire,\n\t\t\t\t\t\tc.nom,\n\t\t\t\t\t\tc.prenom,\n\t\t\t\t\t\tha.numero,\n\t\t\t\t\t\tr.prefixe,\n\t\t\t\t\t\tr.nom as nomRue,\n\t\t\t\t\t\t'commentairesEvenement' as typeCommentaire,\n\t\t\t\t\t\t date_format( c.date, '%Y%m%d%H%i%s' ) AS dateTri,\n\t\t\t\t\t\tc.idCommentairesEvenement as idCommentaire\n\t\t\t\t\t\t \n\t\t\t\t\t\tFROM commentairesEvenement c\n\t\t\t\t\t\tLEFT JOIN utilisateur u on u.idUtilisateur = c.idUtilisateur\n\t\t\t\t\t\tLEFT JOIN _evenementEvenement ee on ee.idEvenementAssocie= c.idEvenement\n\t\t\t\t\t\tLEFT JOIN _adresseEvenement ae on ae.idEvenement = ee.idEvenement\n\t\t\t\t\t\tLEFT JOIN historiqueAdresse ha on ha.idAdresse = ae.idAdresse\n\t\t\t\t\t\tLEFT JOIN rue r on r.idRue = ha.idRue\n\t\t\t\t\t\tWHERE c.CommentaireValide =1\n\t\t\t\t\t\tGROUP BY c.idCommentairesEvenement\n\t\t\t\t\t\t"; $sousRequete2 = "SELECT\n\t\t\t\t\t\tdate_format(c.date," . _('"%e/%m/%Y"') . ") as date,\n\t\t\t\t\t\tc.idUtilisateur,\n\t\t\t\t\t\tc.idEvenementGroupeAdresse,\n\t\t\t\t\t\tc.commentaire,\n\t\t\t\t\t\tc.nom,\n\t\t\t\t\t\tc.prenom,\n\t\t\t\t\t\tha.numero,\n\t\t\t\t\t\tr.prefixe,\n\t\t\t\t\t\tr.nom as nomRue,\n\t\t\t\t\t\t'commentaires' as typeCommentaire,\n\t\t\t\t\t\tdate_format( c.date, '%Y%m%d%H%i%s' ) AS dateTri,\n\t\t\t\t\t\tc.idCommentaire as idCommentaire\n\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t\t \n\t\t\t\t\t\tFROM commentaires c\n\t\t\t\t\t\tLEFT JOIN utilisateur u on u.idUtilisateur = c.idUtilisateur\n\t\t\t\t\t\tLEFT JOIN _evenementEvenement ee on ee.idEvenementAssocie= c.idEvenementGroupeAdresse\n\t\t\t\t\t\tLEFT JOIN _adresseEvenement ae on ae.idEvenement = ee.idEvenement\n\t\t\t\t\t\tLEFT JOIN historiqueAdresse ha on ha.idAdresse = ae.idAdresse\n\t\t\t\t\t\tLEFT JOIN rue r on r.idRue = ha.idRue\n\t\t\t\t\t\tWHERE c.CommentaireValide =1\n\t\t\t\t\t\tGROUP BY c.idCommentaire\n\t\t"; $requete = "\n\t\t\t\tSELECT * FROM\n\t\t\t\t(\n\t\t\t\t{$sousRequete1}\n\t\t\t\t\t) as tmp1\n\n\t\t\t\t\tUNION all\n\n\t\t\t\t\tSELECT * FROM (\n\t\t\t\t\t{$sousRequete2}\n\t\t\t\t\t)\n\t\t\t\t\tAS tmp2\n\t\t\t\t\tORDER BY dateTri desc\n\t\t\t\t\tLIMIT {$nbComment}\n\t\t\t\t\t"; $result = $this->connexionBdd->requete($requete); $arrayComment = array(); $e = new archiEvenement(); while ($latestComment = mysql_fetch_assoc($result)) { $idEvenement = ""; $idEvenementGroup = ""; $idAdresse = ""; $ancre = "#commentaire"; if ($latestComment['typeCommentaire'] == 'commentairesEvenement') { $idEvenement = $latestComment['idEvenement']; $idEvenementGroup = $e->getIdGroupeEvenement($latestComment['idEvenement']); if ($idPersonne = archiPersonne::isPerson($idEvenementGroup)) { $nom = ArchiPersonne::getName($idPersonne); $adresse = $nom->nom . " " . $nom->prenom; $url = $this->creerUrl('', '', array('archiAffichage' => 'evenementListe', 'selection' => "personne", 'id' => $idPersonne)); } else { $idAdresse = $e->getIdAdresse($latestComment['idEvenement']); } $ancre .= "Evenement" . $latestComment['idCommentaire']; } else { $idEvenementGroup = $latestComment['idEvenement']; $reqIdEvt = "\n\t\t\t\tSELECT idEvenementAssocie as idEvenement\n\t\t\t\tFROM _evenementEvenement\n\t\t\t\tWHERE idEvenement = {$idEvenementGroup}\n\t\t\t\t"; $resIdEvt = $this->connexionBdd->requete($reqIdEvt); $tmp = mysql_fetch_array($resIdEvt); $idEvenement = $tmp['idEvenement']; $idAdresse = $e->getIdAdresse($idEvenement); $ancre .= "Adresse" . $latestComment['idCommentaire']; } if (!archiPersonne::isPerson($idEvenementGroup)) { $adresseArray = $e->getArrayAdresse($idEvenement); //Adresse $adresse = ''; $adresse = $e->getAddressText($adresseArray); $url = $this->creerUrl('', '', array('archiAffichage' => 'adresseDetail', "archiIdAdresse" => $idAdresse, "archiIdEvenementGroupeAdresse" => $idEvenementGroup)); } $so = new StringObject(); $test = $so->replaceUrl($latestComment['commentaire']); $bbCode = new bbCodeObject(); $commentaireText = $bbCode->stripBBCode($latestComment['commentaire']); $latestComment['commentaire'] = $so->truncateStringToWord($commentaireText, 80, ' ', '...'); $urlPersonne = $this->creerUrl('', 'detailProfilPublique', array('archiIdUtilisateur' => $latestComment['idUtilisateur'], 'archiIdEvenementGroupeAdresseOrigine' => $idEvenementGroup)); $latestComment['typeCommentaire'] = 'commentaireEvenement'; $latestComment['urlAdresse'] = $url . $ancre; $latestComment['urlPersonne'] = $urlPersonne; $latestComment['adresse'] = $adresse; $arrayComment[] = $latestComment; } return $arrayComment; }