/** * @name rechercheAutorisation($pTypeRecherche, $pCritereRecherche, $pTypeTri, $pCritereTri) * @param string nom de la table * @param array(string) champs à récupérer dans la table * @param array(array(string, object)) Dictionnaire(champ, valeur)) contenant les champs à filtrer ainsi que la valeur du filtre * @param array(array(string, string)) Dictionnaire(champ, sens) contenant les tris à appliquer * @param integer * @return array(AutorisationVO) * @desc Recherche les autorisations selon les critères et les renvoie sous forme d'une collection de AutorisationVO */ public static function rechercheAutorisation($pTypeRecherche, $pTypeCritere, $pCritereRecherche, $pTypeTri, $pCritereTri) { // Initialisation du Logger $lLogger =& Log::singleton('file', CHEMIN_FICHIER_LOGS); $lLogger->setMask(Log::MAX(LOG_LEVEL)); // Préparation de la requète $lChamps = array(AutorisationManager::CHAMP_AUT_ID . "," . AutorisationManager::CHAMP_AUT_ID_ADHERENT . "," . AutorisationManager::CHAMP_AUT_ID_MODULE); // Préparation de la requète de recherche $lRequete = DbUtils::prepareRequeteRecherche(AutorisationManager::TABLE_AUTORISATION, $lChamps, $pTypeRecherche, $pTypeCritere, $pCritereRecherche, $pTypeTri, $pCritereTri); $lListeAutorisation = array(); if ($lRequete !== false) { $lLogger->log("Execution de la requete : " . $lRequete, PEAR_LOG_DEBUG); // Maj des logs $lSql = Dbutils::executerRequete($lRequete); if (mysql_num_rows($lSql) > 0) { while ($lLigne = mysql_fetch_assoc($lSql)) { array_push($lListeAutorisation, AutorisationManager::remplirAutorisation($lLigne[AutorisationManager::CHAMP_AUT_ID], $lLigne[AutorisationManager::CHAMP_AUT_ID_ADHERENT], $lLigne[AutorisationManager::CHAMP_AUT_ID_MODULE])); } } else { $lListeAutorisation[0] = new AutorisationVO(); } return $lListeAutorisation; } $lListeAutorisation[0] = new AutorisationVO(); return $lListeAutorisation; }
/** * @name recherche( $pTypeRecherche, $pCritereRecherche, $pTypeTri, $pCritereTri ) * @param string nom de la table * @param array(string) champs à récupérer dans la table * @param array(array(string, object)) Dictionnaire(champ, valeur)) contenant les champs à filtrer ainsi que la valeur du filtre * @param array(array(string, string)) Dictionnaire(champ, sens) contenant les tris à appliquer * @return array(AdherentSoldeVO) * @desc Récupères les lignes de la table selon le critère de recherche puis trie et renvoie la liste de résultat sous forme d'une collection de AdherentVO */ public static function recherche($pTypeRecherche, $pTypeCritere, $pCritereRecherche, $pTypeTri, $pCritereTri) { // Initialisation du Logger $lLogger =& Log::singleton('file', CHEMIN_FICHIER_LOGS); $lLogger->setMask(Log::MAX(LOG_LEVEL)); // Préparation de la requète $lChamps = array(AdherentManager::CHAMP_ADHERENT_ID . "," . AdherentManager::CHAMP_ADHERENT_NUMERO . "," . AdherentManager::CHAMP_ADHERENT_ID_COMPTE . "," . AdherentManager::CHAMP_ADHERENT_NOM . "," . AdherentManager::CHAMP_ADHERENT_PRENOM . "," . AdherentManager::CHAMP_ADHERENT_COURRIEL_PRINCIPAL . "," . AdherentManager::CHAMP_ADHERENT_COURRIEL_SECONDAIRE . "," . AdherentManager::CHAMP_ADHERENT_TELEPHONE_PRINCIPAL . "," . AdherentManager::CHAMP_ADHERENT_TELEPHONE_SECONDAIRE . "," . AdherentManager::CHAMP_ADHERENT_ADRESSE . "," . AdherentManager::CHAMP_ADHERENT_CODE_POSTAL . "," . AdherentManager::CHAMP_ADHERENT_VILLE . "," . AdherentManager::CHAMP_ADHERENT_DATE_NAISSANCE . "," . AdherentManager::CHAMP_ADHERENT_DATE_ADHESION . "," . AdherentManager::CHAMP_ADHERENT_DATE_MAJ . "," . AdherentManager::CHAMP_ADHERENT_COMMENTAIRE); // Préparation de la requète de recherche $lRequete = DbUtils::prepareRequeteRecherche(AdherentManager::TABLE_ADHERENT, $lChamps, $pTypeRecherche, $pTypeCritere, $pCritereRecherche, $pTypeTri, $pCritereTri); $lListeAdherent = array(); if ($lRequete !== false) { $lLogger->log("Execution de la requete : " . $lRequete, PEAR_LOG_DEBUG); // Maj des logs $lSql = Dbutils::executerRequete($lRequete); if (mysql_num_rows($lSql) > 0) { $lListeModuleAll = ModuleManager::selectAll(); while ($lLigne = mysql_fetch_assoc($lSql)) { $lAdherent = AdherentSoldeManager::remplirAdherent($lLigne[AdherentManager::CHAMP_ADHERENT_ID], $lLigne[AdherentManager::CHAMP_ADHERENT_NUMERO], $lLigne[AdherentManager::CHAMP_ADHERENT_ID_COMPTE], $lLigne[AdherentManager::CHAMP_ADHERENT_NOM], $lLigne[AdherentManager::CHAMP_ADHERENT_PRENOM], $lLigne[AdherentManager::CHAMP_ADHERENT_COURRIEL_PRINCIPAL], $lLigne[AdherentManager::CHAMP_ADHERENT_COURRIEL_SECONDAIRE], $lLigne[AdherentManager::CHAMP_ADHERENT_TELEPHONE_PRINCIPAL], $lLigne[AdherentManager::CHAMP_ADHERENT_TELEPHONE_SECONDAIRE], $lLigne[AdherentManager::CHAMP_ADHERENT_ADRESSE], $lLigne[AdherentManager::CHAMP_ADHERENT_CODE_POSTAL], $lLigne[AdherentManager::CHAMP_ADHERENT_VILLE], $lLigne[AdherentManager::CHAMP_ADHERENT_DATE_NAISSANCE], $lLigne[AdherentManager::CHAMP_ADHERENT_DATE_ADHESION], $lLigne[AdherentManager::CHAMP_ADHERENT_DATE_MAJ], $lLigne[AdherentManager::CHAMP_ADHERENT_COMMENTAIRE]); // Ajout des modules d'accés $lListeAutorisation = AutorisationManager::selectByIdAdherent($lAdherent->getId()); $lListeModule = array(); foreach ($lListeAutorisation as $lAutorisation) { if ($lListeModuleAll[$lAutorisation->getIdModule()] === NULL) { $lListeModuleAll[$lAutorisation->getIdModule()] = new ModuleVO(); } array_push($lListeModule, $lListeModuleAll[$lAutorisation->getIdModule()]); } $lAdherent->setListeModule($lListeModule); array_push($lListeAdherent, $lAdherent); } } else { $lListeAdherent[0] = new AdherentSoldeVO(); } return $lListeAdherent; } $lListeAdherent[0] = new AdherentSoldeVO(); return $lListeAdherent; }
// Protection des dates vides if ($lAdherent->getDateNaissance() == '') { $lAdherent->setDateNaissance(StringUtils::FORMAT_DATE_NULLE); } $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() != "") {
/** * @name getAutorisation($pId) * @param integer * @return array(AutorisationVO) * @desc Retourne les autorisations d'un adhérent */ public function getAutorisation($pId) { $lAdherentValid = new NAMESPACE_CLASSE\NAMESPACE_VALIDATEUR\MOD_SERVICE\AdherentValid(); if ($lAdherentValid->delete($pId)) { return AutorisationManager::selectByIdAdherent($pId); } return false; }