Line 4... |
Line 4... |
4 |
* - envoie un email et écrit dans un fichier log
|
4 |
* - envoie un email et écrit dans un fichier log
|
5 |
*
|
5 |
*
|
6 |
* Utilisation: http://www.tela-botanica.org/widget:reseau:remarques
|
6 |
* Utilisation: http://www.tela-botanica.org/widget:reseau:remarques
|
7 |
* Paramètres GET (optionnels):
|
7 |
* Paramètres GET (optionnels):
|
8 |
* pageSource : URL de la page depuis laquelle l'utilisateur a cliqué sur "nous contacter"
|
8 |
* pageSource : URL de la page depuis laquelle l'utilisateur a cliqué sur "nous contacter"
|
9 |
* (exemple: http://www.tela-botanica.org/appli:cel)
|
9 |
* (exemple: http://www.tela-botanica.org/appli:cel)
|
- |
|
10 |
* service : service à l'adresse duquel envoyer le rapport, par défaut webmestre,
|
- |
|
11 |
* limité aux clefs de la liste self::$servicesAutorises
|
- |
|
12 |
* (exemple: cel)
|
10 |
* email : adresse à laquelle envoyer le rapport, par défaut webmestre@tela-botanica.org, limité à la liste self::$emailsAutorises
|
13 |
* email (DÉPRÉCIÉ) : adresse à laquelle envoyer le rapport, par défaut webmestre@tela-botanica.org,
|
- |
|
14 |
* limité aux valeurs de la liste self::$servicesAutorises
|
11 |
* (exemple: cel_remarques@tela-botanica.org)
|
15 |
* (exemple: cel_remarques@tela-botanica.org)
|
12 |
*
|
16 |
*
|
13 |
* @author Mathias Chouet <mathias@tela-botanica.org>
|
17 |
* @author Mathias Chouet <mathias@tela-botanica.org>
|
14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
18 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
19 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
16 |
* @version 0.1
|
20 |
* @version 0.1
|
Line 19... |
Line 23... |
19 |
class Remarques extends WidgetCommun {
|
23 |
class Remarques extends WidgetCommun {
|
Line 20... |
Line 24... |
20 |
|
24 |
|
Line 21... |
Line 25... |
21 |
const DS = DIRECTORY_SEPARATOR;
|
25 |
const DS = DIRECTORY_SEPARATOR;
|
22 |
|
26 |
|
23 |
/**
|
27 |
/**
|
24 |
* adresse de destination par défaut, si une adresse non autorisée est spécifiée,
|
28 |
* service de destination par défaut, si un service ou une adresse non autorisés sont spécifiés,
|
25 |
* ou si aucune adresse n'est spécifiée
|
29 |
* ou si aucun service ni adresse n'est spécifié
|
Line 26... |
Line 30... |
26 |
*/
|
30 |
*/
|
27 |
const EMAIL_PAR_DEFAUT = 'webmestre@tela-botanica.org';
|
31 |
const SERVICE_PAR_DEFAUT = 'webmestre';
|
28 |
|
32 |
|
29 |
/**
|
33 |
/**
|
30 |
* liste des adresses de destination autorisées
|
34 |
* liste des adresses de destination autorisées
|
31 |
*/
|
35 |
*/
|
32 |
private static $emailsAutorises = array(
|
36 |
private static $servicesAutorises = array(
|
33 |
'eflore_remarques@tela-botanica.org',
|
37 |
'eflore' => 'eflore_remarques@tela-botanica.org',
|
34 |
'pictoflora_remarques@tela-botanica.org',
|
38 |
'pictoflora' => 'pictoflora_remarques@tela-botanica.org',
|
35 |
'identiplante_remarques@tela-botanica.org',
|
39 |
'identiplante' => 'identiplante_remarques@tela-botanica.org',
|
36 |
'cel_remarques@tela-botanica.org',
|
40 |
'cel' => 'cel_remarques@tela-botanica.org',
|
37 |
'coel_remarques@tela-botanica.org',
|
- |
|
38 |
'webmestre@tela-botanica.org',
|
41 |
'coel' => 'coel_remarques@tela-botanica.org',
|
Line 39... |
Line 42... |
39 |
'accueil@tela-botanica.org',
|
42 |
'webmestre' => 'webmestre@tela-botanica.org',
|
40 |
'mathias@tela-botanica.org'
|
43 |
'accueil' => 'accueil@tela-botanica.org'
|
- |
|
44 |
);
|
41 |
);
|
45 |
|
42 |
|
46 |
protected $cheminLog;
|
Line 43... |
Line 47... |
43 |
protected $cheminLog;
|
47 |
protected $pageSource;
|
44 |
protected $pageSource;
|
48 |
protected $serviceDestination;
|
Line 53... |
Line 57... |
53 |
|
57 |
|
54 |
public function __construct($config, $parametres) {
|
58 |
public function __construct($config, $parametres) {
|
Line 55... |
Line 59... |
55 |
parent::__construct($config, $parametres);
|
59 |
parent::__construct($config, $parametres);
|
56 |
|
60 |
|
- |
|
61 |
$this->pageSource = 'inconnue';
|
57 |
$this->pageSource = 'inconnue';
|
62 |
$this->serviceDestination = self::SERVICE_PAR_DEFAUT;
|
Line 58... |
Line 63... |
58 |
$this->emailDestination = self::EMAIL_PAR_DEFAUT;
|
63 |
$this->emailDestination = self::$servicesAutorises[self::SERVICE_PAR_DEFAUT];
|
59 |
$this->action = null;
|
64 |
$this->action = null;
|
60 |
|
65 |
|
Line 74... |
Line 79... |
74 |
$this->collecterParametres();
|
79 |
$this->collecterParametres();
|
75 |
$squelette = dirname(__FILE__) . self::DS . 'squelettes' . self::DS . 'remarques.tpl.php';
|
80 |
$squelette = dirname(__FILE__) . self::DS . 'squelettes' . self::DS . 'remarques.tpl.php';
|
Line 76... |
Line 81... |
76 |
|
81 |
|
77 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/remarques/squelettes/css/defaut.css');
|
82 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/remarques/squelettes/css/defaut.css');
|
78 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/remarques/squelettes/js/defaut.js');
|
83 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/remarques/squelettes/js/defaut.js');
|
79 |
$widget['donnees']['email'] = $this->emailDestination;
|
84 |
$widget['donnees']['service'] = $this->serviceDestination;
|
80 |
$widget['donnees']['page'] = $this->pageSource;
|
85 |
$widget['donnees']['page'] = $this->pageSource;
|
Line 81... |
Line 86... |
81 |
$widget['donnees']['envoye'] = false;
|
86 |
$widget['donnees']['envoye'] = false;
|
82 |
|
87 |
|
Line 103... |
Line 108... |
103 |
// paramètres du widget en GET et du formulaire en POST
|
108 |
// paramètres du widget en GET et du formulaire en POST
|
104 |
protected function collecterParametres() {
|
109 |
protected function collecterParametres() {
|
105 |
if (isset($_GET['pageSource']) && $_GET['pageSource'] != '') {
|
110 |
if (isset($_GET['pageSource']) && $_GET['pageSource'] != '') {
|
106 |
$this->pageSource = $_GET['pageSource'];
|
111 |
$this->pageSource = $_GET['pageSource'];
|
107 |
}
|
112 |
}
|
- |
|
113 |
if (isset($_GET['service']) && in_array($_GET['service'], array_keys(self::$servicesAutorises))) {
|
- |
|
114 |
$this->serviceDestination = $_GET['service'];
|
- |
|
115 |
$this->emailDestination = self::$servicesAutorises[$_GET['service']];
|
- |
|
116 |
} else {
|
- |
|
117 |
// Rétrocompatibilité (déprécié)
|
108 |
if (isset($_GET['email']) && in_array($_GET['email'], self::$emailsAutorises)) {
|
118 |
if (isset($_GET['email']) && in_array($_GET['email'], self::$servicesAutorises)) {
|
109 |
$this->emailDestination = $_GET['email'];
|
119 |
$this->emailDestination = $_GET['email'];
|
- |
|
120 |
$this->serviceDestination = array_search($_GET['email'], self::$servicesAutorises);
|
- |
|
121 |
}
|
110 |
}
|
122 |
}
|
111 |
if (isset($_POST['action']) && $_POST['action'] != '') {
|
123 |
if (isset($_POST['action']) && $_POST['action'] != '') {
|
112 |
$this->action = $_POST['action'];
|
124 |
$this->action = $_POST['action'];
|
113 |
}
|
125 |
}
|
114 |
// contenu du formulaire
|
126 |
// contenu du formulaire
|
Line 131... |
Line 143... |
131 |
|
143 |
|
132 |
// ajoute une entrée au log
|
144 |
// ajoute une entrée au log
|
133 |
protected function log() {
|
145 |
protected function log() {
|
134 |
$contenu = ''.
|
146 |
$contenu = ''.
|
135 |
date("Y-m-d h:i:s") . "\n".
|
147 |
date("Y-m-d h:i:s") . "\n".
|
136 |
"Pour: " . $this->emailDestination . "\n".
|
148 |
"Pour: " . $this->serviceDestination . " <" . $this->emailDestination . ">\n".
|
137 |
"Page: " . $this->pageSource . "\n".
|
149 |
"Page: " . $this->pageSource . "\n".
|
138 |
"User agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n".
|
150 |
"User agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n".
|
139 |
"Contributeur: " . $this->coordonnees . "\n".
|
151 |
"Contributeur: " . $this->coordonnees . "\n".
|
140 |
"Gravité: " . $this->gravite . "\n".
|
152 |
"Gravité: " . $this->gravite . "\n".
|
Line 148... |
Line 160... |
148 |
|
160 |
|
149 |
// envoie un email
|
161 |
// envoie un email
|
150 |
protected function email() {
|
162 |
protected function email() {
|
151 |
$contenu = ''.
|
163 |
$contenu = ''.
|
152 |
date("Y-m-d h:i:s") . "\n".
|
164 |
date("Y-m-d h:i:s") . "\n".
|
153 |
"Pour: " . $this->emailDestination . "\n".
|
165 |
"Pour: " . $this->serviceDestination . " <" . $this->emailDestination . ">\n".
|
154 |
"Page: " . $this->pageSource . "\n".
|
166 |
"Page: " . $this->pageSource . "\n".
|
155 |
"User agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n".
|
167 |
"User agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n".
|
156 |
"Contributeur: " . $this->coordonnees . "\n".
|
168 |
"Contributeur: " . $this->coordonnees . "\n".
|
157 |
"Gravité: " . $this->gravite . "\n".
|
169 |
"Gravité: " . $this->gravite . "\n".
|