/**
  * This method save the interest with
  */
 public function saveInterest()
 {
     $t = new Template($this->getCheminPhysique() . $this->cheminTemplates . "interest/");
     $t->set_filenames(array('confirm' => 'confirm.tpl'));
     $urlBack = $this->creerUrl('', 'mesInterets', array());
     $txtLink = "Revenir à la liste de mes intérêts";
     if (isset($this->variablesPost) && !empty($this->variablesPost)) {
         $interets = $this->variablesPost;
     } elseif (isset($this->variablesGet) && !empty($this->variablesGet)) {
         $interets = $this->variablesGet;
     }
     /*
      * Initially, it was adding related nesting element in the interests of the user
      * Client asked to add only the smallest element in interest (if neighborhood selected, don't add the city and the country)
      * Little array handling to satified the client need, to revert, delete the two following loops 
      */
     foreach ($interets as $key => $int) {
         if ($int == 0) {
             unset($interets[$key]);
         }
     }
     while (count($interets) > 1) {
         array_shift($interets);
     }
     $requestParameters = array();
     if ($interets['rue'] != 0) {
         $requestParameters[] = array('table' => '_interetRue', 'fieldName1' => 'idUtilisateur', 'fieldName2' => 'idRue', 'idInteret' => $interets['rue'], 'userId' => $this->userId);
     }
     if ($interets['sousQuartier'] != 0) {
         $requestParameters[] = array('table' => '_interetSousQuartier', 'fieldName1' => 'idUtilisateur', 'fieldName2' => 'idSousQuartier', 'idInteret' => $interets['sousQuartier'], 'userId' => $this->userId);
     }
     if ($interets['quartier'] != 0) {
         $requestParameters[] = array('table' => '_interetQuartier', 'fieldName1' => 'idUtilisateur', 'fieldName2' => 'idQuartier', 'idInteret' => $interets['quartier'], 'userId' => $this->userId);
     }
     if ($interets['ville'] != 0) {
         $requestParameters[] = array('table' => '_interetVille', 'fieldName1' => 'idUtilisateur', 'fieldName2' => 'idVille', 'idInteret' => $interets['ville'], 'userId' => $this->userId);
     }
     if ($interets['pays'] != 0) {
         $requestParameters[] = array('table' => '_interetPays', 'fieldName1' => 'idUtilisateur', 'fieldName2' => 'idPays', 'idInteret' => $interets['pays'], 'userId' => $this->userId);
     }
     if ($interets['adresse'] != 0) {
         $idHistoriqueAdresse = $interets['adresse'];
         $requestParameters[] = array('table' => '_interetAdresse', 'fieldName1' => 'idUtilisateur', 'fieldName2' => 'idHistoriqueAdresse', 'idInteret' => $interets['adresse'], 'userId' => $this->userId);
         $requete = "\n\t\t\t\t\tSELECT ae.idEvenement as idEvenementGroupeAdresse, ae.idAdresse as idAdresse \n\t\t\t\t\tFROM _adresseEvenement ae\n\t\t\t\t\tLEFT JOIN historiqueAdresse ha on ha.idAdresse = ae.idAdresse \n\t\t\t\t\tWHERE ha.idHistoriqueAdresse  = " . $idHistoriqueAdresse . "\n\t\t\t\t\t";
         $result = $this->connexionBdd->requete($requete);
         $fetch = mysql_fetch_array($result);
         $idAdresse = $fetch['idAdresse'];
         $idEvenementGroupeAdresse = $fetch['idEvenementGroupeAdresse'];
         $evenement = new archiEvenement();
         $titreAdresse = $evenement->getIntituleAdresseFrom($idAdresse, 'idAdresse');
         $urlBack = $this->creerUrl('', '', array('archiAffichage' => 'adresseDetail', 'archiIdAdresse' => $idAdresse, 'archiIdEvenementGroupeAdresse' => $idEvenementGroupeAdresse));
         $txtLink = "Aller à l'adresse " . $titreAdresse;
     }
     if ($interets['personne']) {
         $requestParameters[] = array('table' => '_interetPersonne', 'fieldName1' => 'idUtilisateur', 'fieldName2' => 'idPersonne', 'idInteret' => $interets['personne'], 'userId' => $this->userId);
         $urlBack = $this->creerUrl('', 'evenementListe', array('selection' => 'personne', 'id' => $interets['personne']));
         $txtLink = "Retour à la fiche de la personne";
     }
     $nbEltInserted = 0;
     foreach ($requestParameters as $rp) {
         //Insert if not exists
         $requete = "\n\t\t\t\t\tINSERT INTO " . $rp['table'] . " (" . $rp['fieldName1'] . "," . $rp['fieldName2'] . ",created)\n\t\t\t\t\tSELECT '" . $this->userId . "', '" . $rp['idInteret'] . "' , now()\n\t\t\t\t\tFROM DUAL\n\t\t\t\t\tWHERE NOT EXISTS (SELECT * FROM `" . $rp['table'] . "`\n\t\t\t\t\tWHERE " . $rp['fieldName1'] . "='" . $this->userId . "' AND " . $rp['fieldName2'] . "='" . $rp['idInteret'] . "')\n\t\t\t\t\tLIMIT 1\n\t\t\t\t\t";
         $res = $this->connexionBdd->requete($requete, false);
     }
     $this->messages->addConfirmation('Intérêt(s) sauvegardé(s) avec succès !');
     $t->assign_vars(array('message' => $this->messages->display(), 'textLink' => $txtLink, 'urlBack' => $urlBack));
     ob_start();
     $t->pparse('confirm');
     $html .= ob_get_contents();
     ob_end_clean();
     return $html;
 }