14 |
aurelien |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* PHP Version 5
|
|
|
4 |
*
|
|
|
5 |
* @category PHP
|
|
|
6 |
* @package annuaire
|
|
|
7 |
* @author aurelien <aurelien@tela-botanica.org>
|
|
|
8 |
* @copyright 2010 Tela-Botanica
|
|
|
9 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
10 |
* @version SVN: <svn_id>
|
|
|
11 |
* @link /doc/annuaire/
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
class LettreControleur extends Controleur {
|
|
|
15 |
|
|
|
16 |
private $chemin_script_inscription_lettre = null;
|
|
|
17 |
|
|
|
18 |
private $commande_inscription_lettre = null;
|
|
|
19 |
|
|
|
20 |
private $commande_desinscription_lettre = null;
|
|
|
21 |
|
|
|
22 |
private $chemin_lettre = null;
|
|
|
23 |
|
|
|
24 |
private $adresse_inscription_lettre = null;
|
|
|
25 |
|
|
|
26 |
private $adresse_desinscription_lettre = null;
|
|
|
27 |
|
|
|
28 |
private $utilise_mail = false;
|
|
|
29 |
|
|
|
30 |
public function LettreControleur() {
|
|
|
31 |
|
|
|
32 |
$this->__construct();
|
|
|
33 |
|
|
|
34 |
if(Config::get('chemin_script_inscription_lettre') != null) {
|
|
|
35 |
$this->chemin_script_inscription_lettre = Config::get('chemin_script_inscription_lettre');
|
|
|
36 |
} else {
|
|
|
37 |
$this->utilise_mail = true;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
if(Config::get('commande_inscription_lettre') != null) {
|
|
|
41 |
$this->commande_inscription = Config::get('commande_inscription_lettre');
|
|
|
42 |
} else {
|
|
|
43 |
$this->utilise_mail = true;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
if(Config::get('commande_desinscription_lettre') != null) {
|
|
|
47 |
$this->commande_desinscription_lettre = Config::get('commande_desinscription_lettre');
|
|
|
48 |
} else{
|
|
|
49 |
$this->utilise_mail = true;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
if(Config::get('chemin_lettre') != null) {
|
|
|
53 |
$this->chemin_lettre = Config::get('chemin_lettre');
|
|
|
54 |
} else {
|
|
|
55 |
$this->utilise_mail = true;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
if(Config::get('adresse_inscription_lettre') != null) {
|
|
|
59 |
$this->adresse_inscription_lettre = Config::get('adresse_inscription_lettre');
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
if(Config::get('adresse_desinscription_lettre') != null) {
|
|
|
63 |
$this->adresse_desinscription_lettre = Config::get('adresse_desinscription_lettre');
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
private function envoyerMail($adresse, $inscrit, $sujet) {
|
|
|
68 |
|
|
|
69 |
// Pour envoyer un mail HTML, l'en-tête Content-type doit être défini
|
|
|
70 |
$entetes = 'MIME-Version: 1.0' . "\r\n";
|
|
|
71 |
$entetes .= 'Content-type: text/html; charset='.Config::get('appli_encodage'). "\r\n";
|
|
|
72 |
// En-têtes additionnels
|
|
|
73 |
$entetes .= 'To: '.$adresse."\r\n";
|
|
|
74 |
$entetes .= 'From: '.$inscrit."\r\n";
|
|
|
75 |
|
|
|
76 |
$contenu_mail = '';
|
|
|
77 |
|
|
|
78 |
return mail($adresse, $sujet, $contenu_mail, $entetes);
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
public function inscriptionLettreActualite($mail) {
|
|
|
82 |
|
|
|
83 |
if($this->utilise_mail) {
|
|
|
84 |
return $this->envoyerMail($this->adresse_inscription_lettre, $mail, 'inscription à la lettre d\'actualité');
|
|
|
85 |
} else {
|
|
|
86 |
//echo 'exec('.$this->commande_inscription_lettre.' '.$this->chemin_lettre.' '.$mail.')';
|
|
|
87 |
//return exec($this->commande_inscription_lettre.' '.$this->chemin_lettre.' '.$mail);
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
public function desinscriptionLettreActualite($mail) {
|
|
|
93 |
|
|
|
94 |
if($this->utilise_mail) {
|
|
|
95 |
return $this->envoyerMail($this->adresse_inscription_lettre, $mail, 'desinscription à la lettre d\'actualité');
|
|
|
96 |
} else {
|
|
|
97 |
//echo 'exec('.$this->commande_desinscription_lettre.' '.$this->chemin_lettre.' '.$mail.')';
|
|
|
98 |
//return exec($this->commande_desinscription_lettre.' '.$this->chemin_lettre.' '.$mail);
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public function ModificationInscriptionLettreActualite($ancien_mail, $nouveau_mail) {
|
|
|
104 |
|
|
|
105 |
if($this->utilise_mail) {
|
|
|
106 |
|
|
|
107 |
$adresse_deinscription_lettre = Config::get('adresse_desinscription_lettre');
|
|
|
108 |
$suppression_ancien_mail = $this->envoyerMail($adresse_deinscription_lettre, $ancien_mail, 'desinscription à la lettre d\'actualité');
|
|
|
109 |
|
|
|
110 |
$adresse_inscription_lettre = Config::get('adresse_inscription_lettre');
|
|
|
111 |
$ajout_nouveau_mail = $this->envoyerMail($adresse_inscription_lettre, $nouveau_mail, 'inscription à la lettre d\'actualité');
|
|
|
112 |
|
|
|
113 |
return $suppression_ancien_mail && $ajout_nouveau_mail;
|
|
|
114 |
} else {
|
|
|
115 |
$desinscription = $this->desinscriptionLettreActualite($ancien_mail);
|
|
|
116 |
$inscription = $this->inscriptionLettreActualite($nouveau_mail);
|
|
|
117 |
|
|
|
118 |
return ($desinscription && $inscription);
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
?>
|