/src/2.071.0/_inscription_compte_user.class.php

https://github.com/crepeausucre/soothERP · PHP · 1095 lines · 603 code · 180 blank · 312 comment · 104 complexity · 5f17f76fbeef5e29fbf4ae323adf487c MD5 · raw file

  1. <?php
  2. // *************************************************************************************************************
  3. // CLASSE REGISSANT LES INSCRIPTIONS
  4. // *************************************************************************************************************
  5. class Inscription_compte_user extends InscriptionModification {
  6. private $inscription_allowed;
  7. function __construct($id_interface, $inscriptionAllowed = -1) {
  8. parent::__construct($id_interface);
  9. if($inscriptionAllowed == -1){
  10. // La valeur pour $this->inscription_allowed n'a pas été définie
  11. // il faut ouvrir le fichier config pour pouvoir charger cette valeur.
  12. // Lecture du fichier config de l'interface $id_interface
  13. if(file_exists($DIR.$this->getDossier()."_interface.config.php")){
  14. //L'interface possede son porpre fichier de config -> il est lu
  15. $chemin_file = $DIR.$this->getDossier()."_interface.config.php";
  16. if(file_exists($chemin_file)){
  17. $handle = @fopen($chemin_file, "r");
  18. if($handle){
  19. while(!feof($handle) && $inscriptionAllowed == -1){
  20. $ligne = fgets($handle);
  21. $inscriptionAllowed = $this->search_INSCRIPTION_ALLOWED_value($ligne);
  22. }
  23. fclose($handle);
  24. }
  25. }
  26. }else{
  27. //L'interface ne possede pas son porpre fichier de config -> c'est celui du profil client qui est lu
  28. $chemin_file = $DIR."profil_client/_interface.config.php";
  29. if(file_exists($chemin_file)){
  30. $handle = @fopen($chemin_file, "r");
  31. if($handle){
  32. while(!feof($handle) && $inscriptionAllowed == -1){
  33. $ligne = fgets($handle);
  34. $inscriptionAllowed = $this->search_INSCRIPTION_ALLOWED_value($ligne);
  35. }
  36. fclose($handle);
  37. }
  38. }
  39. }
  40. }
  41. $this->inscription_allowed = $inscriptionAllowed;
  42. }
  43. private static function search_INSCRIPTION_ALLOWED_value($texte){
  44. $pattern = '\$INSCRIPTION_ALLOWED([^\/]{0,2})*=([^\/]{0,2})*(\d);.*';
  45. $value_searched = preg_replace('/'.$pattern.'/', '$3', $texte);
  46. if($value_searched != $texte)// la valeur a été trouvée
  47. { return intval($value_searched);}
  48. else{ return -1;}
  49. }
  50. // *************************************************************************************************************
  51. // *************************************************************************************************************
  52. // INSCRIPTION D'UN CONTACT
  53. // *************************************************************************************************************
  54. // *************************************************************************************************************
  55. // Utilisation de la table Table: annuaire_tmp
  56. //
  57. // id_contact_tmp smallint(5) UNSIGNED NOTNULL auto_increment :
  58. // id_interface smallint(5) UNSIGNED NOTNULL :
  59. // infos mediumtext NOTNULL : liste de couple clé/valeur séparé par un ;
  60. // date_demande datetime NOTNULL :
  61. // code_validation varchar(64) NOTNULL : code pour que l'utilisateur confirme son inscription
  62. // validation_email tinyint(2) NOTNULL : 1 => validation par un collab : ce contact n'a pas de besoin la confirmation par mail :
  63. // - soit c'est une inscription sans confirmation
  64. // - soit c'est une inscription avec confirmation, mais l'utilisateur a déjŕ confirmé son inscription
  65. // 2 => validation par un collab : cet utilisateur doit confirmer son inscription pour pouvoir passer
  66. // ŕ l'étape suivante : validation_email <- 1
  67. // 3 => validation automatique : cet utilisateur doit confirmer son inscription pour pouvoir passer
  68. // ŕ l'étape suivante (création du contact et supression de la ligne)
  69. // mode enum('inscription', 'modification') NOTNULL :
  70. //
  71. //
  72. // listes des clé contenu dans le champ infos :
  73. // id_categorie
  74. // civilite
  75. // nom
  76. // siret
  77. // tva_intra
  78. // admin_pseudo
  79. // admin_emaila
  80. // admin_passworda
  81. // livraison_adresse
  82. // livraison_code
  83. // livraison_ville
  84. // id_pays_livraison
  85. // adresse_adresse
  86. // adresse_code
  87. // adresse_ville
  88. // id_pays_contact
  89. // coordonnee_tel1
  90. // coordonnee_tel2
  91. // coordonnee_fax
  92. //
  93. //
  94. // FONCTIONNEMENT DE L'inscription
  95. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  96. // $this->inscription_allowed == 0 : inscription interdite
  97. // inscription_contact => retourne faux
  98. //
  99. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  100. // $this->inscription_allowed == 1 : inscription d'un contact avec une validation par un collaborateur mais sans un mail de confirmation
  101. // inscription_contact
  102. // etape 1 l'inscription est enregistrée
  103. // inscription_contact_avec_validation_sans_mail_confirmation
  104. // inscription_contact_avec_validation_get_sujet_pour_contact
  105. // inscription_contact_avec_validation_get_message_pour_contact
  106. // inscription_contact_avec_validation_get_sujet_pour_collaborateur
  107. // inscription_contact_avec_validation_get_message_pour_collaborateur
  108. // getEmail_du_collaborateur
  109. // envoi_email_templated => CONTACT
  110. // envoi_email_templated => COLLABORATEUR
  111. //
  112. // etape 2A le collab valide l'inscription
  113. // validation_inscription_contact_par_collaborateur
  114. // validation_inscription_contact
  115. // supprimer_inscription
  116. // inscription_creation_contact
  117. // inscription_creation_user
  118. // envoi_email_templated => CONTACT
  119. //
  120. // atape 2B le collab invalide l'inscription
  121. // refus_inscription_contact_par_collaborateur
  122. //
  123. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  124. // $this->inscription_allowed == 3 : inscription d'un contact avec une validation par un collaborateur mais avec un mail confirmation
  125. // inscription_contact
  126. // etape 1 l'inscription est enregistrée
  127. // inscription_contact_avec_validation_avec_mail_confirmation
  128. // inscription_contact_avec_validation_avec_mail_confirmation_get_sujet_pour_contact
  129. // inscription_contact_avec_validation_avec_mail_confirmation_get_message_pour_contact
  130. //
  131. // etape 2 l'utilisateur reçoit le mail et confirme sont inscription
  132. // contact_confirme_son_inscription
  133. // contact_confirme_son_inscription_puis_validation_par_collab
  134. // inscription_contact_avec_validation_get_sujet_pour_contact
  135. // inscription_contact_avec_validation_get_message_pour_contact
  136. // inscription_contact_email_du_contact
  137. // inscription_contact_avec_validation_get_sujet_pour_collaborateur
  138. // inscription_contact_avec_validation_get_message_pour_collaborateur
  139. // getEmail_du_collaborateur
  140. // envoi_email_templated => CONTACT
  141. // envoi_email_templated => COLLABORATEUR
  142. //
  143. // etape 3A le collab valide l'inscription
  144. // validation_inscription_contact_par_collaborateur
  145. // validation_inscription_contact
  146. // supprimer_inscription
  147. // inscription_creation_contact
  148. // inscription_creation_user
  149. // envoi_email_templated => CONTACT
  150. //
  151. // atape 3B le collab invalide l'inscription
  152. // refus_inscription_contact_par_collaborateur
  153. //
  154. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  155. // $this->inscription_allowed == 2 : inscription d'un contact automatique sans mail de confirmation
  156. // inscription_contact
  157. // etape 1 l'inscription est enregistrée
  158. // inscription_contact_automatique_sans_mail_confirmation
  159. // validation_inscription_contact
  160. // inscription_automatique_sans_mail_confirmation_get_suejt_pour_contact
  161. // inscription_automatique_sans_mail_confirmation_get_message_pour_contact
  162. // envoi_email_templated => CONTACT
  163. //
  164. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  165. // $this->inscription_allowed == 4 : inscription d'un contact automatique avec mail de confirmation
  166. // inscription_contact
  167. // etape 1 l'inscription est enregistrée
  168. // inscription_contact_automatique_avec_mail_confirmation
  169. // inscription_contact_automatique_avec_mail_confirmation_get_sujet_pour_contact
  170. // inscription_contact_automatique_avec_mail_confirmation_get_message_pour_contact
  171. // envoi_email_templated => CONTACT
  172. //
  173. // etae 2 l'utilisateur reçoit le mail et confirme sont inscription
  174. // contact_confirme_son_inscription
  175. // contact_confirme_son_inscription_puis_validation_automatique
  176. // validation_inscription_contact
  177. // supprimer_inscription
  178. // inscription_contact_automatique_get_sujet_pour_contact
  179. // inscription_contact_automatique_get_message_pour_contact
  180. // inscription_contact_email_du_contact
  181. // envoi_email_templated => CONTACT
  182. //
  183. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  184. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  185. //lance la procedure d'inscription pour un contact
  186. //@param $infos_contact array : tableau associatif contenant les informations du contact
  187. //@param $email string : email du contact.
  188. //@return boolean : vrai si l'inscrition du contact s'est bien passé, faux sinon.
  189. //attention, l'insrciption peut se faire en plusieurs temps suivant la valeur de $this->inscription_allowed
  190. public function inscription_contact($infos_contact, $email){
  191. //vérification des paramčtres d'entré
  192. if(is_null($infos_contact) || !is_array($infos_contact) || !$this->verifie_infos_contact_pour_inscription_ou_modification_contact($infos_contact))
  193. { return false;}
  194. if(is_null($email) || !is_string($email))
  195. { return false;}
  196. switch ($this->getInscription_allowed()){
  197. case 0 : { return false;} //inscription interdite
  198. case 1 : { return $this->inscription_contact_avec_validation_sans_mail_confirmation($infos_contact, $email); break;}
  199. case 3 : { return $this->inscription_contact_avec_validation_avec_mail_confirmation($infos_contact, $email); break;}
  200. case 2 : { return $this->inscription_contact_automatique_sans_mail_confirmation($infos_contact, $email); break;}
  201. case 4 : { return $this->inscription_contact_automatique_avec_mail_confirmation($infos_contact, $email); break;}
  202. default: { return false;} //valeur non permises
  203. }
  204. }
  205. // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *
  206. // INSCRIPTION D'UN CONTACT AVEC VALIDATION
  207. // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *
  208. //procedure d'inscription pour un contact AVEC VALIDATION et SANS MAIL DE CONFIRMATION
  209. //@param $infos_contact array : tableau associatif contenant les informations du contact
  210. //@param $email string : email du contact.
  211. //@return boolean : vrai si l'inscrition du contact s'est bien passé, faux sinon.
  212. protected function inscription_contact_avec_validation_sans_mail_confirmation($infos_contact, $email){
  213. global $bdd;
  214. if(is_null($infos_contact) || !is_array($infos_contact))
  215. { return false;}
  216. if(is_null($email) || !is_string($email))
  217. { return false;}
  218. if($this->getInscription_allowed() != 1)
  219. { return false;}
  220. global $INSCRIPTION_VALIDATION_CONTENU;
  221. global $INSCRIPTION_VALIDATION_SUJET;
  222. $code_validation = "";
  223. $query = "INSERT INTO annuaire_tmp
  224. (id_interface, infos, date_demande, code_validation, validation_email, mode) VALUES
  225. (".$this->getId_interface().", '".addslashes(implode(";", $infos_contact))."', NOW(), '".$code_validation."', 1, 'inscription')";
  226. if($bdd->exec($query) == 0)
  227. { return false;} //Aucune ligne n'é été modifiée
  228. $id_contact_tmp = $bdd->lastInsertId();
  229. $sujet_pour_contact = $this->inscription_contact_avec_validation_get_sujet_pour_contact();
  230. $message_pour_contact = $this->inscription_contact_avec_validation_get_message_pour_contact();
  231. $email_contact = $email;
  232. $sujet_pour_collaborateur = $this->inscription_contact_avec_validation_get_sujet_pour_collaborateur();
  233. $message_pour_collaborateur = $this->inscription_contact_avec_validation_get_message_pour_collaborateur();
  234. $email_collaborateur = $this->getEmail_du_collaborateur();
  235. if($email_collaborateur === false)
  236. { return false;}
  237. return $this->envoi_email_templated($email_contact, $sujet_pour_contact, $message_pour_contact)
  238. && $this->envoi_email_templated($email_collaborateur, $sujet_pour_collaborateur, $message_pour_collaborateur);
  239. }
  240. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  241. //procedure d'inscription pour un contact AVEC VALIDATION et AVEC MAIL DE CONFIRMATION
  242. //@param $infos_contact array : tableau associatif contenant les informations du contact
  243. //@param $email string : email du contact.
  244. //@return boolean : vrai si l'inscrition du contact s'est bien passé, faux sinon.
  245. protected function inscription_contact_avec_validation_avec_mail_confirmation($infos_contact, $email){
  246. if(is_null($infos_contact) || !is_array($infos_contact))
  247. { return false;}
  248. if(is_null($email) || !is_string($email))
  249. { return false;}
  250. if($this->getInscription_allowed() != 3)
  251. { return false;}
  252. global $INSCRIPTION_VALIDATION_CONTENU;
  253. global $INSCRIPTION_VALIDATION_SUJET;
  254. $code_validation = creer_code_unique($email, $this->getId_interface());
  255. global $bdd;
  256. $query = "INSERT INTO annuaire_tmp
  257. (id_interface, infos, date_demande, code_validation, validation_email, mode) VALUES
  258. (".$this->getId_interface().", '".addslashes(implode(";", $infos_contact))."', NOW(), '".$code_validation."', 2, 'inscription')";
  259. if($bdd->exec($query) == 0)
  260. { return false;} //Aucune ligne n'é été modifiée
  261. $id_contact_tmp = $bdd->lastInsertId();
  262. $sujet_pour_contact = $this->inscription_contact_avec_validation_avec_mail_confirmation_get_sujet_pour_contact();
  263. $message_pour_contact = $this->inscription_contact_avec_validation_avec_mail_confirmation_get_message_pour_contact($id_contact_tmp, $code_validation);
  264. $email_contact = $email;
  265. return $this->envoi_email_templated($email_contact, $sujet_pour_contact, $message_pour_contact);
  266. }
  267. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  268. //sujet du mail envoyé ŕ l'UTILISATEUR quand il s'inscrit sur le site (inscription avec validation)
  269. //@return string : retourne le sujet de l'email envoyé par la fonction Inscription->inscription_contact_avec_validation_sans_mail_confirmation()
  270. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  271. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  272. protected function inscription_contact_avec_validation_get_sujet_pour_contact(){
  273. return "Inscription sur ".$_SERVER['HTTP_HOST'];
  274. }
  275. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  276. //message du mail envoyé ŕ l'UTILISATEUR quand il s'inscrit sur le site (inscription avec validation)
  277. //@return string : retourne le sujet de l'email envoyé par la fonction Inscription->inscription_contact_avec_validation_sans_mail_confirmation()
  278. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  279. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  280. protected function inscription_contact_avec_validation_get_message_pour_contact(){
  281. global $INFO_LOCALE;
  282. return "Date d'envois ".lmb_strftime('le %A %d %B %Y ŕ %H:%M:%S', $INFO_LOCALE)."<br />
  283. <br />
  284. Bonjour et bienvenue,<br />
  285. Vous venez de vous inscrire sur notre site et nous vous en remercions.<br />
  286. <br />
  287. Un de nos collaborateurs va prochainement valider votre fiche. Vous recevrez alors un email de confirmation.<br />
  288. <br />
  289. <br />
  290. ".$this->getNom_entreprise()."
  291. <br />
  292. <br />
  293. -------------------------------------------------------------------------------------------------------------------------<br />
  294. ";
  295. }
  296. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  297. //sujet du mail envoyé A UN COLLABORATEUR quand un utilisateur s'inscrit sur le site (inscription avec validation)
  298. //@return string : retourne le sujet de l'email envoyé par la fonction Inscription->inscription_contact_avec_validation_sans_mail_confirmation()
  299. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  300. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  301. protected function inscription_contact_avec_validation_get_sujet_pour_collaborateur(){
  302. return "Inscription sur ".$_SERVER['HTTP_HOST'];
  303. }
  304. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  305. //corps du mail envoyé A UN COLLABORATEUR quand un utilisateur s'inscrit sur le site (inscription avec validation)
  306. //@return string : retourne le corps de l'email envoyé par la fonction Inscription->inscription_contact_avec_validation_sans_mail_confirmation()
  307. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  308. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  309. protected function inscription_contact_avec_validation_get_message_pour_collaborateur(){
  310. global $INFO_LOCALE;
  311. return "Date d'envois ".lmb_strftime('le %A %d %B %Y ŕ %H:%M:%S', $INFO_LOCALE)."<br />
  312. <br />
  313. Bonjour,<br />
  314. Un nouvel inscrit s'est enregistré sur '".$this->getLib_interface()."' du site '".$_SERVER['HTTP_HOST']."'<br />
  315. Vous devez valider son inscription ŕ partir de votre interface collaborateur.
  316. <br />
  317. <br />
  318. <br />
  319. ".$this->getNom_entreprise()."
  320. <br />
  321. <br />
  322. -------------------------------------------------------------------------------------------------------------------------<br />
  323. ";
  324. }
  325. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  326. //sujet du mail envoyé ŕ l'UTILISATEUR quand il s'inscrit sur le site (inscription avec validation)
  327. //ce message invite l'utilisateur ŕ confirmer son inscription (avant toute autre validation)
  328. //@return string : retourne le sujet de l'email envoyé par la fonction Inscription->inscription_contact_avec_validation_avec_mail_confirmation()
  329. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  330. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  331. protected function inscription_contact_avec_validation_avec_mail_confirmation_get_sujet_pour_contact(){
  332. return "Inscription sur ".$_SERVER['HTTP_HOST'];
  333. }
  334. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  335. //message du mail envoyé ŕ l'UTILISATEUR quand il s'inscrit sur le site (inscription avec validation)
  336. //ce message invite l'utilisateur ŕ confirmer son inscription (avant toute autre validation)
  337. //@return string : retourne le message de l'email envoyé par la fonction Inscription->inscription_contact_avec_validation_avec_mail_confirmation()
  338. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  339. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  340. protected function inscription_contact_avec_validation_avec_mail_confirmation_get_message_pour_contact($id_contact_tmp, $code_validation){
  341. global $INFO_LOCALE;
  342. $my_pathinfo = pathinfo(str_replace(str_replace("/", "\\", $_SERVER['DOCUMENT_ROOT']), "", __FILE__));
  343. return "Date d'envois ".lmb_strftime('le %A %d %B %Y ŕ %H:%M:%S', $INFO_LOCALE)."<br />
  344. <br />
  345. Bonjour,<br />
  346. <br />
  347. votre demande a bien été prise en compte.<br />
  348. Cette validation se fait en deux temps.<br />
  349. Premičrement, vous devez confirmer votre inscription en cliquant sur ce lien :<br />
  350. http://".$_SERVER['HTTP_HOST']."/".$my_pathinfo["dirname"]."/".$this->getDossier()."_inscription_valide.php?id_contact_tmp=".$id_contact_tmp."&code_validation=".$code_validation."<br />
  351. Deuxičmement, notre équipe validera celle-ci.<br />
  352. <br />
  353. <br />
  354. ".$this->getNom_entreprise()."
  355. <br />
  356. <br />
  357. -------------------------------------------------------------------------------------------------------------------------<br />
  358. ";
  359. }
  360. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  361. //retourne l'eamil du collaborateur ŕ qui les demandes de validation doivent ętre envoyé
  362. //@param $id_contact_tmp int : indentifiant du contact temporaire
  363. //@return mixed : l'email sous forme de string s'il a été trouvé, faux sinon.
  364. protected function inscription_contact_email_du_contact($id_contact_tmp){
  365. global $bdd;
  366. $query = "SELECT infos
  367. FROM annuaire_tmp
  368. WHERE id_contact_tmp = ".$id_contact_tmp."";
  369. $resultat = $bdd->query ($query);
  370. if (!$res = $resultat->fetchObject())
  371. { return false;}
  372. return $this->extractEmail($res->infos);
  373. }
  374. // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *
  375. // INSCRIPTION D'UN CONTACT AUTOMATIQUE
  376. // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *
  377. //procedure d'inscription pour un contact AUTOMATIQUE et SANS MAIL de confirmation
  378. //@param $infos_contact array : tableau associatif contenant les informations du contact
  379. //@param $email string : email du contact.
  380. //@return boolean : vrai si l'inscrition du contact s'est bien passé, faux sinon.
  381. protected function inscription_contact_automatique_sans_mail_confirmation($infos_contact, $email){
  382. global $bdd;
  383. if(is_null($infos_contact) || !is_array($infos_contact))
  384. { return false;}
  385. if(is_null($email) || !is_string($email))
  386. { return false;}
  387. if($this->getInscription_allowed() != 2)
  388. { return false;}
  389. $user =& $this->validation_inscription_contact($infos_contact);
  390. if(is_null($user))
  391. { return false;}
  392. $sujet_pour_contact = $this->inscription_contact_automatique_sans_mail_confirmation_get_suejt_pour_contact();
  393. $message_pour_contact = $this->inscription_contact_automatique_sans_mail_confirmation_get_message_pour_contact();
  394. $email_contact = $email;
  395. return $this->envoi_email_templated($email_contact, $sujet_pour_contact, $message_pour_contact);
  396. }
  397. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  398. //sujet du mail envoyé ŕ l'UTILISATEUR pour lui indiquer que son inscription est terminée
  399. //@return string : retourne le sujet de l'email envoyé par la fonction Inscription->inscription_contact_automatique_sans_mail_confirmation()
  400. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  401. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  402. protected function inscription_contact_automatique_sans_mail_confirmation_get_suejt_pour_contact(){
  403. return "Inscription sur ".$_SERVER['HTTP_HOST'];
  404. }
  405. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  406. //message du mail envoyé ŕ l'UTILISATEUR pour lui indiquer que son inscription est terminée
  407. //@return string : retourne le message de l'email envoyé par la fonction Inscription->inscription_contact_automatique_sans_mail_confirmation()
  408. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  409. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  410. protected function inscription_contact_automatique_sans_mail_confirmation_get_message_pour_contact(){
  411. global $INFO_LOCALE;
  412. return "Date d'envois ".lmb_strftime('le %A %d %B %Y ŕ %H:%M:%S', $INFO_LOCALE)."<br />
  413. <br />
  414. Bonjour et bienvenue,<br />
  415. Vous venez de vous inscrire sur notre site et nous vous en remercions.<br />
  416. <br />
  417. <br />
  418. ".$this->getNom_entreprise()."
  419. <br />
  420. <br />
  421. -------------------------------------------------------------------------------------------------------------------------<br />
  422. ";
  423. }
  424. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  425. //procedure d'inscription pour un contact AUTOMATIQUE et SANS MAIL de confirmation
  426. //@param $infos_contact array : tableau associatif contenant les informations du contact
  427. //@param $email string : email du contact.
  428. //@return boolean : vrai si l'inscrition du contact s'est bien passé, faux sinon.
  429. protected function inscription_contact_automatique_avec_mail_confirmation($infos_contact, $email){
  430. if(is_null($infos_contact) || !is_array($infos_contact))
  431. { return false;}
  432. if(is_null($email) || !is_string($email))
  433. { return false;}
  434. if($this->getInscription_allowed() != 4)
  435. { return false;}
  436. $code_validation = creer_code_unique($email, $this->getId_interface());
  437. global $bdd;
  438. $query = "INSERT INTO annuaire_tmp
  439. (id_interface, infos, date_demande, code_validation, validation_email, mode) VALUES
  440. (".$this->getId_interface().", '".addslashes(implode(";", $infos_contact))."', NOW(), '".$code_validation."', 3, 'inscription')";
  441. if($bdd->exec($query) == 0)
  442. { return false;} //Aucune ligne n'é été modifiée
  443. $id_contact_tmp = $bdd->lastInsertId();
  444. $sujet_pour_contact = $this->inscription_contact_automatique_avec_mail_confirmation_get_sujet_pour_contact();
  445. $message_pour_contact = $this->inscription_contact_automatique_avec_mail_confirmation_get_message_pour_contact($id_contact_tmp, $code_validation);
  446. $email_contact = $email;
  447. return $this->envoi_email_templated($email_contact, $sujet_pour_contact, $message_pour_contact);
  448. }
  449. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  450. //sujet du mail envoyé ŕ l'UTILISATEUR pour qu'il confirme son inscription automatique
  451. //@return string : retourne le sujet de l'email envoyé par la fonction Inscription->inscription_contact_automatique_avec_mail_confirmation()
  452. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  453. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  454. protected function inscription_contact_automatique_avec_mail_confirmation_get_sujet_pour_contact(){
  455. return "Confirmation de votre email pour votre inscription sur ".$_SERVER['HTTP_HOST'];
  456. }
  457. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  458. //message du mail envoyé ŕ l'UTILISATEUR pour qu'il confirme son inscription automatique
  459. //@return string : retourne le message de l'email envoyé par la fonction Inscription->inscription_contact_automatique_avec_mail_confirmation()
  460. //Pour personnaliser ce message, il faut créer un sous classe et redéfinir la fonction.
  461. //Cette nouvelle classe sera propre au E-commerce, donc, elle sera dans son dossier !
  462. protected function inscription_contact_automatique_avec_mail_confirmation_get_message_pour_contact($id_contact_tmp, $code_validation){
  463. global $INFO_LOCALE;
  464. $my_pathinfo = pathinfo(str_replace(str_replace("/", "\\", $_SERVER['DOCUMENT_ROOT']), "", __FILE__));
  465. return "Date d'envois ".lmb_strftime('le %A %d %B %Y ŕ %H:%M:%S', $INFO_LOCALE)."<br />
  466. <br />
  467. Bonjour et bienvenue,<br />
  468. Pour finaliser votre inscription sur notre site, vous confirmer votre email en cliquant ou en copiant/collant le lien ci-dessous.<br />
  469. <br />
  470. http://".$_SERVER['HTTP_HOST']."/".$my_pathinfo["dirname"]."/".$this->getDossier()."_inscription_valide.php?id_contact_tmp=".$id_contact_tmp."&code_validation=".$code_validation."<br />
  471. <br />
  472. ".$this->getNom_entreprise()."
  473. <br />
  474. <br />
  475. -------------------------------------------------------------------------------------------------------------------------<br />
  476. ";
  477. }
  478. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  479. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  480. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  481. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  482. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  483. //procedure pour qu'un contact confirme son inscription aprčs avoir reçu un mail l'invitant ŕ le faire
  484. //envoyé par Inscription->inscription_contact_avec_validation_avec_mail_confirmation()
  485. // ou par Inscription->inscription_contact_automatique_avec_mail_confirmation()
  486. //Aprčs cette étape un collaborateur devra valider cette inscription
  487. //@param $id_contact_tmp int :
  488. //@param $code string :
  489. //@return boolean : vrai si la confirmation de l'inscription du contact s'est bien passé, faux sinon.
  490. protected function contact_confirme_son_inscription_puis_validation_automatique($id_contact_tmp, $code){
  491. if($this->getInscription_allowed() != 4)
  492. { return false;}
  493. $email_contact = $this->inscription_contact_email_du_contact($id_contact_tmp);
  494. //si le code est bon on confirme l'inscription
  495. if(!verifier_code_unique($code, $email_contact, $this->getId_interface()))
  496. { return false;}
  497. global $bdd;
  498. $query = "SELECT infos
  499. FROM annuaire_tmp
  500. WHERE id_contact_tmp = ".$id_contact_tmp."";
  501. $resultat = $bdd->query ($query);
  502. if (!$res = $resultat->fetchObject())
  503. { return false;}
  504. $user =& $this->validation_inscription_contact(explode(";", $res->infos));
  505. if(is_null($user))
  506. { return false;}
  507. if(!$this->supprimer_inscription($id_contact_tmp))
  508. { return false;}
  509. $sujet_pour_contact = $this->inscription_contact_automatique_sans_mail_confirmation_get_suejt_pour_contact();
  510. $message_pour_contact = $this->inscription_contact_automatique_sans_mail_confirmation_get_message_pour_contact();
  511. if($email_contact === false)
  512. { return false;}
  513. return $this->envoi_email_templated($email_contact, $sujet_pour_contact, $message_pour_contact);
  514. }
  515. // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *
  516. // CONFIRMATION DE LA PART DE L'UTILISATEUR DE SON INSCRIPTION (ne pas confondre avec la validation par un collab)
  517. // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *
  518. //procedure pour qu'un contact confirme son inscription aprčs avoir reçu un mail l'invitant ŕ le faire
  519. //envoyé par Inscription->inscription_contact_avec_validation_avec_mail_confirmation()
  520. // ou par Inscription->inscription_contact_automatique_avec_mail_confirmation()
  521. //@param $id_contact_tmp int :
  522. //@param $code string :
  523. //@return boolean : vrai si la confirmation de l'inscription du contact s'est bien passé, faux sinon.
  524. public function contact_confirme_son_inscription($id_contact_tmp, $code){
  525. //vérification des paramčtres d'entré
  526. if(is_null($id_contact_tmp) || !is_numeric($id_contact_tmp))
  527. { return false;}
  528. if(is_null($code) || !is_string($code))
  529. { return false;}
  530. if($this->getInscription_allowed() === false)
  531. { return false;}
  532. switch ($this->getInscription_allowed()){
  533. case 0 : { return false;} //inscription interdite
  534. case 1 : { return false;} //la confirmation n'est pas néncessaire
  535. case 3 : { return $this->contact_confirme_son_inscription_puis_validation_par_collab($id_contact_tmp, $code); break;}
  536. case 2 : { return false;} //la confirmation n'est pas néncessaire
  537. case 4 : { return $this->contact_confirme_son_inscription_puis_validation_automatique($id_contact_tmp, $code); break;}
  538. default: { return false;} //valeur non permises
  539. }
  540. }
  541. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  542. //procedure pour qu'un contact confirme son inscription aprčs avoir reçu un mail l'invitant ŕ le faire
  543. //envoyé par Inscription->inscription_contact_avec_validation_avec_mail_confirmation()
  544. // ou par Inscription->inscription_contact_automatique_avec_mail_confirmation()
  545. //Aprčs cette étape un collaborateur devra valider cette inscription
  546. //@param $id_contact_tmp int :
  547. //@param $code string :
  548. //@return boolean : vrai si la confirmation de l'inscription du contact s'est bien passé, faux sinon.
  549. protected function contact_confirme_son_inscription_puis_validation_par_collab($id_contact_tmp, $code){
  550. if($this->getInscription_allowed() != 3)
  551. { return false;}
  552. global $bdd;
  553. $query = "SELECT id_contact_tmp, infos
  554. FROM annuaire_tmp
  555. WHERE id_contact_tmp = ".$id_contact_tmp;
  556. $resultat = $bdd->query($query);
  557. if (!$res = $resultat->fetchObject())
  558. { return false;}
  559. $email = $this->extractEmail($res->infos);
  560. if($email === false)
  561. { return false;}
  562. //si le code est bon on confirme l'inscription
  563. if(!verifier_code_unique($code, $email, $this->getId_interface()))
  564. { return false;}
  565. $query = "UPDATE annuaire_tmp SET validation_email = 1
  566. WHERE id_contact_tmp = '".$id_contact_tmp."' ";
  567. if($bdd->exec($query) == 0)
  568. { return false;} //Aucune ligne n'é été modifiée
  569. $sujet_pour_contact = $this->inscription_contact_avec_validation_get_sujet_pour_contact();
  570. $message_pour_contact = $this->inscription_contact_avec_validation_get_message_pour_contact();
  571. $email_contact = $this->inscription_contact_email_du_contact($id_contact_tmp);
  572. if($email_contact === false)
  573. { return false;}
  574. $sujet_pour_collaborateur = $this->inscription_contact_avec_validation_get_sujet_pour_collaborateur();
  575. $message_pour_collaborateur = $this->inscription_contact_avec_validation_get_message_pour_collaborateur();
  576. $email_collaborateur = $this->getEmail_du_collaborateur();
  577. if($email_collaborateur === false)
  578. { return false;}
  579. return $this->envoi_email_templated($email_contact, $sujet_pour_contact, $message_pour_contact)
  580. && $this->envoi_email_templated($email_collaborateur, $sujet_pour_collaborateur, $message_pour_collaborateur);
  581. }
  582. // *************************************************************************************************************
  583. // VALIDATION DE L'INSCRIPTION
  584. // *************************************************************************************************************
  585. public function refus_inscription_contact_par_collaborateur($id_contact_tmp){
  586. return $this->supprimer_inscription($id_contact_tmp);
  587. }
  588. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  589. public function &validation_inscription_contact_par_collaborateur($id_contact_tmp){
  590. $null = null;
  591. // vérification si on peut créer un user ŕ partir d'une inscription
  592. switch ($this->getInscription_allowed()){
  593. case 1 : case 2 : case 3: case 4 : {break;} //les inscriptions sont permises
  594. default : {return $null;}
  595. }
  596. global $bdd;
  597. $query = "SELECT infos
  598. FROM annuaire_tmp
  599. WHERE id_contact_tmp = ".$id_contact_tmp."";
  600. $resultat = $bdd->query ($query);
  601. if (!$res = $resultat->fetchObject())
  602. { return $null;}
  603. $user =& $this->validation_inscription_contact(explode(";", $res->infos));
  604. if(is_null($user))
  605. { return $null;}
  606. if($this->supprimer_inscription($id_contact_tmp)){
  607. $sujet_pour_contact = $this->validation_inscription_contact_par_collaborateur_get_suejt_pour_contact();
  608. $message_pour_contact = $this->validation_inscription_contact_par_collaborateur_get_message_pour_contact();
  609. $email_contact = $this->extractEmail($res->infos);
  610. if($email_contact === false)
  611. { return $null;}
  612. if($this->envoi_email_templated($email_contact, $sujet_pour_contact, $message_pour_contact))
  613. { return $user;}
  614. else{ return $null;}
  615. }else{ return $null;}
  616. }
  617. protected function validation_inscription_contact_par_collaborateur_get_suejt_pour_contact(){
  618. return "Inscription sur ".$_SERVER['HTTP_HOST'];
  619. }
  620. protected function validation_inscription_contact_par_collaborateur_get_message_pour_contact(){
  621. global $INFO_LOCALE;
  622. return "Date d'envois ".lmb_strftime('le %A %d %B %Y ŕ %H:%M:%S', $INFO_LOCALE)."<br />
  623. <br />
  624. Bonjour,<br />
  625. Votre inscription vient d'ętre validée, Vous pouvez maintenant vous connecter sur ".$_SERVER['HTTP_HOST']." ŕ l'aide de votre login et mot de passe
  626. <br />
  627. <br />
  628. ".$this->getNom_entreprise()."
  629. <br />
  630. <br />
  631. -------------------------------------------------------------------------------------------------------------------------<br />
  632. ";
  633. }
  634. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  635. protected function &validation_inscription_contact($infos_from_inscription){
  636. global $bdd;
  637. $null = null;
  638. // *************************************************
  639. // vérification si on peut créer un user ŕ partir d'une inscription
  640. switch($this->getInscription_allowed()){
  641. case 1 : case 2 : case 3 : case 4 : {break;} //les inscriptions sont permises
  642. default : {return $null;}
  643. }
  644. // *************************************************
  645. // Vérification et initialisation des variables
  646. $this->verifie_infos_contact_pour_inscription_ou_modification_contact($infos_from_inscription);
  647. $infos_new_contact['id_civilite'] = 5;
  648. $infos_new_contact['siret'] = '';
  649. $infos_new_contact['tva_intra'] = '';
  650. $infos_new_contact['id_categorie'] = '1';
  651. $infos_new_contact['note'] = '';
  652. $infos_new_contact['adresses'] = array();
  653. $infos_new_contact['coordonnees'] = array();
  654. $infos_new_contact['sites'] = array();
  655. // *************************************************
  656. // Récupération des valeurs de l'inscription
  657. $infos_contact = array();
  658. foreach($infos_from_inscription as &$tmp_ann) {
  659. $tmp = explode("=", $tmp_ann);
  660. if (count($tmp)==2) {
  661. $infos_contact[$tmp[0]] = $tmp[1];
  662. }
  663. }
  664. unset($infos_from_inscription);
  665. // *************************************************
  666. if(isset($infos_contact['civilite']))
  667. { $infos_new_contact['id_civilite'] = $infos_contact['civilite'];}
  668. if(!isset($infos_contact['nom']))
  669. { return $null;}
  670. $infos_new_contact['nom'] = $infos_contact['nom'];
  671. if(isset($infos_contact['siret']))
  672. { $infos_new_contact['siret'] = $infos_contact['siret'];}
  673. if(isset($infos_contact['tva_intra']))
  674. { $infos_new_contact['tva_intra'] = $infos_contact['tva_intra'];}
  675. if(!isset($infos_contact['id_categorie']))
  676. { return $null;}
  677. $infos_new_contact['id_categorie'] = $infos_contact['id_categorie'];
  678. if(isset($infos_contact['note']))
  679. { $infos_new_contact['note'] = $infos_contact['note'];}
  680. if(!isset($infos_contact['adresse_adresse']))
  681. { return $null;}
  682. if(!isset($infos_contact['admin_emaila']))
  683. { return $null;}
  684. if(!isset($infos_contact['coordonnee_tel1']))
  685. { $infos_contact['coordonnee_tel1'] = "";}
  686. if(!isset($infos_contact['coordonnee_tel2']))
  687. { $infos_contact['coordonnee_tel2'] = "";}
  688. if(!isset($infos_contact['coordonnee_fax']))
  689. { $infos_contact['coordonnee_fax'] = "";}
  690. $infos_new_contact['coordonnees'][] = array('lib_coord' => "", 'tel1' => $infos_contact['coordonnee_tel1'], 'tel2' => $infos_contact['coordonnee_tel2'], 'fax' => $infos_contact['coordonnee_fax'], 'email' => $infos_contact['admin_emaila'], 'note' => "", 'ref_coord_parent' => NULL, 'email_user_creation' => 0 );
  691. if(!isset($infos_contact['admin_pseudo']))
  692. { return $null;}
  693. if(!isset($infos_contact['admin_passworda']))
  694. { return $null;}
  695. // *************************************************
  696. $contact =& $this->inscription_creation_contact($infos_new_contact);
  697. if(is_null($contact))
  698. { return $contact;}
  699. require_once("profil_client/_contact_client.class.php");
  700. $contact_client = new contact_client($contact->getRef_contact());
  701. // *************************************************
  702. $adresse = new adresse();
  703. if(isset($infos_contact['livraison_adresse'])){
  704. if(!$adresse->create($contact->getRef_contact(), "Adresse de Livraison", $infos_contact['livraison_adresse'], $infos_contact['livraison_code'], $infos_contact['livraison_ville'], $infos_contact['id_pays_livraison'], ""))
  705. { return false;}
  706. }else{
  707. if(!$adresse->create($contact->getRef_contact(), "Adresse de Livraison", $infos_contact['adresse_adresse'], $infos_contact['adresse_code'], $infos_contact['adresse_ville'], $infos_contact['id_pays_contact'], ""))
  708. { return false;}
  709. }
  710. $contact_client->maj_ref_adr_livraison($adresse->getRef_adresse());
  711. // *************************************************
  712. $adresse = new adresse();
  713. if(!$adresse->create($contact->getRef_contact(), "Adresse de Facturation", $infos_contact['adresse_adresse'], $infos_contact['adresse_code'], $infos_contact['adresse_ville'], $infos_contact['id_pays_contact'], ""))
  714. { return false;}
  715. $contact_client->maj_ref_adr_facturation($adresse->getRef_adresse());
  716. unset($contact_client, $adresse);
  717. // *************************************************
  718. $user =& $this->inscription_creation_user($contact, $infos_contact['admin_pseudo'], $infos_contact['admin_passworda']);
  719. return $user;
  720. }
  721. // Connecter l'utilisateur
  722. //$_SESSION['user']->login ($infos_from_inscription['admin_pseudo'], $infos_from_inscription['admin_passworda'], "", $infos_from_inscription['profils_inscription']);
  723. //créer un nouveau contact grâce aux informations récoltées lors de l'inscriptions.
  724. //Ce nouveau contact sera retourné (pointer)
  725. //@param array $infos_from_inscription : informations récupérées lors de l'inscription
  726. //@return &contact
  727. protected function &inscription_creation_contact($infos_from_inscription){
  728. // *************************************************
  729. //Profils
  730. $infos_profils = array();
  731. $id_profil = 4;
  732. $infos_profils[$id_profil]['id_profil'] = $id_profil;
  733. //include_once ("./profil_create_".$_SESSION['profils'][$id_profil]->getCode_profil().".inc.php");
  734. // *************************************************
  735. // Création du contact
  736. $contact = new contact();
  737. $contact->create($infos_from_inscription, $infos_profils);
  738. if(count($GLOBALS['_ALERTES']) == 0)
  739. { return $contact;}
  740. else{ $null = null; return $null;}
  741. }
  742. //$this->supprimer_inscription($id_contact_tmp);
  743. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  744. //créer un nouveau user ŕ partir d'un contact. Ce nouveau user sera retourné (pointer)
  745. //@param contact &$contact : informations récupérées lors de l'inscription
  746. //@return &user : si la création s'est bien passée, on retourne un user, null sinon
  747. protected function &inscription_creation_user(&$contact, $admin_pseudo, $admin_passworda){
  748. $utilisateur = null;
  749. $coord = $contact->getCoordonnees();
  750. if(isset($coord[0])){
  751. $utilisateur = new utilisateur();
  752. $utilisateur->create($contact->getRef_contact(), $coord[0]->getRef_coord(), $admin_pseudo, 1, $admin_passworda, 1);
  753. }
  754. return $utilisateur;
  755. }
  756. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  757. public static function getInscriptions_attendant_validation($validation_email = -1, $id_contact_tmp = null) {
  758. global $bdd;
  759. $inscriptions_attendant_validation = array();
  760. $to = new stdClass();
  761. // Utilisation de la table Table: annuaire_tmp
  762. //
  763. // id_contact_tmp smallint(5) UNSIGNED NOTNULL auto_increment :
  764. // id_interface smallint(5) UNSIGNED NOTNULL :
  765. // infos mediumtext NOTNULL : liste de couple clé/valeur séparé par un ;
  766. // date_demande datetime NOTNULL :
  767. // code_validation varchar(64) NOTNULL : code pour que l'utilisateur confirme son inscription
  768. // validation_email tinyint(3) NOTNULL :
  769. // mode enum('inscription', 'modification') NOTNULL :
  770. $query = "SELECT id_contact_tmp, id_interface, infos, date_demande, code_validation, validation_email, mode
  771. FROM annuaire_tmp
  772. WHERE mode = 'inscription'";
  773. if($validation_email >= 0 && is_null($id_contact_tmp))
  774. $query .= "&& validation_email = '".$email."'";
  775. elseif(!is_numm($id_contact_tmp))
  776. $query .= "&& id_contact_tmp = '".$id_contact_tmp."'";
  777. $query .= ";";
  778. $resultat = $bdd->query($query);
  779. while ($res = $resultat->fetchObject()){
  780. $infos = explode(";", $res->infos);
  781. $tab_tmp = array();
  782. foreach ($infos as $info) {
  783. $tab_tmp2 = explode("=", $info);
  784. $tab_tmp[$tab_tmp2[0]] = (isset($tab_tmp2[1])) ? $tab_tmp2[1] : "";
  785. }
  786. $res->infos = $tab_tmp;
  787. $inscriptions_attendant_validation[] = $res;
  788. }
  789. return $inscriptions_attendant_validation;
  790. }
  791. // *************************************************************************************************************
  792. // Fonctions d'accčs aux données
  793. // *************************************************************************************************************
  794. // Retourne inscription_allowed
  795. public function getInscription_allowed(){
  796. if(!isset($this->inscription_allowed))
  797. { return false;}
  798. else{ return $this->inscription_allowed;}
  799. }
  800. // *************************************************************************************************************
  801. //$inscriptions[]["id_contact_tmp"]
  802. //$inscriptions[]["date_demande"]
  803. //$inscriptions[]["infos"]
  804. //$inscriptions[]["id_civilite"]
  805. //$inscriptions[]["nom"]
  806. //$inscriptions[]["id_profil"]
  807. //$inscriptions[]["lib_profil"]
  808. //$inscriptions[]["id_interface"]
  809. //$inscriptions[]["lib_interface"]
  810. //$inscriptions[]["ref_contact"]
  811. //$inscriptions[]["id_categorie"]
  812. //$inscriptions[]["lib_categorie"]
  813. public static function getInscriptions_confirmees(){
  814. global $bdd;
  815. $inscriptions = array();
  816. $query =" SELECT a.id_contact_tmp, a.id_interface, a.infos, a.date_demande, a.validation_email,
  817. i.id_interface, i.lib_interface, i.dossier, i.id_profil,
  818. p.id_profil, p.lib_profil, p.code_profil
  819. FROM annuaire_tmp a
  820. LEFT JOIN interfaces i ON a.id_interface = i.id_interface
  821. LEFT JOIN profils p ON i.id_profil = p.id_profil
  822. WHERE a.validation_email = 1
  823. && a.mode = 'inscription'";
  824. $resultat = $bdd->query($query);
  825. while($res = $resultat->fetchObject()){
  826. $inscriptions[] = array("id_contact_tmp"=> $res->id_contact_tmp,
  827. "date_demande" => $res->date_demande,
  828. "infos" => $res->infos,
  829. "id_civilite" => InscriptionModification::extractCivilite($res->infos),
  830. "nom" => InscriptionModification::extractNom($res->infos),
  831. "id_profil" => $res->id_profil,
  832. "lib_profil" => $res->lib_profil,
  833. "id_interface" => $res->id_interface,
  834. "lib_interface" => $res->lib_interface,
  835. "ref_contact" => "",
  836. "id_categorie" => "",
  837. "lib_categorie" => "");
  838. }
  839. return $inscriptions;
  840. }
  841. //$inscriptions[]["id_contact_tmp"]
  842. //$inscriptions[]["date_demande"]
  843. //$inscriptions[]["infos"]
  844. //$inscriptions[]["id_civilite"]
  845. //$inscriptions[]["nom"]
  846. //$inscriptions[]["id_profil"]
  847. //$inscriptions[]["lib_profil"]
  848. //$inscriptions[]["id_interface"]
  849. //$inscriptions[]["lib_interface"]
  850. //$inscriptions[]["ref_contact"]
  851. //$inscriptions[]["id_categorie"]
  852. //$inscriptions[]["lib_categorie"]
  853. public static function getInscriptions_non_confirmees(){
  854. global $bdd;
  855. $inscriptions = array();
  856. $query =" SELECT a.id_contact_tmp, a.id_interface, a.infos, a.date_demande, a.validation_email,
  857. i.id_interface, i.lib_interface, i.dossier, i.id_profil,
  858. p.id_profil, p.lib_profil, p.code_profil
  859. FROM annuaire_tmp a
  860. LEFT JOIN interfaces i ON a.id_interface = i.id_interface
  861. LEFT JOIN profils p ON i.id_profil = p.id_profil
  862. WHERE a.validation_email = 3
  863. || a.validation_email = 2
  864. && a.mode = 'inscription'";
  865. $resultat = $bdd->query($query);
  866. while($res = $resultat->fetchObject()){
  867. $inscriptions[] = array("id_contact_tmp"=> $res->id_contact_tmp,
  868. "date_demande" => $res->date_demande,
  869. "infos" => $res->infos,
  870. "id_civilite" => Inscription_compte_user::extractCivilite($res->infos),
  871. "nom" => Inscription_compte_user::extractNom($res->infos),
  872. "id_profil" => $res->id_profil,
  873. "lib_profil" => $res->lib_profil,
  874. "id_interface" => $res->id_interface,
  875. "lib_interface" => $res->lib_interface,
  876. "ref_contact" => Inscription_compte_user::extractRef_contact($res->infos),
  877. "id_categorie" => "",
  878. "lib_categorie" => "");
  879. }
  880. return $inscriptions;
  881. }
  882. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  883. }
  884. ?>