$lRequete = "INSERT INTO " . AdherentManager::TABLE_ADHERENT . "\n\t\t\t\t\t\t\t(" . AdherentManager::CHAMP_ADHERENT_ID . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_NUMERO . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_ID_COMPTE . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_NOM . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_PRENOM . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_COURRIEL_PRINCIPAL . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_COURRIEL_SECONDAIRE . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_TELEPHONE_PRINCIPAL . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_TELEPHONE_SECONDAIRE . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_ADRESSE . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_CODE_POSTAL . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_VILLE . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_DATE_NAISSANCE . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_DATE_ADHESION . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_DATE_MAJ . "\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_COMMENTAIRE . "\t\t\t\t\n\t\t\t\t\t\t\t," . AdherentManager::CHAMP_ADHERENT_ETAT . ")\n\t\t\t\t\t\t\tVALUES (NULL\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getNumero()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getIdCompte()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getNom()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getPrenom()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getCourrielPrincipal()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getCourrielSecondaire()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getTelephonePrincipal()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getTelephoneSecondaire()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getAdresse()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getCodePostal()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getVille()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getDateNaissance()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getDateAdhesion()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getDateMaj()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getCommentaire()) . "'\n\t\t\t\t\t\t\t\t,'" . StringUtils::securiser($lAdherent->getEtat()) . "')"; $lId = Dbutils::executerRequeteInsertRetourId($lRequete); // Execution de la requete et récupération de l'Id généré par la BDD // Les modules autorisés des adhérents $lAutorisation = new AutorisationVO(); $lAutorisation->setIdAdherent($lId); $lAutorisation->setIdModule(1); AutorisationManager::insert($lAutorisation); $lAutorisation = new AutorisationVO(); $lAutorisation->setIdAdherent($lId); $lAutorisation->setIdModule(3); AutorisationManager::insert($lAutorisation); // Insertion des informations de connexion $lMdp = MotDePasseUtils::generer(); $lIdentification = new IdentificationVO(); $lIdentification->setIdLogin($lId); $lIdentification->setLogin($lAdherent->getNumero()); $lIdentification->setPass(md5($lMdp)); $lIdentification->setType(1); $lIdentification->setAutorise(1); IdentificationManager::insert($lIdentification); // Ajout à la mailing liste $lMailingListeService = new MailingListeService(); if ($lAdherent->getCourrielPrincipal() != "") { $lMailingListeService->insert($lAdherent->getCourrielPrincipal()); } if ($lAdherent->getCourrielSecondaire() != "") { $lMailingListeService->insert($lAdherent->getCourrielSecondaire()); } // Envoi du mail de confirmation if ($lAdherent->getCourrielPrincipal() != "") {
/** * @name remplirIdentification($pId, $pIdLogin, $pLogin, $pPass, $pType, $pAutorise) * @param int(11) * @param int(11) * @param varchar(20) * @param varchar(100) * @param int(11) * @param tinyint(1) * @return IdentificationVO * @desc Retourne une IdentificationVO remplie */ private static function remplirIdentification($pId, $pIdLogin, $pLogin, $pPass, $pType, $pAutorise) { $lIdentification = new IdentificationVO(); $lIdentification->setId($pId); $lIdentification->setIdLogin($pIdLogin); $lIdentification->setLogin($pLogin); $lIdentification->setPass($pPass); $lIdentification->setType($pType); $lIdentification->setAutorise($pAutorise); return $lIdentification; }
/** * @name insert($pAdherent) * @param AdherentVO * @return AdherentVO * @desc Ajoute un adherent */ private function insert($pAdherent) { // Initialisation du Logger $lLogger =& Log::singleton('file', CHEMIN_FICHIER_LOGS); $lLogger->setMask(Log::MAX(LOG_LEVEL)); // Si pas de liaison création d'un nouveau compte $lNvCompte = false; if ($pAdherent->getIdCompte() == 0) { // Création d'un nouveau compte $lCompte = new CompteVO(); $lCompteService = new CompteService(); $lCompte = $lCompteService->set($lCompte); $pAdherent->setIdCompte($lCompte->getId()); // Laision avec l'adhérent $lNvCompte = true; } // Insertion de la première mise à jour $pAdherent->setDateMaj(StringUtils::dateTimeAujourdhuiDb()); // L'adherent n'est pas supprimé $pAdherent->setEtat(1); // Mise en forme des données $pAdherent->setNom(StringUtils::formaterNom(trim($pAdherent->getNom()))); $pAdherent->setPrenom(StringUtils::formaterPrenom(trim($pAdherent->getPrenom()))); $pAdherent->setCourrielPrincipal(trim($pAdherent->getCourrielPrincipal())); $pAdherent->setCourrielSecondaire(trim($pAdherent->getCourrielSecondaire())); $pAdherent->setTelephonePrincipal(trim($pAdherent->getTelephonePrincipal())); $pAdherent->setTelephoneSecondaire(trim($pAdherent->getTelephoneSecondaire())); $pAdherent->setAdresse(trim($pAdherent->getAdresse())); $pAdherent->setCodePostal(trim($pAdherent->getCodePostal())); $pAdherent->setVille(StringUtils::formaterVille(trim($pAdherent->getVille()))); $pAdherent->setCommentaire(trim($pAdherent->getCommentaire())); // Protection des dates vides if ($pAdherent->getDateNaissance() == '') { $pAdherent->setDateNaissance(StringUtils::FORMAT_DATE_NULLE); } if ($pAdherent->getDateAdhesion() == '') { $pAdherent->setDateAdhesion(StringUtils::FORMAT_DATE_NULLE); } if ($pAdherent->getDateMaj() == '') { $pAdherent->setDateMaj(StringUtils::FORMAT_DATE_NULLE); } // Enregistre l'adherent dans la BDD $lIdAdherent = AdherentManager::insert($pAdherent); if ($lNvCompte) { // Création d'un compte $lCompte = $lCompteService->get($lCompte->getId()); $lCompte->setIdAdherentPrincipal($lIdAdherent); // Positionnement de l'adhérent en adhérent principal du compte $lCompteService->set($lCompte); } else { // Liaison avec un autre compte // Les adhérents du compte $lListeAdherent = $this->selectActifByIdCompte($pAdherent->getIdCompte()); // Le premier adhérent $lAdherent = $lListeAdherent[0]; $lAdhesionService = new AdhesionService(); // Les adhésions sur le premier adhérent $lAdhesions = $lAdhesionService->getAdhesionSurAdherent($lAdherent->getId()); // Positionne les mêmes adhésions foreach ($lAdhesions as $lAdhesion) { if (!is_null($lAdhesion->getAdadId())) { $lAdhesionAdherentDetail = $lAdhesionService->getAdhesionAdherent($lAdhesion->getAdadId()); $lAdhesionAdherent = $lAdhesionAdherentDetail->getAdhesionAdherent(); $lTypeAdhesion = $lAdhesionService->getTypeAdhesion($lAdhesionAdherent->getIdTypeAdhesion()); if ($lTypeAdhesion->getIdPerimetre() == 2) { // Si type d'adhésion sur périmètre compte $lAdhesionAdherent->setId(''); $lAdhesionAdherent->setIdAdherent($lIdAdherent); $lAdhesionService->setAdhesionAdherent($lAdhesionAdherent); } } } } $pAdherent->setId($lIdAdherent); $pAdherent->setNumero('Z' . $lIdAdherent); // Mise à jour du numéro dans l'objet AdherentManager::update($pAdherent); // Mise à jour de la base // Ajout des autorisations de l'adherent $lModuleService = new ModuleService(); $lModulesDefaut = $lModuleService->selectAllDefautVisible(); $lAutorisations = array(); foreach ($lModulesDefaut as $lModule) { $lAutorisation = new AutorisationVO(); $lAutorisation->setIdAdherent($lIdAdherent); $lAutorisation->setIdModule($lModule->getId()); //AutorisationManager::insert($lAutorisation); array_push($lAutorisations, $lAutorisation); } if (!empty($lAutorisations)) { AutorisationManager::insertByArray($lAutorisations); } //$lAdherent = AdherentManager::select($lIdAdherent); // Insertion des informations de connexion $lMdp = MotDePasseUtils::generer(); $lIdentification = new IdentificationVO(); $lIdentification->setIdLogin($lIdAdherent); $lIdentification->setLogin($pAdherent->getNumero()); $lIdentification->setPass(md5($lMdp)); $lIdentification->setType(1); $lIdentification->setAutorise(1); IdentificationManager::insert($lIdentification); // Ajout à la mailing liste $lMailingListeService = new MailingListeService(); if ($pAdherent->getCourrielPrincipal() != "") { $lMailingListeService->insert($pAdherent->getCourrielPrincipal()); } if ($pAdherent->getCourrielSecondaire() != "") { $lMailingListeService->insert($pAdherent->getCourrielSecondaire()); } // Envoi du mail de confirmation if ($pAdherent->getCourrielPrincipal() != "") { $lTo = $pAdherent->getCourrielPrincipal(); } else { if ($pAdherent->getCourrielSecondaire() != "") { $lTo = $pAdherent->getCourrielSecondaire(); } else { // Pas de mail sur le compte : Envoi au gestionnaire $lTo = MAIL_SUPPORT; } } $lFrom = MAIL_SUPPORT; $jour = date("d-m-Y"); $heure = date("H:i"); $lSujet = "Votre Compte zeybux"; $lContenu = file_get_contents(CHEMIN_TEMPLATE . MOD_GESTION_ADHERENTS . "/" . "MailAjoutAdherent.html"); $lContenu = str_replace(array("{LOGIN}", "{MOT_PASSE}", "{PROP_NOM}", "{ZEYBUX_ADRESSE_SITE}"), array($pAdherent->getNumero(), $lMdp, PROP_NOM, ZEYBUX_ADRESSE_SITE), $lContenu); $lHeaders = file_get_contents(CHEMIN_TEMPLATE . COMMUN_TEMPLATE . "/" . "EnteteMail.html"); $lHeaders = str_replace("{FROM}", $lFrom, $lHeaders); $VerifEnvoiMail = TRUE; $VerifEnvoiMail = @mail($lTo, $lSujet, $lContenu, $lHeaders); if ($VerifEnvoiMail === FALSE) { $lVr = new TemplateVR(); $lVr->setValid(false); $lVr->getLog()->setValid(false); $lErreur = new VRerreur(); $lErreur->setCode(MessagesErreurs::ERR_118_CODE); $lErreur->setMessage(MessagesErreurs::ERR_118_MSG); $lVr->getLog()->addErreur($lErreur); $lLogger->log("Erreur d'envoi du mail de création de l'adhérent " . $pAdherent->getNumero() . "par : " . $_SESSION[ID_CONNEXION] . ".", PEAR_LOG_INFO); // Maj des logs $lLogger->log($lVr->export(), PEAR_LOG_INFO); // Maj des logs } else { $lLogger->log("Envoi du mail de création de l'adhérent " . $pAdherent->getNumero() . "par : " . $_SESSION[ID_CONNEXION] . ".", PEAR_LOG_INFO); // Maj des logs } return $pAdherent; }