Ejemplo n.º 1
0
    $t->assign_block_vars('linkConnected', array('authLinkOneClass' => 'authLinkTwoClass subscribeLabel', 'authLinkUrl' => $config->creerUrl('', 'inscription'), 'authLinkLabel' => 'Inscrivez-vous !'));
} else {
    if ($authentification->estAdmin()) {
        $t->assign_block_vars('isAdmin', array());
    }
    // utilisateur connecté
    $classFastConnect = "hidden";
    $userId = $authentification->getIdUtilisateur();
    $imgConnexion = $utilisateur->getImageAvatar(array('idUtilisateur' => $userId, 'default' => "images/logo_connexion.png"));
    $reqTitre = "SELECT prenom, nom FROM utilisateur WHERE idUtilisateur = {$userId}";
    $res = $config->connexionBdd->requete($reqTitre);
    $arrayUser = mysql_fetch_assoc($res);
    $labelConnexion = $arrayUser['prenom'] . " " . $arrayUser['nom'];
    $t->assign_block_vars('utilisateurConnecte', array());
    $t->assign_vars(array('inscriptionDeconnexion' => _("Déconnexion"), 'formulaireRecherche' => $recherche->afficheFormulaire(array(), 0, array('noDisplayRechercheAvancee' => false, 'noDisplayCheckBoxResultatsCarte' => false)), 'urlInscriptDeconnexion' => $config->creerUrl('deconnexion', 'authentification'), 'urlAccueil' => $config->creerUrl('', 'afficheAccueil'), 'txtAccueil' => _("Accueil"), 'urlMonArchi' => $config->creerUrl('', 'afficheAccueil', array('modeAffichage' => 'monArchi')), 'txtMonArchi' => _("Mon Archi"), 'authLinkOneUrl' => $config->creerUrl('', 'afficheAccueil', array('modeAffichage' => 'profil')), 'classAuthLinkWrapper' => 'connectedAuthLink', 'classFastConnect' => $classFastConnect));
    if ($utilisateur->getIdProfil($userId) >= 4) {
        $t->assign_block_vars('linkConnected', array('authLinkOneClass' => 'authLinkTwoClass subscribeLabel', 'authLinkUrl' => $config->creerUrl('', 'utilisateurListe'), 'authLinkLabel' => _("Utilisateurs")));
    }
    if ($utilisateur->getIdProfil($userId) >= 3) {
        $t->assign_block_vars('linkConnected', array('authLinkOneClass' => 'authLinkTwoClass subscribeLabel', 'authLinkUrl' => $config->creerUrl('', 'administration'), 'authLinkLabel' => _("Administration")));
    }
    $t->assign_block_vars('linkConnected', array('authLinkOneClass' => ' authLinkOneClass forgetPasswordLabel', 'authLinkUrl' => $config->creerUrl('', 'afficheAccueil', array('modeAffichage' => 'profil')), 'authLinkLabel' => _("Mon Profil")));
    $t->assign_block_vars('linkConnected', array('authLinkOneClass' => ' authLinkOneClass forgetPasswordLabel', 'authLinkUrl' => $config->creerUrl('', 'afficheAccueil', array('modeAffichage' => 'monArchi')), 'authLinkLabel' => _("Mon Archi")));
    $t->assign_block_vars('linkConnected', array('authLinkOneClass' => 'authLinkTwoClass subscribeLabel', 'authLinkUrl' => $config->creerUrl('deconnexion', 'authentification'), 'authLinkLabel' => _("Déconnexion")));
    if ($utilisateur->isAuthorized('affiche_menu_admin', $authentification->getIdUtilisateur())) {
        $t->assign_block_vars('afficheAdministrationMenu', array());
    }
}
$t->assign_vars(array("labelConnexion" => $labelConnexion, 'imageConnexion' => $imgConnexion, 'urlFr' => $config->creerUrl('', '', array_merge($_GET, array('lang' => fr_FR))), 'urlEn' => $config->creerUrl('', '', array_merge($_GET, array('lang' => en_US))), 'urlDe' => $config->creerUrl('', '', array_merge($_GET, array('lang' => de_DE)))));
if ($adresse->isParcoursActif()) {
    $t->assign_block_vars('isParcours', array());
 public function getGoogleMapIframe($params = array())
 {
     $html = '<link href="css/default.css" rel="stylesheet" type="text/css" />
 ';
     if (isset($this->variablesGet['longitude']) && $this->variablesGet['longitude'] != '' && isset($this->variablesGet['latitude']) && $this->variablesGet['latitude'] != '') {
         $ajax = new ajaxObject();
         $html .= $ajax->getAjaxFunctions();
         $longitude = $this->variablesGet['longitude'];
         $latitude = $this->variablesGet['latitude'];
         $listeCoords = array();
         // si archiIdAdresse est précisé , on remplace les coordonnées par celle de l'adresse ( car celle envoyée sont celle de la premiere du groupe d'adresse)
         $isCoordonneesAdresseCouranteValide = true;
         $isCoordonneesGroupeAdresseOK = false;
         if (isset($this->variablesGet['archiIdAdresse']) && $this->variablesGet['archiIdAdresse'] != '' && isset($this->variablesGet['archiIdEvenementGroupeAdresse']) && $this->variablesGet['archiIdEvenementGroupeAdresse'] != '') {
             // s'il existe des coordonnées pour le groupe d'adresse dans la table _adresseEvenement, on prend celles ci
             $reqCoordonneesGroupeAdresse = "SELECT longitudeGroupeAdresse,latitudeGroupeAdresse FROM _adresseEvenement WHERE idAdresse='" . $this->variablesGet['archiIdAdresse'] . "' AND idEvenement='" . $this->variablesGet['archiIdEvenementGroupeAdresse'] . "' AND longitudeGroupeAdresse<>'0' AND latitudeGroupeAdresse<>'0'";
             $resCoordonneesGroupeAdresse = $this->connexionBdd->requete($reqCoordonneesGroupeAdresse);
             if (mysql_num_rows($resCoordonneesGroupeAdresse) > 0) {
                 $fetchCoordonneesGroupeAdresse = mysql_fetch_assoc($resCoordonneesGroupeAdresse);
                 $longitude = $fetchCoordonneesGroupeAdresse['longitudeGroupeAdresse'];
                 $latitude = $fetchCoordonneesGroupeAdresse['latitudeGroupeAdresse'];
                 $isCoordonneesGroupeAdresseOK = true;
             }
         }
         if (isset($this->variablesGet['archiIdAdresse']) && $this->variablesGet['archiIdAdresse'] != '' && $this->variablesGet['archiIdAdresse'] != '0' && !$isCoordonneesGroupeAdresseOK) {
             $reqCoordonnees = "\n                    SELECT ha1.longitude as longitude, ha1.latitude as latitude\n                    FROM historiqueAdresse ha2, historiqueAdresse ha1\n                    WHERE ha2.idAdresse = ha1.idAdresse\n                    AND ha1.idAdresse = '" . $this->variablesGet['archiIdAdresse'] . "'\n                    GROUP BY ha1.idAdresse, ha1.idHistoriqueAdresse\n                    HAVING ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)\n                ";
             $resCoordonnees = $this->connexionBdd->requete($reqCoordonnees);
             if (mysql_num_rows($resCoordonnees) == 1) {
                 $fetchCoordonnees = mysql_fetch_assoc($resCoordonnees);
                 if ($fetchCoordonnees['longitude'] != '' && $fetchCoordonnees['latitude'] != '' && $fetchCoordonnees['longitude'] != '0' && $fetchCoordonnees['latitude'] != '0') {
                     $longitude = $fetchCoordonnees['longitude'];
                     $latitude = $fetchCoordonnees['latitude'];
                 } else {
                     $isCoordonneesAdresseCouranteValide = false;
                 }
             }
         }
         $affichageCoordonneesVille = false;
         if ($longitude < 0 || $latitude < 0 || $longitude == 0 || $latitude == 0 || !$isCoordonneesAdresseCouranteValide) {
             // on detection une longitude ou latitude negative : il doit y avoir eu une erreur de detection des parametres
             // on va centrer la carte sur la ville
             if (isset($this->variablesGet['archiIdAdresse']) && $this->variablesGet['archiIdAdresse'] != '' && $this->variablesGet['archiIdAdresse'] != '0') {
                 // recuperation de l'idville de l'adresse courante
                 $idVille = $this->getIdVilleFrom($this->variablesGet['archiIdAdresse'], 'idAdresse');
                 // coordonnees de la ville
                 $reqCoordonneesVille = "SELECT longitude,latitude,nom FROM ville WHERE idVille = '" . $idVille . "'";
                 $resCoordonneesVille = $this->connexionBdd->requete($reqCoordonneesVille);
                 $fetchCoordonneesVille = mysql_fetch_assoc($resCoordonneesVille);
                 $longitude = $fetchCoordonneesVille['longitude'];
                 $latitude = $fetchCoordonneesVille['latitude'];
                 $affichageCoordonneesVille = true;
             }
         }
         // rayon en metres
         if (isset($this->variablesGet['modeAffichage']) && $this->variablesGet['modeAffichage'] == 'popupDetailAdresse') {
             // dans le cas de l'affichage de la popup sur le detail de l'adresse on prend un rayon plus grand, donc plus d'adresses affichées
             $rayon = 200;
         } else {
             $rayon = 200;
         }
         $arrayGoogleMapCoord = $this->getArrayGoogleMapConfigCoordonneesFromCenter(array('longitude' => $longitude, 'latitude' => $latitude, 'rayon' => $rayon));
         $listeCoords = $arrayGoogleMapCoord['arrayConfigCoordonnees'];
         // verification des droits
         $isAuthorizedToDrag = false;
         $widthGoogleMapModePopup = 650;
         if (isset($this->variablesGet['modeAffichage']) && $this->variablesGet['modeAffichage'] == 'popupDetailAdresse') {
             if (isset($this->variablesGet['archiIdAdresse']) && $this->variablesGet['archiIdAdresse'] != '' && isset($this->variablesGet['archiIdEvenementGroupeAdresse']) && $this->variablesGet['archiIdEvenementGroupeAdresse'] != '') {
                 $idAdresseCentree = $this->variablesGet['archiIdAdresse'];
                 $idEvenementGroupeAdresseCentre = $this->variablesGet['archiIdEvenementGroupeAdresse'];
                 $utilisateur = new archiUtilisateur();
                 $authentification = new archiAuthentification();
                 // verification des droits
                 if ($utilisateur->isAuthorized('googlemap_change_coordonnees', $authentification->getIdUtilisateur())) {
                     if ($utilisateur->getIdProfil($authentification->getIdUtilisateur()) == 4 || $utilisateur->getIdProfil($authentification->getIdUtilisateur()) == 3 && $utilisateur->isModerateurFromVille($authentification->getIdUtilisateur(), $idAdresseCentree, 'idAdresse')) {
                         $isAuthorizedToDrag = true;
                         $widthGoogleMapModePopup = 650;
                     }
                 }
             }
         }
         if (isset($this->variablesGet['modeAffichage']) && $this->variablesGet['modeAffichage'] == 'popupDetailAdresse') {
             // affichage pour la popup sur le detail d'une adresse
             if ($affichageCoordonneesVille) {
                 $gm = new googleMap(array('googleMapKey' => $this->googleMapKey, 'width' => $widthGoogleMapModePopup, 'height' => 500, 'zoom' => 11, 'noDisplayZoomSelectionSquare' => true, 'noDisplayZoomSlider' => false, 'zoomType' => 'mini', 'noDisplayEchelle' => true, 'noDisplayMapTypeButtons' => false, 'centerLong' => $longitude, 'centerLat' => $latitude, 'mapType' => 'G_SATELLITE_MAP'));
             } else {
                 $gm = new googleMap(array('googleMapKey' => $this->googleMapKey, 'width' => $widthGoogleMapModePopup, 'height' => 500, 'zoom' => 17, 'noDisplayZoomSelectionSquare' => true, 'noDisplayZoomSlider' => false, 'zoomType' => 'mini', 'noDisplayEchelle' => true, 'noDisplayMapTypeButtons' => false, 'centerLong' => $longitude, 'centerLat' => $latitude, 'mapType' => 'G_SATELLITE_MAP'));
             }
         } else {
             if ($affichageCoordonneesVille) {
                 $gm = new googleMap(array('googleMapKey' => $this->googleMapKey, 'width' => 275, 'height' => 275, 'zoom' => 10, 'noDisplayZoomSelectionSquare' => true, 'noDisplayZoomSlider' => false, 'zoomType' => 'mini', 'noDisplayEchelle' => true, 'noDisplayMapTypeButtons' => true, 'centerLong' => $longitude, 'centerLat' => $latitude, 'mapType' => 'G_SATELLITE_MAP'));
             } else {
                 // affichage par defaut , s'affichage en haut de la page detail d'une adresse , a gauche de l'encars
                 $gm = new googleMap(array('googleMapKey' => $this->googleMapKey, 'width' => 275, 'height' => 275, 'zoom' => 16, 'noDisplayZoomSelectionSquare' => true, 'noDisplayZoomSlider' => false, 'zoomType' => 'mini', 'noDisplayEchelle' => true, 'noDisplayMapTypeButtons' => true, 'centerLong' => $longitude, 'centerLat' => $latitude, 'mapType' => 'G_SATELLITE_MAP'));
                 //,'divStyle'=>'margin-top:-17px;'
             }
         }
         $html .= $gm->getJsFunctions();
         //$html.="<script  >".$gm->setFunctionAddPointsCallableFromChild()."</script>";
         $html .= $gm->getMap(array('listeCoordonnees' => $listeCoords, 'urlImageIcon' => $this->getUrlImage() . "pointGM.png", 'pathImageIcon' => $this->getCheminPhysique() . "images/pointGM.png"));
         // on ajoute le markeur central a la main
         $html .= "<script  >\n                var iconHome = new GIcon();\n                iconHome.image = \"" . $this->getUrlImage() . "placeMarker.png\";\n                //iconHome.shadow = \"https://labs.google.com/ridefinder/images/mm_20_shadow.png\";\n                iconHome.iconSize = new GSize(19, 32);\n                iconHome.shadowSize = new GSize(22, 20);\n                iconHome.iconAnchor = new GPoint(5, 26);\n                iconHome.infoWindowAnchor = new GPoint(5, 1);\n\n                //var iconMarkerHome = new GIcon(iconHome);\n                ";
         if (isset($this->variablesGet['modeAffichage']) && $this->variablesGet['modeAffichage'] == 'popupDetailAdresse' && $isAuthorizedToDrag) {
             $html .= "markerHome = new GMarker(new GLatLng(" . $latitude . "," . $longitude . "),{icon:iconHome, draggable: true});";
         } else {
             $html .= "markerHome = new GMarker(new GLatLng(" . $latitude . "," . $longitude . "),{icon:iconHome});";
         }
         $html .= "map.addOverlay(markerHome);";
         if (isset($this->variablesGet['modeAffichage']) && $this->variablesGet['modeAffichage'] == 'popupDetailAdresse' && $isAuthorizedToDrag) {
             $html .= "markerHome.enableDragging();";
         }
         if (isset($this->variablesGet['modeAffichage']) && $this->variablesGet['modeAffichage'] == 'popupDetailAdresse' && $isAuthorizedToDrag) {
             $html .= "GEvent.addListener(markerHome,'drag',function(){parent.window.document.getElementById('latitudeUser').value=markerHome.getPoint().lat();parent.window.document.getElementById('longitudeUser').value=markerHome.getPoint().lng();parent.window.document.getElementById('validationCoordonnees').style.display='';});\n                ";
             $html .= "GEvent.addListener(\n                            map,\n                            'dragend',\n                            function(){appelAjaxReturnJs('" . html_entity_decode($this->creerUrl('', 'majGoogleMapNewCenter', array('noRefresh' => 1, 'noHTMLHeaderFooter' => 1, 'noHeaderNoFooter' => 1, 'latitudeHome' => $latitude, 'longitudeHome' => $longitude))) . "&longitudeCenter='+map.getCenter().lng()+'&latitudeCenter='+map.getCenter().lat(),'divListeAdressesAjax')}\n                            );";
         } else {
             $html .= "GEvent.addListener(\n                            map,\n                            'dragend',\n                            function(){appelAjaxReturnJs('" . html_entity_decode($this->creerUrl('', 'majGoogleMapNewCenter', array('noHTMLHeaderFooter' => 1, 'noHeaderNoFooter' => 1, 'latitudeHome' => $latitude, 'longitudeHome' => $longitude))) . "&longitudeCenter='+map.getCenter().lng()+'&latitudeCenter='+map.getCenter().lat(),'divListeAdressesAjax')}\n                            );";
             //$html.="GEvent.addListener(map,'dragend',function(){document.getElementById('iFrameMajCenter').src='".$this->creerUrl('','majGoogleMapNewCenter',array('noHeaderNoFooter'=>1,'latitudeHome'=>$latitude,'longitudeHome'=>$longitude))."&longitudeCenter='+map.getCenter().lng()+'&latitudeCenter='+map.getCenter().lat();});";
         }
         //$html.=$gm->setFunctionAddPointsCallableFromChild(array());
         $html .= "</script>";
         //$html.="<div id='jsMiseAJourCenter' ><iframe id='iFrameMajCenter' src=''></iframe></div>";//style='position:absolute;left:0px;top:0px;'
     }
     return $html;
 }
 /**
  * Est ce que l'utilisateur est moderateur ?
  * ATTENTION : cette fonction ne précise pas si l'utilisateur est moderateur pour une ville,
  * donc il faudra encore faire la verif de la ville
  * 
  * @param array $params Paramètres
  * Si pas de parametre, on verifie l'utilisateur connecté courant
  * 
  * @return bool
  * */
 public function estModerateur($params = array())
 {
     $retour = false;
     $utilisateur = new archiUtilisateur();
     if (isset($params['idUtilisateur']) && $params['idUtilisateur'] != '' || $this->estConnecte()) {
         if (isset($params['idUtilisateur']) && $params['idUtilisateur'] != '' && $utilisateur->getIdProfil($params['idUtilisateur']) == '3') {
             $retour = true;
         } elseif ($utilisateur->getIdProfil($this->session->getFromSession('utilisateurConnecte' . $this->idSite)) == '3') {
             $retour = true;
         }
     }
     return $retour;
 }
    /**
     * Display html details of a single event
     *
     * @param unknown $idEvenement : id of the event to display
     * @return string : html of the detail event
     */
    public function getEventInfos($idEvenement, $params = array())
    {
        $authentification = new archiAuthentification();
        $evenements = array();
        /*
         * Data processing
         */
        $requete = 'SELECT

				hE.idEvenement,
				hE.titre,
				hE.idSource,
				hE.idTypeStructure,
				hE.idTypeEvenement,
				hE.description,
				hE.dateDebut,
				hE.dateFin,
				hE.dateDebut,
				hE.dateFin,
				tE.nom AS nomTypeEvenement,
				tS.nom AS nomTypeStructure,
				s.nom AS nomSource,
				u.nom AS nomUtilisateur,
				u.prenom as prenomUtilisateur,
				tE.groupe,
				hE.ISMH ,
				hE.MH,
				date_format(hE.dateCreationEvenement,"' . _("%e/%m/%Y à %kh%i") . '") as dateCreationEvenement,
				hE.isDateDebutEnviron as isDateDebutEnviron,
				u.idUtilisateur as idUtilisateur,
				hE.numeroArchive as numeroArchive,
				ae.idAdresse,
				ha.idVille,
				ee.idEvenement as idEvenementGroupeAdresse

				FROM evenements hE
				LEFT JOIN source s      ON s.idSource = hE.idSource
				LEFT JOIN typeStructure tS  ON tS.idTypeStructure = hE.idTypeStructure
				LEFT JOIN typeEvenement tE  ON tE.idTypeEvenement = hE.idTypeEvenement
				LEFT JOIN utilisateur u     ON u.idUtilisateur = hE.idUtilisateur

				LEFT JOIN _evenementEvenement ee on ee.idEvenementAssocie =' . $idEvenement . '
				LEFT JOIN _adresseEvenement ae on ae.idEvenement = ee.idEvenement
				LEFT JOIN historiqueAdresse ha on ha.idAdresse= ae.idAdresse

				WHERE hE.idEvenement=' . $idEvenement . '
				ORDER BY hE.idEvenement DESC
				LIMIT 1';
        if ($params['type'] == 'historique') {
            $requete = 'SELECT

				hE.idEvenement,
				hE.titre,
				hE.idSource,
				hE.idTypeStructure,
				hE.idTypeEvenement,
				hE.description,
				hE.dateDebut,
				hE.dateFin,
				hE.dateDebut,
				hE.dateFin,
				tE.nom AS nomTypeEvenement,
				tS.nom AS nomTypeStructure,
				s.nom AS nomSource,
				s.description as descriptionSource,
				u.nom AS nomUtilisateur,
				u.prenom as prenomUtilisateur,
				tE.groupe,
				hE.ISMH ,
				hE.MH,
				date_format(hE.dateCreationEvenement,"' . _("%e/%m/%Y à %kh%i") . '") as dateCreationEvenement,
				hE.isDateDebutEnviron as isDateDebutEnviron,
				u.idUtilisateur as idUtilisateur,
				hE.numeroArchive as numeroArchive,
				ae.idAdresse,
				ha.idVille,
				ee.idEvenement as idEvenementGroupeAdresse

				FROM historiqueEvenement hE
				LEFT JOIN source s      ON s.idSource = hE.idSource
				LEFT JOIN typeStructure tS  ON tS.idTypeStructure = hE.idTypeStructure
				LEFT JOIN typeEvenement tE  ON tE.idTypeEvenement = hE.idTypeEvenement
				LEFT JOIN utilisateur u     ON u.idUtilisateur = hE.idUtilisateur

				LEFT JOIN _evenementEvenement ee on ee.idEvenementAssocie = hE.idEvenement
				LEFT JOIN _adresseEvenement ae on ae.idEvenement = ee.idEvenement
				LEFT JOIN historiqueAdresse ha on ha.idAdresse= ae.idAdresse

				WHERE hE.idHistoriqueEvenement=' . $idEvenement . '
				ORDER BY hE.idHistoriqueEvenement DESC';
        }
        $result = $this->connexionBdd->requete($requete);
        $fetch = mysql_fetch_assoc($result);
        $idEvenementGroupeAdresse = $fetch['idEvenementGroupeAdresse'];
        //History processing
        $requeteHistory = "SELECT idHistoriqueEvenement from historiqueEvenement where idEvenement = " . $idEvenement;
        $resultHistory = $this->connexionBdd->requete($requeteHistory);
        if (mysql_num_rows($resultHistory) > 1) {
            $txtEnvoi = "modifié";
        } else {
            $txtEnvoi = "envoyé";
        }
        $lienHistoriqueEvenementCourant = $this->creerUrl('', 'consultationHistoriqueEvenement', array('archiIdEvenement' => $idEvenement));
        $labelHistoriqueEvenement = '(Consulter l\'historique)';
        //Image processing
        $images = new archiImage();
        $arrayImagesVuesSurByDate = array();
        $imagesHTML = $images->afficherFromEvenement($idEvenement, array('withoutImagesVuesSurPrisesDepuis' => true, 'imagesVuesSurLinkedByDate' => $arrayImagesVuesSurByDate, 'idGroupeAdresseEvenementAffiche' => $idEvenementGroupeAdresse));
        if ($params['type'] == 'historique') {
            $req = "\n\t\t\t\t\t\t\t\tSELECT e.dateDebut, ae1.idAdresse\n\t\t\t\t\t\t\t\tFROM _adresseEvenement ae1,_adresseEvenement ae2\n\t\t\t\t\t\t\t\tLEFT JOIN historiqueEvenement e on e.idEvenement= ae2.idEvenement\n\t\t\t\t\t\t\t\tWHERE ae1.idAdresse= ae2.idAdresse\n\t\t\t\t\t\t\t\tAND e.idHistoriqueEvenement =" . $idEvenement . "\n\t\t\t\t\t\t\t\t\t\tORDER BY e.idEvenement DESC LIMIT 1\n\t\t\t\t\t\t\t\t\t";
        } else {
            $req = "\n\t\t\t\t\t\t\t\tSELECT e.dateDebut, ae1.idAdresse\n\t\t\t\t\t\t\t\tFROM _adresseEvenement ae1,_adresseEvenement ae2\n\t\t\t\t\t\t\t\tLEFT JOIN evenements e on e.idEvenement= ae2.idEvenement\n\t\t\t\t\t\t\t\tWHERE ae1.idAdresse= ae2.idAdresse\n\t\t\t\t\t\t\t\tAND ae1.idEvenement =" . $idEvenement . "\n\t\t\t\t\t\t\t\t\t\tORDER BY e.idEvenement DESC LIMIT 1\n\t\t\t\t\t\t\t\t\t";
        }
        $res = $this->connexionBdd->requete($req);
        $date2 = mysql_fetch_object($res);
        $idAdresse = $fetch['idAdresse'];
        $linkedEventsHTML = archiPersonne::displayEvenementsLies($idPerson, $dateDebut, $date2->dateDebut);
        //Personne processing
        if ($params['type'] == 'historique') {
            $rep = $this->connexionBdd->requete('
						SELECT  p.idPersonne, m.nom as metier, p.nom, p.prenom
						FROM _evenementPersonne _eP
						LEFT JOIN personne p ON p.idPersonne = _eP.idPersonne
						LEFT JOIN metier m ON m.idMetier = p.idMetier
						LEFT JOIN historiqueEvenement he on he.idEvenement = _eP.idEvenement
						WHERE he.idHistoriqueEvenement=' . $idEvenement . '
						ORDER BY p.nom DESC');
        } else {
            $rep = $this->connexionBdd->requete('
						SELECT  p.idPersonne, m.nom as metier, p.nom, p.prenom
						FROM _evenementPersonne _eP
						LEFT JOIN personne p ON p.idPersonne = _eP.idPersonne
						LEFT JOIN metier m ON m.idMetier = p.idMetier
						WHERE _eP.idEvenement=' . $idEvenement . '
						ORDER BY p.nom DESC');
        }
        $metier = "";
        $arrayPersonne = array();
        while ($res = mysql_fetch_object($rep)) {
            $personne = array();
            if (isset($res->metier) && $res->metier != '') {
                $metier = $res->metier . ' : ';
            }
            $arrayPersonne[] = array('evenement.pers', array('urlDetail' => $this->creerUrl('', 'personne', array('idPersonne' => $res->idPersonne)), 'urlEvenement' => $this->creerUrl('', 'evenementListe', array('selection' => 'personne', 'id' => $res->idPersonne)), 'nom' => ucfirst(stripslashes($res->nom)), 'prenom' => ucfirst(stripslashes($res->prenom)), 'metier' => ucfirst(stripslashes($metier)), 'idPerson' => $res->idPersonne, 'idEvent' => $idEvenement));
        }
        /*
         *  COURANTS ARCHI
         */
        $rep = $this->connexionBdd->requete('
						SELECT  cA.idCourantArchitectural, cA.nom
						FROM _evenementCourantArchitectural _eA
						LEFT JOIN courantArchitectural cA  ON cA.idCourantArchitectural  = _eA.idCourantArchitectural
						WHERE _eA.idEvenement=' . $idEvenement . '
						ORDER BY cA.nom ASC');
        $arrayCourantArchi = array();
        if (mysql_num_rows($rep) > 0) {
            $arrayCourantArchi[] = array('evenement.isCourantArchi', array());
            while ($res = mysql_fetch_object($rep)) {
                $arrayCourantArchi[] = array('evenement.isCourantArchi.archi', array('url' => $this->creerUrl('', 'evenementListe', array('selection' => 'courant', 'id' => $res->idCourantArchitectural)), 'nom' => $res->nom));
            }
        }
        //Commentaires
        $formulaireCommentaire = $this->getFormComment($idEvenement, $this->getCommentairesFields('evenement'), 'evenement');
        $listeCommentaires = $this->getListCommentairesEvenements($idEvenement);
        //Adresses liees processing
        $adressesLieesHTML = $this->getAdressesLieesAEvenement(array('modeRetour' => 'affichageSurDetailEvenement', 'idEvenement' => $idEvenementGroupeAdresse));
        if ($adressesLieesHTML != '') {
            $adressesLieesHTML = "<b>" . _("Liste des adresses liées :") . "</b> <br>" . $adressesLieesHTML;
        }
        //Date processing
        $dateTxt = $this->getDateAsString($fetch);
        if (!empty($fetch['description']) && $fetch['description'] != '') {
            //Description processing : BBCode parsing
            $bbCode = new bbCodeObject();
            $description = $bbCode->convertToDisplay(array('text' => $fetch['description'], 'idEvenement' => $idEvenement));
            $description = empty($description) ? "" : "<div itemprop='description' class='desc'>" . $description . "</div>";
        }
        //User
        $idUtilisateur = $fetch['idUtilisateur'];
        $utilisateur = "<a href='" . $this->creerUrl('', 'detailProfilPublique', array('archiIdUtilisateur' => $idUtilisateur, 'archiIdEvenementGroupeAdresseOrigine' => $idEvenementGroupeAdresse)) . "'>" . $fetch['prenomUtilisateur'] . " " . $fetch['nomUtilisateur'] . "</a>";
        //Event type
        $urlTypeEvenement = $this->creerUrl('', 'evenementListe', array('selection' => 'typeEvenement', 'id' => $fetch['idTypeEvenement']));
        $nomTypeEvenement = $fetch['nomTypeEvenement'];
        $lienTypeEvenement = "<a href={$urlTypeEvenement}>{$nomTypeEvenement}</a>";
        //Structure type
        $urlTypeStructure = $this->creerUrl('', 'listeStructure', array('idTypeStructure' => $fetch['idTypeStructure']));
        $nomTypeStructure = $fetch['nomTypeStructure'];
        $typeStructure = "<a href=\"{$urlTypeStructure}\">{$nomTypeStructure}</a> ";
        //Source
        $source = "";
        if (isset($fetch['nomSource']) && $fetch['nomSource'] != '') {
            $source = "Source : <a href='" . $this->creerUrl('', 'listeAdressesFromSource', array('source' => $fetch['idSource'], 'submit' => 'Rechercher')) . "' onmouseover=\"document.getElementById('calqueDescriptionSource').style.top=(getScrollHeight()+150)+'px';\n\t\t\t\t\t\t\tdocument.getElementById('calqueDescriptionSource').style.display='block';\n\t\t\t\t\t\t\tdocument.getElementById('iframe').src='" . $this->creerUrl('', 'descriptionSource', array('archiIdSource' => $fetch['idSource'], 'noHeaderNoFooter' => 1)) . "';\"\n\t\t\t\t\t\t\t\t\t>" . stripslashes($fetch['nomSource']) . "\n\t\t\t\t\t</a><br>";
        }
        //Info used for menu display
        $cityId = $fetch['idVille'];
        $isModerateur = true;
        $isAdmin = true;
        $u = new archiUtilisateur();
        $userId = $authentification->getIdUtilisateur();
        $urlProfilPic = $u->getImageAvatar(array('idUtilisateur' => $idUtilisateur));
        $isModerateur = $u->isModerateurFromVille($userId, $cityId, 'idVille');
        $isAdmin = $u->getIdProfil($userId) == '4';
        $urlMenuAction = array('ajouterImage' => $this->creerUrl('', 'ajoutImageEvenement', array('archiIdEvenement' => $idEvenement)), 'modifierImage' => $this->creerUrl('', 'modifierImageEvenement', array('archiIdEvenement' => $idEvenement)), 'modifierEvenement' => $this->creerUrl('', 'modifierEvenement', array('archiIdEvenement' => $idEvenement, 'archiIdEvenementGroupeAdresse' => $fetch['idEvenementGroupeAdresse'], 'archiIdAdresse' => $fetch['idAdresse'])), 'supprimerEvenement' => $this->creerUrl('supprimerEvenement', '', array('archiIdEvenement' => $idEvenement)), 'urlImporterImage' => "#", 'onClickImporterImage' => "document.getElementById('formulaireEvenement').action='" . $this->creerUrl('deplacerImagesSelectionnees', 'evenement', array('idEvenement' => $idEvenement)) . "&deplacerVersIdEvenement=" . $res->idEvenement . "';document.getElementById('actionFormulaireEvenement').value='deplacerImages';if(confirm('Voulez-vous vraiment déplacer ces images ?')){document.getElementById('formulaireEvenement').submit();}", 'onClickSupprimerImage' => "document.getElementById('formulaireEvenement').action='" . $this->creerUrl('supprimerImagesSelectionnees', 'evenement', array('idEvenement' => $idEvenement)) . "';document.getElementById('actionFormulaireEvenement').value='supprimerImages';if(confirm('Voulez-vous vraiment supprimer ces images ?')){document.getElementById('formulaireEvenement').submit();}", 'lierAdresse' => $this->creerUrl('', 'afficheFormulaireEvenementAdresseLiee', array('idEvenement' => $idEvenement)), 'versAdresse' => $this->creerUrl('deplacerEvenementVersNouveauGA', 'evenement', array('idEvenement' => $idEvenement)), 'plusCreer' => $this->creerUrl('deplacerEvenementVersNouveauGA', 'evenement', array('idEvenement' => $idEvenement)));
        $numeroArchive = "";
        if ($fetch['numeroArchive'] != '') {
            // modif fabien du 15/04/2011 suite mail directrice Archives de Strasbourg Mme Perry Laurence
            $numeroArchive = "Cote Archives de Strasbourg : " . $fetch['numeroArchive'] . "";
        }
        // si on est en mode de deplacement d'image
        // ou de selection de titre
        // on rajoute le formulaire sur la page
        if ($authentification->estConnecte() && (isset($this->variablesGet['afficheSelectionImage']) && $this->variablesGet['afficheSelectionImage'] == '1' || isset($this->variablesGet['afficheSelectionTitre']) && $this->variablesGet['afficheSelectionTitre'] == '1')) {
            $arrayFormEvenement = array('formEvenement', array());
        }
        /*
         * Template filling
         */
        //Unset some stuff for historic
        if ($params['type'] == 'historique') {
            unset($listeCommentaires);
            unset($formulaireCommentaire);
            unset($lienHistoriqueEvenementCourant);
            unset($labelHistoriqueEvenement);
        }
        $evenementData = array('titre' => stripslashes($fetch['titre']), 'infoTitre' => $utilisateur . " a " . $txtEnvoi . " un événement", 'txtEnvoi' => $txtEnvoi . " le", 'utilisateur' => $fetch['prenomUtilisateur'] . ' ' . $fetch['nomUtilisateur'], 'urlProfilPic' => $urlProfilPic, 'dateEnvoi' => $fetch['dateCreationEvenement'], 'lienHistoriqueEvenementCourant' => $lienHistoriqueEvenementCourant, 'labelLienHistorique' => $labelHistoriqueEvenement, 'dates' => $dateTxt, 'source' => $source, 'labelStructure' => "Structure  : ", 'typeStructure' => $typeStructure, 'labelTypeEvenement' => 'Type d\'Événement : ', 'urlTypeEvenement' => $this->creerUrl('', 'evenementListe', array('selection' => 'typeEvenement', 'id' => $fetch['idTypeEvenement'])), 'lienTypeEvenement' => $lienTypeEvenement, 'typeEvenement' => $fetch['nomTypeEvenement'], 'numeroArchive' => $numeroArchive, 'description' => $description, 'imagesLiees' => $imagesHTML, 'evenementsParents' => '', 'listeAdressesLiees' => $adressesLieesHTML, 'evenementsLiesPersonne' => $linkedEventsHTML, 'idEvenement' => $idEvenement, 'listeCommentaireEvenement' => $listeCommentaires, 'formulaireCommentaireEvenement' => $formulaireCommentaire);
        //}//End while($fetch = mysql_fetch_assoc($result))
        $evenements[] = $evenementData;
        /*
         * Useless now, but might be need futher if
         *	this function is reused and should not display menu action
         */
        $afficherMenu = $authentification->estConnecte();
        $allowSuppressImage = false;
        //Set to false now, image suppression isn't implemented
        if ($params['type'] == 'historique') {
            $afficherMenu = false;
        }
        $menuArray = array();
        if ($afficherMenu) {
            $menuArray[] = array('evenement.menuAction', array());
            $menuArray[] = array('evenement.menuAction.rowName', array('actionName' => 'Ajouter', 'urlAction' => $urlMenuAction['ajouterImage'], 'actionTarget' => 'Image'));
            $menuArray[] = array('evenement.menuAction.rowName', array('actionName' => 'Modifier', 'urlAction' => $urlMenuAction['modifierImage'], 'actionTarget' => 'Image'));
            $menuArray[] = array('evenement.menuAction.rowName.secondAction', array('urlAction' => $urlMenuAction['modifierEvenement'], 'actionTarget' => 'Événement'));
        }
        if ($isModerateur || $isAdmin) {
            $menuArray[] = array('evenement.menuAction.rowName', array('actionName' => 'Supprimer', 'urlAction' => '#', 'actionTarget' => 'Événement'));
            $menuArray[] = array('evenement.menuAction.rowName.confirmMessage', array('message' => 'Voulez vous vraiment supprimer cet événement ?', 'url' => $urlMenuAction['supprimerEvenement']));
            if ($isAdmin && $allowSuppressImage) {
                $menuArray[] = array('evenement.menuAction.rowName.secondAction', array('urlAction' => '#', 'actionTarget' => 'Image'));
                $menuArray[] = array('evenement.menuAction.rowName.secondAction.confirmMessage', array('message' => 'Voulez vous vraiment supprimer cette image ?', 'url' => $urlMenuAction['onClickSupprimerImage']));
            }
            if ($isAdmin) {
                $menuArray[] = array('evenement.menuAction.rowName', array('actionName' => 'Lier', 'urlAction' => $urlMenuAction['lierAdresse'], 'actionTarget' => 'Adresses'));
                $menuArray[] = array('evenement.menuAction.rowName', array('actionName' => 'Déplacer', 'urlAction' => $urlMenuAction['versAdresse'], 'actionTarget' => 'Vers adresse'));
                $menuArray[] = array('evenement.menuAction.rowName.secondAction', array('urlAction' => $urlMenuAction['plusCreer'], 'actionTarget' => '+Créer'));
            }
        }
        return array('evenementData' => $evenementData, 'menuArray' => $menuArray, 'arrayPersonne' => $arrayPersonne, 'arrayFormEvent' => $arrayFormEvenement, 'arrayCourantArchi' => $arrayCourantArchi);
    }
 public function afficher($idImage = 0)
 {
     $t = new Template('modules/archi/templates/');
     $t->set_filenames(array('detailImage' => 'detailImage.tpl'));
     $adresse = new archiAdresse();
     $evenement = new archiEvenement();
     $authentification = new archiAuthentification();
     $string = new stringObject();
     $u = new archiUtilisateur();
     $d = new droitsObject();
     $html = "";
     if ((isset($this->variablesGet['formatPhoto']) && $this->variablesGet['formatPhoto'] == 'moyenRedim' || isset($this->variablesGet['formatPhoto']) && $this->variablesGet['formatPhoto'] == 'original') && !$authentification->estConnecte()) {
         // il faut etre connecté et donc inscrit pour pouvoir voir les images dans un format different
         $html .= $authentification->afficheFormulaireAuthentification('noCompact', array("msg" => "<b>Pour voir les photos au format moyen ou l'original vous devez être connecté. Si vous n'avez pas encore de compte utilisateur pour vous connecter,  cliquez <a href='" . $this->creerUrl('', 'inscription') . "'>ici</a></b>"));
     } else {
         if ($authentification->estConnecte()) {
             $t->assign_block_vars("isConnected", array());
             $idProfilUtilisateur = $u->getIdProfilFromUtilisateur($authentification->getIdUtilisateur());
             if ($d->isAuthorized('image_supprimer', $idProfilUtilisateur)) {
                 require_once __DIR__ . '/archiPersonne.class.php';
                 $e = new ArchiEvenement();
                 // on verifie que l'utilisateur est moderateur de la ville ou est admin
                 if ($u->isModerateurFromVille($authentification->getIdUtilisateur(), $idImage, 'idImage') || $idProfilUtilisateur == '4' || ArchiPersonne::isPerson($e->getIdEvenementGroupeAdresseFromIdEvenement($_GET['archiRetourIdValue']))) {
                     if (isset($this->variablesGet['archiRetourAffichage'])) {
                         $t->assign_block_vars('isAdminOrModerateurFromVille', array('urlSupprimerImage' => $this->creerUrl('deleteImage', '', array('archiIdImage' => $idImage, 'archiRetourAffichage' => $this->variablesGet['archiRetourAffichage'], 'archiRetourIdName' => $this->variablesGet['archiRetourIdName'], 'archiRetourIdValue' => $this->variablesGet['archiRetourIdValue']))));
                     } else {
                         $t->assign_block_vars('isAdminOrModerateurFromVille', array('urlSupprimerImage' => $this->creerUrl('deleteImage', '', array('archiIdImage' => $idImage))));
                     }
                 }
             }
             if ($authentification->estAdmin()) {
                 if (isset($this->variablesGet['archiRetourAffichage']) && isset($this->variablesGet['archiRetourIdName']) && isset($this->variablesGet['archiRetourIdValue'])) {
                     $t->assign_block_vars('isAdmin', array('urlAfficheHistorique' => $this->creerUrl('', 'afficheHistoriqueImage', array('archiIdImage' => $idImage, 'archiRetourAffichage' => $this->variablesGet['archiRetourAffichage'], 'archiRetourIdName' => $this->variablesGet['archiRetourIdName'], 'archiRetourIdValue' => $this->variablesGet['archiRetourIdValue']))));
                 } else {
                     $t->assign_block_vars('isAdmin', array('urlAfficheHistorique' => $this->creerUrl('', 'afficheHistoriqueImage', array('archiIdImage' => $idImage))));
                 }
             }
         }
         // gestion des liens vers le detail de la photo et autres formats
         if (isset($this->variablesGet["formatPhoto"])) {
             switch ($this->variablesGet["formatPhoto"]) {
                 case 'petit':
                     $classLienPetit = "formatAffichePhotoSelected";
                     $classLienMoyen = "formatAffichePhoto";
                     $classLienOriginal = "formatAffichePhoto";
                     $formatPhoto = "grand";
                     // petit correspond au format 'grand' en interne
                     $formatPhotoUrl = "petit";
                     break;
                 case 'moyenRedim':
                     $classLienPetit = "formatAffichePhoto";
                     $classLienMoyen = "formatAffichePhotoSelected";
                     $classLienOriginal = "formatAffichePhoto";
                     $formatPhoto = "moyenRedim";
                     $formatPhotoUrl = "moyenRedim";
                     break;
                 case 'original':
                     $classLienPetit = "formatAffichePhoto";
                     $classLienMoyen = "formatAffichePhoto";
                     $classLienOriginal = "formatAffichePhotoSelected";
                     $formatPhoto = "originaux";
                     $formatPhotoUrl = "original";
                     break;
             }
         } else {
             $classLienPetit = "formatAffichePhotoSelected";
             $classLienMoyen = "formatAffichePhoto";
             $classLienOriginal = "formatAffichePhoto";
             $formatPhoto = "grand";
             $formatPhotoUrl = "petit";
         }
         if (isset($this->variablesGet['archiRetourAffichage'])) {
             $t->assign_vars(array("choixFormatPhoto" => "<span style='color:#007799;'>Photo au format : <a href='" . $this->creerUrl('', 'imageDetail', array("archiIdImage" => $idImage, "archiRetourAffichage" => $this->variablesGet['archiRetourAffichage'], "archiRetourIdName" => $this->variablesGet['archiRetourIdName'], "archiRetourIdValue" => $this->variablesGet['archiRetourIdValue'], "formatPhoto" => 'petit')) . "' class='{$classLienPetit}'>Petit</a> | <a href='" . $this->creerUrl('', 'imageDetail', array("archiIdImage" => $idImage, "archiRetourAffichage" => $this->variablesGet['archiRetourAffichage'], "archiRetourIdName" => $this->variablesGet['archiRetourIdName'], "archiRetourIdValue" => $this->variablesGet['archiRetourIdValue'], "formatPhoto" => 'moyenRedim')) . "' class='{$classLienMoyen}'>Moyen</a> | <a href='" . $this->creerUrl('', 'imageDetail', array("archiIdImage" => $idImage, "archiRetourAffichage" => $this->variablesGet['archiRetourAffichage'], "archiRetourIdName" => $this->variablesGet['archiRetourIdName'], "archiRetourIdValue" => $this->variablesGet['archiRetourIdValue'], "formatPhoto" => 'original')) . "' class='{$classLienOriginal}'>Original</a></span><br />"));
         } else {
             $idAdresseRetour = $this->getIdAdresseFromIdImage($idImage);
             $t->assign_vars(array("choixFormatPhoto" => "<span style='color:#007799;'>Photo au format : <a href='" . $this->creerUrl('', 'imageDetail', array("archiIdImage" => $idImage, "archiRetourAffichage" => 'adresseDetail', "archiRetourIdName" => 'archiIdAdresse', "archiRetourIdValue" => $idAdresseRetour, "formatPhoto" => 'petit')) . "' class='{$classLienPetit}'>Petit</a> | <a href='" . $this->creerUrl('', 'imageDetail', array("archiIdImage" => $idImage, "archiRetourAffichage" => 'adresseDetail', "archiRetourIdName" => 'archiIdAdresse', "archiRetourIdValue" => $idAdresseRetour, "formatPhoto" => 'moyenRedim')) . "' class='{$classLienMoyen}'>Moyen</a> | <a href='" . $this->creerUrl('', 'imageDetail', array("archiIdImage" => $idImage, "archiRetourAffichage" => 'adresseDetail', "archiRetourIdName" => 'archiIdAdresse', "archiRetourIdValue" => $idAdresseRetour, "formatPhoto" => 'original')) . "' class='{$classLienOriginal}'>Original</a></span><br />"));
         }
         // ***********************************************************************************************************************
         // on prend l'adresse de reference de la page si elle existe sinon celle de l'evenement courant et sinon on prend l'adresse de reference de l'image
         if (isset($this->variablesGet['archiIdAdresse'])) {
             $idAdresseReference = $this->variablesGet['archiIdAdresse'];
         } elseif (isset($this->variablesGet['archiRetourIdName']) && $this->variablesGet['archiRetourIdName'] == 'idEvenement' && isset($this->variablesGet['archiRetourIdValue'])) {
             $idAdresseReference = $adresse->getIdAdresseFromIdEvenementGroupeAdresse($this->variablesGet['archiRetourIdValue']);
         } else {
             $idAdresseReference = $this->getIdAdresseFromIdImage($idImage);
         }
         // **********************************************************************************************************************
         $arrayInfosImage = $this->getInfosCompletesFromIdImage($idImage, array('idAdresseReference' => $idAdresseReference, 'displayFirstTitreAdresse' => true, 'classCSSTitreAdresse' => "textePrisDepuisVueSur", 'withZonesOnMouseOver' => true));
         if (count($arrayInfosImage['vueSurLiens']) > 0) {
             if (count($arrayInfosImage['vueSurLiens']) > 1) {
                 $t->assign_vars(array("infosVueSur" => "<span class='textePrisDepuisVueSurEntete'>Vue sur :</span>&nbsp;<br>" . implode("<br>", $arrayInfosImage['vueSurLiens']) . "<br>"));
             } else {
                 $t->assign_vars(array("infosVueSur" => "<span class='textePrisDepuisVueSurEntete'>Vue sur </span>&nbsp;" . implode(" / ", $arrayInfosImage['vueSurLiens']) . "<br>"));
             }
         }
         if (count($arrayInfosImage['prisDepuisLiens']) > 0) {
             $t->assign_vars(array("infosPrisDepuis" => "<br><span class='textePrisDepuisVueSurEntete'>Pris depuis</span>&nbsp; " . implode(" / ", $arrayInfosImage['prisDepuisLiens']) . "<br>"));
         }
         $e = new archiEvenement();
         if (archiPersonne::isPerson($e->getIdEvenementGroupeAdresseFromIdEvenement($_GET["archiRetourIdValue"]))) {
             $resImage = $this->connexionBdd->requete("SELECT * FROM `historiqueImage` WHERE `idImage` =" . $idImage . ' ORDER BY idHistoriqueImage DESC');
         } else {
             $resImage = $this->connexionBdd->requete("SELECT * FROM `historiqueImage` WHERE `idImage` = {$idImage}\n                    ORDER BY idHistoriqueImage DESC");
             /*$resImage = $this->connexionBdd->requete("
                             select hI.idSource,  hI.nom, hI.dateUpload, hI.dateCliche, hI.description, hI.idUtilisateur, hI.idHistoriqueImage, ha1.idAdresse as idAdresse, ha1.numero as numero,
                             hI.isDateClicheEnviron as isDateClicheEnviron,
                             r.nom as nomRue,
                             sq.nom as nomSousQuartier,
                             q.nom as nomQuartier,
                             v.nom as nomVille,
                             p.nom as nomPays,
                             ha1.numero as numeroAdresse,
                             hI.numeroArchive as numeroArchive,
                             ha1.idRue,
                             r.prefixe as prefixeRue,
                             IF (ha1.idSousQuartier != 0,  ha1.idSousQuartier,  r.idSousQuartier) AS idSousQuartier,
                             IF (ha1.idQuartier != 0,  ha1.idQuartier,  sq.idQuartier) AS idQuartier,
                             IF (ha1.idVille != 0,  ha1.idVille,  q.idVille) AS idVille,
                             IF (ha1.idPays != 0,  ha1.idPays,  v.idPays) AS idPays
             
                             from historiqueImage hI2, historiqueImage hI
             
                             RIGHT JOIN _evenementImage ei ON ei.idImage = hI.idImage
                             RIGHT JOIN _evenementEvenement ee ON ee.idEvenementAssocie = ei.idEvenement
                             RIGHT JOIN _adresseEvenement ae ON ae.idEvenement = ee.idEvenement
                             RIGHT JOIN historiqueAdresse ha1 ON ha1.idAdresse = ae.idAdresse
                             RIGHT JOIN historiqueAdresse ha2 ON ha2.idAdresse = ha1.idAdresse
             
             
                             LEFT JOIN rue r         ON r.idRue = ha1.idRue
                             LEFT JOIN sousQuartier sq    ON sq.idSousQuartier = if (ha1.idRue='0' and ha1.idSousQuartier!='0' , ha1.idSousQuartier , r.idSousQuartier )
                             LEFT JOIN quartier q        ON q.idQuartier = if (ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier!='0' , ha1.idQuartier , sq.idQuartier )
                             LEFT JOIN ville v        ON v.idVille = if (ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille!='0' , ha1.idVille , q.idVille )
                             LEFT JOIN pays p        ON p.idPays = if (ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille='0' and ha1.idPays!='0' , ha1.idPays , v.idPays )
             
             
             
             
                             where hI.idImage='$idImage'
                             and hI2.idImage=hI.idImage
                             group by hI.idImage, hI.idHistoriqueImage, ha1.idAdresse,  ha1.idHistoriqueAdresse
                             having hI.idHistoriqueImage = max(hI2.idHistoriqueImage) and ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)
                             LIMIT 1
                             ");*/
         }
         $fetch = mysql_fetch_array($resImage);
         /*
         stripslashes($fetch['nom'])
          $this->date->toFrench($fetch['dateCliche'])
         */
         $nomEtDateCliche = "";
         if (stripslashes($fetch['nom']) != '' && $this->date->toFrench($fetch['dateCliche']) != '') {
             $nomEtDateCliche = stripslashes($fetch['nom']) . ' - ' . $this->date->toFrench($fetch['dateCliche']);
         } else {
             $nomEtDateCLiche = stripslashes($fetch['nom']) . $this->date->toFrench($fetch['dateCliche']);
         }
         // on affiche les deux car on sait qu'il y en a un qui est vide,  donc pas de probleme
         $datePriseDeVue = "";
         if ($this->date->toFrench($fetch['dateCliche']) != '') {
             $environ = "";
             if ($fetch['isDateClicheEnviron'] == '1') {
                 $environ = "environ ";
             }
             $datePriseDeVue = "Date : {$environ}" . $this->date->toFrench($fetch['dateCliche']);
         }
         $description = $fetch['description'];
         $bbCode = new bbCodeObject();
         //$bbCode = new bbCodeObject();
         if (!empty($description)) {
             $description = $bbCode->convertToDisplay(array('text' => $description));
         }
         if (isset($fetch['idSource']) && $fetch['idSource'] != '' && $fetch['idSource'] != '0') {
             $reqSource = "\n                    SELECT s.idSource as idSource,  s.nom as nomSource,  ts.nom as nomTypeSource\n                    FROM source s\n                    LEFT JOIN typeSource ts ON ts.idTypeSource = s.idTypeSource\n                    WHERE s.idSource = '" . $fetch['idSource'] . "'";
             $resSource = $this->connexionBdd->requete($reqSource);
             $fetchSource = mysql_fetch_assoc($resSource);
             $description .= "<br>Source : <a href='" . $this->creerUrl('', 'listeAdressesFromSource', array('source' => $fetch['idSource'], 'submit' => 'Rechercher')) . "'>" . stripslashes($fetchSource['nomSource']) . " (" . stripslashes($fetchSource['nomTypeSource']) . ")</a>";
         }
         if (isset($fetch['numeroArchive']) && $fetch['numeroArchive'] != '') {
             // modif fabien du 15/04/2011 suite mail directrice Archives de Strasbourg Mme Perry Laurence
             $description .= "<br>Cote Archives de Strasbourg : " . $fetch['numeroArchive'];
         }
         $intituleAdresse = $adresse->getIntituleAdresse($fetch);
         $reqImages = "\n            SELECT idImage FROM _evenementImage WHERE idEvenement = " . mysql_real_escape_string($_GET['archiRetourIdValue']) . " ORDER BY position\n            ";
         $resImages = $this->connexionBdd->requete($reqImages);
         $found = false;
         while ($row = mysql_fetch_assoc($resImages)) {
             if (intval($row['idImage']) == $_GET['archiIdImage']) {
                 if (isset($prev)) {
                     $prevImage = $prev;
                     $t->assign_block_vars('previous', array());
                 }
                 $next = true;
             } else {
                 if (isset($next)) {
                     $nextImage = $row;
                     $t->assign_block_vars('next', array());
                     break;
                 }
             }
             $prev = $row;
         }
         $reqImages = "\n            SELECT idImage FROM _evenementImage  WHERE idEvenement = " . mysql_real_escape_string($_GET['archiRetourIdValue']) . " ORDER BY position\n            ";
         $resImages = $this->connexionBdd->requete($reqImages);
         $imgList = array();
         while ($row = mysql_fetch_row($resImages)) {
             $reqImage = '
             SELECT idHistoriqueImage, dateUpload, description, idImage
             FROM historiqueImage
             WHERE idImage = ' . mysql_real_escape_string($row[0]) . '
             ORDER BY idHistoriqueImage DESC
             LIMIT 1';
             $resImage = $this->connexionBdd->requete($reqImage);
             $imgList[] = mysql_fetch_row($resImage);
         }
         $intituleAdresseNoQuartierNoVille = $adresse->getIntituleAdresse($fetch, array('noQuartier' => true, 'noSousQuartier' => true, 'noVille' => true));
         $format = isset($_GET['formatPhoto']) ? $_GET['formatPhoto'] : 'petit';
         if ($u->canModifyTags(array('idUtilisateur' => $authentification->getIdUtilisateur()))) {
             $tags = 'Tags&nbsp;: ';
             if (empty($fetch["tags"])) {
                 $tags .= '<i>(aucun)</i>';
             } else {
                 $tags .= stripslashes($fetch["tags"]);
             }
         } else {
             $tags = '';
         }
         $t->assign_vars(array('datePriseDeVue' => $datePriseDeVue, 'cheminDetailImage' => 'photos-' . $string->convertStringToUrlRewrite($intituleAdresse) . '-' . $fetch['dateUpload'] . '-' . $fetch['idHistoriqueImage'] . '-' . $formatPhoto . '.jpg', 'nomEtDateCliche' => $nomEtDateCliche, 'tags' => $tags, 'description' => $description, 'fullscreenDesc' => strip_tags($description), 'nom' => $intituleAdresseNoQuartierNoVille, 'IDDivImage' => "divImage_" . $idImage, 'IDDivZones' => "divZones_" . $idImage, 'nextURL' => $this->creerUrl('', 'imageDetail', array('archiIdImage' => $nextImage['idImage'], 'archiRetourAffichage' => 'evenement', 'archiRetourIdName' => 'idEvenement', 'archiRetourIdValue' => $_GET['archiRetourIdValue'], "formatPhoto" => $format)), 'prevURL' => $this->creerUrl('', 'imageDetail', array('archiIdImage' => $prevImage['idImage'], 'archiRetourAffichage' => 'evenement', 'archiRetourIdName' => 'idEvenement', 'archiRetourIdValue' => $_GET['archiRetourIdValue'], "formatPhoto" => $format)), 'list' => rawurlencode(json_encode($imgList)), 'imgID' => rawurlencode(json_encode(array($fetch['idHistoriqueImage'], $fetch['idImage']))), 'imgDate' => $fetch['dateUpload'], 'orgId' => $fetch['idImage'], 'format' => $format));
         //$this->urlImagesGrand.$fetch['dateUpload'].'/'.$fetch['idHistoriqueImage'].".jpg"
         // si affichage du detail sans modification ,  on affiche les zones cliquables
         // pour la selection de zone modifiable
         // on ne l'affiche que si l'image figure dans la table _adresseImage et comporte des adresses sur lesquelles le champ vueSur est a 1
         if (count($arrayInfosImage['vueSurLiens']) > 0 && $authentification->estConnecte() && $u->isAuthorized('selection_zones_photo', $authentification->getIdUtilisateur())) {
             if ($u->getIdProfil($authentification->getIdUtilisateur()) == 4 || $u->isModerateurFromVille($authentification->getIdUtilisateur(), $idImage, 'idImage')) {
                 $styleMenuZoneSelection = "";
                 if (isset($this->variablesGet['archiSelectionZone']) && $this->variablesGet['archiSelectionZone'] == '1') {
                     // menu en rouge si on est sur la selection de zone
                     $styleMenuZoneSelection = "color:#FF0000;";
                 }
                 $t->assign_block_vars('selectionZonesCliquables', array('styleMenuZoneSelection' => $styleMenuZoneSelection, 'urlSelectionZone' => $this->creerUrl('', 'imageDetail', array('archiIdImage' => $idImage, 'archiRetourAffichage' => $this->variablesGet['archiRetourAffichage'], 'archiRetourIdName' => $this->variablesGet['archiRetourIdName'], 'archiRetourIdValue' => $this->variablesGet['archiRetourIdValue'], 'archiSelectionZone' => 1, 'formatPhoto' => $formatPhotoUrl))));
             }
         }
         $authentifie = new archiAuthentification();
         // gestion du lien de retour à la page précédente
         if (isset($this->variablesGet['archiRetourAffichage']) && isset($this->variablesGet['archiRetourIdName']) && isset($this->variablesGet['archiRetourIdValue'])) {
             //$t->assign_block_vars('isRetour',  array('urlRetour'=>$this->creerUrl('',  $this->variablesGet['archiRetourAffichage'],  array($this->variablesGet['archiRetourIdName']=>$this->variablesGet['archiRetourIdValue']))));
             // affichage de l'encars des adresses
             $idEvenementGroupeAdresse = $evenement->getIdEvenementGroupeAdresseFromIdEvenement($this->variablesGet['archiRetourIdValue']);
             if ($idPerson = archiPersonne::isPerson($idEvenementGroupeAdresse)) {
                 $person = new archiPersonne();
                 $infos = $person->getInfosPersonne($idPerson);
                 $html .= "<h2 class='h1'><a href='" . $this->creerUrl('', '', array('archiAffichage' => 'evenementListe', 'selection' => "personne", 'id' => $idPerson)) . "'>" . $infos["prenom"] . " " . $infos["nom"] . "</a></h2>";
             } else {
                 $html .= $adresse->afficherRecapitulatifAdresses($idEvenementGroupeAdresse);
             }
             $t->assign_vars(array('urlModifierImage' => $this->creerUrl('', 'modifierImage', array('archiIdImageModification' => $idImage, 'archiIdEvenementGroupeAdresseAffichageAdresse' => $idEvenementGroupeAdresse))));
         } elseif (isset($idAdresseRetour) && $idAdresseRetour != '' && $idAdresseRetour != '0') {
             $resIdGroupeAdresse = $adresse->getIdEvenementGroupeAdresseFromAdresse($idAdresseRetour);
             $fetchIdGroupeAdresse = mysql_fetch_assoc($resIdGroupeAdresse);
             $html .= $adresse->afficherRecapitulatifAdresses($fetchIdGroupeAdresse['idEvenement']);
             $t->assign_vars(array('urlModifierImage' => $this->creerUrl('', 'modifierImage', array('archiIdImageModification' => $idImage, 'archiIdEvenementGroupeAdresseAffichageAdresse' => $fetchIdGroupeAdresse['idEvenement']))));
         } else {
             $t->assign_vars(array('urlModifierImage' => $this->creerUrl('', 'modifierImage', array('archiIdImageModification' => $idImage))));
         }
         // ***********************************************************************************************************************
         if (isset($this->variablesGet['archiRetourIdName']) && $this->variablesGet['archiRetourIdName'] == 'idEvenement' && isset($this->variablesGet['archiRetourIdValue'])) {
             $reqVerifZone = "\n                    SELECT 0\n                    FROM _adresseImage ai\n                    WHERE\n                        ai.idImage='" . $idImage . "'\n                    AND ai.idEvenementGroupeAdresse = '" . $this->variablesGet['archiRetourIdValue'] . "'\n                    AND vueSur='1'\n                    AND ai.coordonneesZoneImage<>''\n                    AND ai.largeurBaseZoneImage<>''\n                    AND ai.longueurBaseZoneImage<>''\n\n                ";
             $resVerifZone = $this->connexionBdd->requete($reqVerifZone);
             if (mysql_num_rows($resVerifZone) > 0) {
                 $imageZoom = $this->getUrlRacine() . "imageZoomZone.php?idImage=" . $idImage . "&idEvenementGroupeAdresse=" . $this->variablesGet['archiRetourIdValue'] . "&idAdresseCourante=" . $idAdresseReference . "&date=" . $fetch['dateUpload'] . "&idHistorique=" . $fetch['idHistoriqueImage'];
                 $t->assign_vars(array('imageZoom' => "<img src='{$imageZoom}' alt=''>"));
                 $t->assign_vars(array('txtZoom' => "<br>" . _("L'image ci-dessus est un zoom de l'image ci-dessous :")));
             }
         }
         $licence = $this->getLicence($idImage);
         $textLicence = "<img src='images/licences/" . $licence["logo"] . "' alt=''/> ";
         if (!empty($licence["link"])) {
             $textLicence .= "<a rel='license' href='" . $licence["link"] . "'>";
         }
         $textLicence .= $licence["name"];
         if (!empty($licence["link"])) {
             $textLicence .= "</a>";
         }
         $auteur = $this->getAuteur($idImage);
         if (is_array($auteur)) {
             if (!empty($auteur["nom"]) && $auteur["nom"] != " ") {
                 $textLicence .= " (<span itemprop='author'><a rel='author' href='profil-" . $auteur["id"] . ".html'>" . $auteur["nom"] . "</a></span>)";
             }
         } else {
             $textLicence .= " (<span itemprop='author'>" . $auteur . "</span>)";
         }
         $t->assign_vars(array("licence" => $textLicence));
         // ***********************************************************************************************************************
         ob_start();
         $t->pparse('detailImage');
         $html .= ob_get_contents();
         ob_end_clean();
         $image = new imageObject();
         $html .= $image->getJsSetOpacityFunction();
         $html .= $image->getJsCodeDrawFunctions();
         if (isset($this->variablesGet['archiSelectionZone']) && $this->variablesGet['archiSelectionZone'] == '1') {
             // recuperation des longueur et largeur de l'image affiché pour avoir le rapport de base entre ces deux dimensions,  comme cela on pourra reporter les zones sur les images d'autres longueurs et largeurs grace au taux calculé
             $calque = new calqueObject(array('idPopup' => 'popupSelectAdresseVueSurZone'));
             // calque de selection d'adresse une fois que la zone est selectionnee
             $html .= $calque->getDiv(array('height' => 300, 'lienSrcIFrame' => $this->creerUrl('', 'affichePopupSelectionZoneVueSur', array("noHeaderNoFooter" => '1', "archiIdImage" => $idImage)), "titre" => "Selectionnez l'adresse de la zone", "codeJsFermerButton" => "location.href=location.href;"));
             $html .= "<script  >" . $calque->getJsToDragADiv() . "</script>";
             // fonctions de trace,  obligatoire si on veut afficher les zones
             $html .= $image->getJsCodeSelectionZone(array('nomIDImage' => 'divImage', 'tracePolygoneResultat' => true, 'onZoneSelectedAction' => "\n                                        document.getElementById('" . $calque->getJSDivId() . "').style.display='block';\n                                        imageElement = document.getElementById('imageAfficheeID');\n                                        document.getElementById('largeurBaseImageZoneSelection').value=imageElement.clientWidth;\n                                        document.getElementById('longueurBaseImageZoneSelection').value=imageElement.clientHeight;\n                                ", 'addHTMLElementsToFormValidatedAfterZoneSelection' => "<input type='hidden' id='idAdresseRetourZone' name='idAdresseRetourZone' value=''>\n                                <input type='hidden' name='largeurBaseImageZoneSelection' id='largeurBaseImageZoneSelection' value=''>\n                                <input type='hidden' name='longueurBaseImageZoneSelection' id='longueurBaseImageZoneSelection' value=''>\n                                ", 'actionFormValidateZone' => $this->creerUrl('enregistreZoneImage', 'imageDetail', array('archiIdImage' => $idImage, 'archiRetourAffichage' => $this->variablesGet['archiRetourAffichage'], 'archiRetourIdName' => $this->variablesGet['archiRetourIdName'], 'archiRetourIdValue' => $this->variablesGet['archiRetourIdValue']))));
         }
         // affichage des zones existantes,  map sur l'image et divs des formes
         if ($formatPhoto == 'moyenRedim') {
             // vu que le format de la photo moyenRedim est generé a la volée,  il faut calculer les hauteurs et largeurs en fonction d'une autre photo. Ici on prendra le format grand c'est suffisamment precis pas besoin de prendre le format original
             // les photos redimensionnées ont une largeur X de 700px ,  voir le htaccess
             $sizes = getimagesize($this->getCheminPhysiqueImage("grand") . $fetch['dateUpload'] . "/" . $fetch['idHistoriqueImage'] . ".jpg");
             // on converti les dimensions
             $sizeX = 0;
             $sizeY = 0;
             if ($sizes[0] >= $sizes[1]) {
                 $sizeX = 700;
                 $sizeY = round(700 * $sizes[0] / $sizes[1]);
             } else {
                 $sizeY = 700;
                 $sizeX = round(700 * $sizes[1] / $sizes[0]);
             }
             $arrayZones = $this->getDivsAndMapsZonesImagesVueSur(array("idImage" => $idImage, 'largeurImageCourante' => $sizeX, 'longueurImageCourante' => $sizeY));
         } else {
             $sizes = getimagesize($this->getCheminPhysique() . "images/" . $formatPhoto . "/" . $fetch['dateUpload'] . "/" . $fetch['idHistoriqueImage'] . ".jpg");
             $arrayZones = $this->getDivsAndMapsZonesImagesVueSur(array("idImage" => $idImage, 'largeurImageCourante' => $sizes[0], 'longueurImageCourante' => $sizes[1]));
         }
         $html .= $arrayZones['htmlDivs'];
         $html .= $arrayZones['htmlMaps'];
         $html .= $arrayZones['htmlJs'];
     }
     return $html;
 }