PageRenderTime 61ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/src/2.071.0/_modification_compte_user.class.php

https://github.com/crepeausucre/soothERP
PHP | 1080 lines | 610 code | 168 blank | 302 comment | 120 complexity | f427094a76a0a0b06752c60572b0c23e MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

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

Large files files are truncated, but you can click here to view the full file