|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/* |
|
3
|
|
|
* You may not change or alter any portion of this comment or credits |
|
4
|
|
|
* of supporting developers from this source code or any supporting source code |
|
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
* |
|
7
|
|
|
* This program is distributed in the hope that it will be useful, |
|
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
14
|
|
|
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
15
|
|
|
* @package extcal |
|
16
|
|
|
* @since |
|
17
|
|
|
* @author XOOPS Development Team, |
|
18
|
|
|
* |
|
19
|
|
|
* L'utilisation de ce formulaire d'adminitration suppose |
|
20
|
|
|
* que la classe correspondante de la table a été générées avec classGenerator |
|
21
|
|
|
**/ |
|
22
|
|
|
|
|
23
|
|
|
require_once __DIR__ . '/../../../class/uploader.php'; |
|
24
|
|
|
require_once __DIR__ . '/../../../class/mail/phpmailer/class.phpmailer.php'; // First we require the PHPMailer libary in our script |
|
25
|
|
|
require_once __DIR__ . '/../class/utility.php'; |
|
26
|
|
|
require_once __DIR__ . '/constantes.php'; |
|
27
|
|
|
require_once __DIR__ . '/../../../class/template.php'; |
|
28
|
|
|
|
|
29
|
|
|
/******************************************************************** |
|
30
|
|
|
* |
|
31
|
|
|
******************************************************************* |
|
32
|
|
|
* @param $mode |
|
33
|
|
|
* @param $event_id |
|
34
|
|
|
* @param $member_uid |
|
35
|
|
|
* @param $subject |
|
36
|
|
|
* @param $tplMessage |
|
37
|
|
|
*/ |
|
38
|
|
|
function sendMail2member($mode, $event_id, $member_uid, $subject, $tplMessage) |
|
|
|
|
|
|
39
|
|
|
{ |
|
40
|
|
|
//mode = 0 pas d'entete |
|
41
|
|
|
//mode = 1 format text |
|
42
|
|
|
//mode = 2: format html |
|
43
|
|
|
|
|
44
|
|
|
global $xoopsConfig, $xoopsDB; |
|
|
|
|
|
|
45
|
|
|
// $t = print_r($xoopsConfig, true); |
|
|
|
|
|
|
46
|
|
|
// echo "<pre>{$t}</pre>"; |
|
47
|
|
|
/* |
|
|
|
|
|
|
48
|
|
|
$member_uid = 1; |
|
49
|
|
|
$event_id = 393; |
|
50
|
|
|
$message = "Bonne journée à tous"; |
|
51
|
|
|
$newStatus = 1; |
|
52
|
|
|
$oldStatus = 0; |
|
53
|
|
|
|
|
54
|
|
|
*/ |
|
55
|
|
|
|
|
56
|
|
|
//l'utilisateur ne pas etre notifié par mail |
|
57
|
|
|
//if ($mode == 0) exit; |
|
|
|
|
|
|
58
|
|
|
//------------------------------------------------------- |
|
59
|
|
|
$tblMember = $xoopsDB->prefix('extcal_eventmember'); |
|
60
|
|
|
$tblNotMember = $xoopsDB->prefix('extcal_eventnotmember'); |
|
61
|
|
|
$tblUsers = $xoopsDB->prefix('users'); |
|
62
|
|
|
$tblEvent = $xoopsDB->prefix('extcal_event'); |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
//-------------------------------------------------------------- |
|
65
|
|
|
//Recuperation des données event,user et member |
|
66
|
|
|
//Recuperation des données de l'evennement |
|
67
|
|
|
$eventHandler = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE); |
|
68
|
|
|
$obj = $eventHandler->getEvent($event_id); |
|
69
|
|
|
$event = $eventHandler->objectToArray($obj); |
|
70
|
|
|
$eventHandler->formatEventDate($event, _MD_EXTCAL_FORMAT_DATE); |
|
71
|
|
|
|
|
72
|
|
|
$submiter_uid = $event['event_submitter']; |
|
73
|
|
|
// ext_echoArray($event,'event'); |
|
|
|
|
|
|
74
|
|
|
//-------------------------------------------------------------- |
|
75
|
|
|
//Recuperation des données du user createur de l'evennement |
|
76
|
|
|
$sql = <<<__sql__ |
|
77
|
|
|
SELECT if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email |
|
78
|
|
|
FROM {$tblUsers} tu |
|
79
|
|
|
WHERE tu.uid = {$submiter_uid}; |
|
80
|
|
|
__sql__; |
|
81
|
|
|
|
|
82
|
|
|
$rst = $xoopsDB->query($sql); |
|
83
|
|
|
$submiter = $xoopsDB->fetchArray($rst); |
|
84
|
|
|
// echo "{$sql}<br>"; |
|
85
|
|
|
// ext_echoArray($submiter,'submiter'); |
|
|
|
|
|
|
86
|
|
|
//-------------------------------------------------------------- |
|
87
|
|
|
//Recuperation des données du membre inscrit |
|
88
|
|
|
$sql = <<<__sql__ |
|
89
|
|
|
SELECT if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email |
|
90
|
|
|
FROM {$tblUsers} tu |
|
91
|
|
|
WHERE tu.uid = {$member_uid}; |
|
92
|
|
|
__sql__; |
|
93
|
|
|
|
|
94
|
|
|
$rst = $xoopsDB->query($sql); |
|
95
|
|
|
$acteur = $xoopsDB->fetchArray($rst); |
|
96
|
|
|
//echo "{$sql}<br>"; |
|
97
|
|
|
// ext_echoArray($acteur,'acteur'); |
|
|
|
|
|
|
98
|
|
|
//-------------------------------------------------------------- |
|
99
|
|
|
//Recuperation des données des membres présents |
|
100
|
|
|
$sql = <<<__sql__ |
|
101
|
|
|
SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email, |
|
102
|
|
|
tm.status |
|
103
|
|
|
FROM {$tblMember} tm, |
|
104
|
|
|
{$tblUsers} tu |
|
105
|
|
|
WHERE tm.uid = tu.uid |
|
106
|
|
|
AND tm.event_id = {$event_id} |
|
107
|
|
|
__sql__; |
|
108
|
|
|
|
|
109
|
|
|
$rst = $xoopsDB->query($sql); |
|
110
|
|
|
$members = array(); |
|
111
|
|
View Code Duplication |
while ($row = $xoopsDB->fetchArray($rst)) { |
|
|
|
|
|
|
112
|
|
|
$row['status'] = _MD_EXTCAL_PRESENT; |
|
113
|
|
|
$members[$row['uid']] = $row; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
//-------------------------------------------------------------- |
|
117
|
|
|
//Recuperation des données des membres absents |
|
118
|
|
|
$sql = <<<__sql__ |
|
119
|
|
|
SELECT tu.uid, if(tu.name='', tu.uname, tu.name) AS name, tu.uname, tu.email, |
|
120
|
|
|
tm.status |
|
121
|
|
|
FROM {$tblNotMember} tm, |
|
122
|
|
|
{$tblUsers} tu |
|
123
|
|
|
WHERE tm.uid = tu.uid |
|
124
|
|
|
AND tm.event_id = {$event_id} |
|
125
|
|
|
__sql__; |
|
126
|
|
|
|
|
127
|
|
|
$rst = $xoopsDB->query($sql); |
|
128
|
|
View Code Duplication |
while ($row = $xoopsDB->fetchArray($rst)) { |
|
|
|
|
|
|
129
|
|
|
$row['status'] = _MD_EXTCAL_ABSENT; |
|
130
|
|
|
$members[$row['uid']] = $row; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
// ext_echoArray($members,'members'); |
|
|
|
|
|
|
134
|
|
|
// exit; |
|
135
|
|
|
|
|
136
|
|
|
//-------------------------------------------------------------- |
|
137
|
|
|
//Message et sujet du mail |
|
138
|
|
|
$action = ''; //a voir JJD |
|
139
|
|
|
$message = sprintf($tplMessage, $acteur['name']); |
|
140
|
|
|
//$subject .= ' (' . rand(1, 100) . ')'; |
|
|
|
|
|
|
141
|
|
|
$subject .= ' - ' . $acteur['name']; |
|
142
|
|
|
//-------------------------------------------------------------- |
|
143
|
|
|
//Chargement du template dans le dossier de langue |
|
144
|
|
|
//$f = _EXTCAL_PATH_LG . $xoopsConfig['language'] . '\mail_inscription.html'; |
|
|
|
|
|
|
145
|
|
|
//$tpl = new tpl($f); |
|
|
|
|
|
|
146
|
|
|
$tpl = new XoopsTpl(); |
|
147
|
|
|
|
|
148
|
|
|
$tpl->assign('dateAction', date(_MD_EXTCAL_FORMAT_DATE)); |
|
149
|
|
|
$tpl->assign('submiter', $submiter); |
|
150
|
|
|
$tpl->assign('event', $event); |
|
151
|
|
|
$tpl->assign('acteur', $acteur); |
|
152
|
|
|
$tpl->assign('members', $members); |
|
153
|
|
|
$tpl->assign('action', $action); |
|
154
|
|
|
$tpl->assign('subject', $subject); |
|
155
|
|
|
$tpl->assign('message', $message); |
|
156
|
|
|
$tpl->assign('xoopsConfig', $xoopsConfig); |
|
157
|
|
|
$tpl->assign('br', '<br>'); |
|
158
|
|
|
|
|
159
|
|
|
//-------------------------------------------------------------- |
|
160
|
|
|
$destinataires = array(); |
|
161
|
|
|
$destinataires[$submiter['email']] = $submiter['email']; |
|
162
|
|
|
$destinataires[$acteur['email']] = $acteur['email']; |
|
163
|
|
|
// while (list($k, $row) = each($members)) { |
|
|
|
|
|
|
164
|
|
|
foreach ($members as $k => $row) { |
|
165
|
|
|
$destinataires[$row['email']] = $row['email']; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
// ext_echoArray($destinataires); |
|
|
|
|
|
|
169
|
|
|
// exit; |
|
170
|
|
|
|
|
171
|
|
|
$mail_fromName = $xoopsConfig['sitename']; |
|
172
|
|
|
$mail_fromemail = $xoopsConfig['adminmail']; |
|
173
|
|
|
$mail_subject = $subject; |
|
174
|
|
|
|
|
175
|
|
|
$bEcho = false; |
|
|
|
|
|
|
176
|
|
|
$mode = _EXTCAL_HEADER_HTML; |
|
177
|
|
|
$sep = '|'; |
|
|
|
|
|
|
178
|
|
|
|
|
179
|
|
|
$template = 'extcal_mail_member_text.tpl'; |
|
180
|
|
|
if ($mode == _EXTCAL_HEADER_HTML) { |
|
181
|
|
|
$template = 'extcal_mail_member_html.tpl'; |
|
182
|
|
|
} |
|
183
|
|
|
$mail_body = $tpl->fetch('db:' . $template); |
|
184
|
|
|
|
|
185
|
|
|
extcal_SendMail($destinataires, $mail_fromName, $mail_fromemail, $mail_subject, $mail_body, $bEcho = false, $mode = 0, $sep = '|'); |
|
186
|
|
|
|
|
187
|
|
|
//Prépartion de l'envoi |
|
188
|
|
|
|
|
189
|
|
|
//-------------------------------------------------------------- |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/***************************************************************** |
|
193
|
|
|
**************************************************************** |
|
194
|
|
|
* @param $destinataires |
|
195
|
|
|
* @param $mail_fromname |
|
196
|
|
|
* @param $mail_fromemail |
|
197
|
|
|
* @param $mail_subject |
|
198
|
|
|
* @param $mail_body |
|
199
|
|
|
* @param bool $bEcho |
|
200
|
|
|
* @param int $mode |
|
201
|
|
|
* @param string $sep |
|
202
|
|
|
*/ |
|
203
|
|
|
function extcal_SendMail( |
|
204
|
|
|
$destinataires, |
|
205
|
|
|
$mail_fromname, |
|
206
|
|
|
$mail_fromemail, |
|
207
|
|
|
$mail_subject, |
|
208
|
|
|
$mail_body, |
|
209
|
|
|
$bEcho = false, |
|
210
|
|
|
$mode = 0, |
|
|
|
|
|
|
211
|
|
|
$sep = '|' |
|
212
|
|
|
) { |
|
213
|
|
|
global $ModName, $signature, $mail_admin, $xoopsConfig, $xoopsDB, $xoopsModule; |
|
|
|
|
|
|
214
|
|
|
|
|
215
|
|
|
//$bEcho=false; |
|
216
|
|
|
//echo "<hr>function hermesMail<hr>"; |
|
217
|
|
|
|
|
218
|
|
|
// $destinataires = array('[email protected]','[email protected]','[email protected]'); |
|
|
|
|
|
|
219
|
|
|
//$mail_fromname = "test jjd hermes"; |
|
|
|
|
|
|
220
|
|
|
if ($mail_fromname == '') { |
|
221
|
|
|
$mail_fromname = $mail_fromemail; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
//$mail_fromemail = "[email protected]"; |
|
|
|
|
|
|
225
|
|
|
//$mail_subject = "test hemes"; |
|
|
|
|
|
|
226
|
|
|
//$mail_body = getContentTestMail(); |
|
|
|
|
|
|
227
|
|
|
//----------------------------- |
|
228
|
|
|
if (!is_array($destinataires)) { |
|
229
|
|
|
$destinataires = explode($sep, $destinataires); |
|
230
|
|
|
} |
|
231
|
|
|
$header = extcal_getHeader(1, $mail_fromemail); |
|
|
|
|
|
|
232
|
|
|
//----------------------------- |
|
233
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
234
|
|
|
//$xoopsMailer = getMailer(); |
|
|
|
|
|
|
235
|
|
|
$xoopsMailer = xoops_getMailer(); |
|
236
|
|
|
|
|
237
|
|
|
//$xoopsMailer->setToUsers($destinataires[$i]); |
|
|
|
|
|
|
238
|
|
|
|
|
239
|
|
|
// while (list($k, $v) = each($destinataires)) { |
|
|
|
|
|
|
240
|
|
|
foreach ($destinataires as $k => $v) { |
|
241
|
|
|
//for ( $i = 0, $iMax = count($destinataires); $i < $iMax; ++$i) { |
|
|
|
|
|
|
242
|
|
|
//$xoopsMailer->setToUsers($destinataires[$i]); |
|
|
|
|
|
|
243
|
|
|
$xoopsMailer->setToEmails($v); |
|
244
|
|
|
//echo "setToUsers : {$destinataires[$i]}<br>"; |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
$xoopsMailer->multimailer->isHTML(true); |
|
248
|
|
|
$xoopsMailer->setFromName($myts->oopsStripSlashesGPC($mail_fromname)); |
|
249
|
|
|
|
|
250
|
|
|
$xoopsMailer->setFromEmail($myts->oopsStripSlashesGPC($mail_fromemail)); |
|
251
|
|
|
|
|
252
|
|
|
$xoopsMailer->setSubject($myts->oopsStripSlashesGPC($mail_subject)); |
|
253
|
|
|
$xoopsMailer->setBody($myts->oopsStripSlashesGPC($mail_body)); |
|
254
|
|
|
//$xoopsMailer->encodeBody($mail_body); |
|
|
|
|
|
|
255
|
|
|
|
|
256
|
|
|
$xoopsMailer->useMail(); |
|
257
|
|
|
|
|
258
|
|
|
//function $xoopsMailer->sendMail($email, $subject, $body, $headers) |
|
|
|
|
|
|
259
|
|
|
$xoopsMailer->send($bEcho); |
|
260
|
|
|
|
|
261
|
|
|
if ($bEcho) { |
|
262
|
|
|
ExtcalUtility::ext_echo($xoopsMailer->getSuccess()); |
|
263
|
|
|
ExtcalUtility::ext_echo($xoopsMailer->getErrors()); |
|
264
|
|
|
} |
|
265
|
|
|
/* |
|
|
|
|
|
|
266
|
|
|
|
|
267
|
|
|
echo "<hr>mail_fromname : {$mail_fromname}<br>" |
|
268
|
|
|
."mail_fromemail : {$mail_fromemail}<br>" |
|
269
|
|
|
."mail_subject : {$mail_subject}<br>" |
|
270
|
|
|
."mail_body : {$mail_body}<br><hr>"; |
|
271
|
|
|
*/ |
|
272
|
|
|
//--------------------------- |
|
273
|
|
|
/* |
|
|
|
|
|
|
274
|
|
|
|
|
275
|
|
|
$adresse = "[email protected]"; |
|
276
|
|
|
$bolOk = mail($adresse, "test envoi mail", "test envoi envoi mail via php"); |
|
277
|
|
|
$r= (($bolOk) ? " => Succés" : "Echec"); |
|
278
|
|
|
echo "<hr>==> <b>{$r}</b> de l'envoi du mail a: ==> {$adresse}<br>" ; |
|
279
|
|
|
*/ |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
/**************************************************************************** |
|
283
|
|
|
* |
|
284
|
|
|
*************************************************************************** |
|
285
|
|
|
* @param $mode |
|
286
|
|
|
* @param $emailSender |
|
287
|
|
|
* |
|
288
|
|
|
* @return string |
|
289
|
|
|
*/ |
|
290
|
|
|
function extcal_getHeader($mode, $emailSender) |
|
|
|
|
|
|
291
|
|
|
{ |
|
292
|
|
|
//mode = 0 pas d'entete |
|
293
|
|
|
//mode = 1 format text |
|
294
|
|
|
//mode = 2: format html |
|
295
|
|
|
|
|
296
|
|
|
global $xoopsConfig; |
|
|
|
|
|
|
297
|
|
|
|
|
298
|
|
|
// $t = print_r($xoopsConfig, true); |
|
|
|
|
|
|
299
|
|
|
// echo "<pre>{$t}</pre>"; |
|
300
|
|
|
|
|
301
|
|
|
//------------------------------------------------------ |
|
302
|
|
|
$d = date('d-m-Y h:m:h', time()); |
|
|
|
|
|
|
303
|
|
|
//----------------------------------------------------------- |
|
304
|
|
|
//defini l'expediteur du mail |
|
305
|
|
|
if ($emailSender == '') { |
|
306
|
|
|
if ($xoopsConfig['adminmail'] == '') { |
|
307
|
|
|
$emailSender = "webmaster@{$_SERVER['SERVER_NAME']}"; |
|
308
|
|
|
} else { |
|
309
|
|
|
$emailSender = $xoopsConfig['adminmail']; |
|
310
|
|
|
} |
|
311
|
|
|
} |
|
312
|
|
|
//----------------------------------------------------------- |
|
313
|
|
|
$header = array(); |
|
314
|
|
|
$header[] = "From: {$emailSender}"; |
|
315
|
|
|
$header[] = "Reply-To: {$emailSender}"; |
|
316
|
|
|
$header[] = 'X-Mailer: PHP/' . PHP_VERSION; |
|
317
|
|
|
|
|
318
|
|
|
if ($mode == _EXTCAL_HEADER_HTML) { |
|
319
|
|
|
$header[] = 'MIME-Version: 1.0'; |
|
320
|
|
|
$header[] = 'Content-type: text/html; charset=iso-8859-1'; |
|
321
|
|
|
} else { |
|
|
|
|
|
|
322
|
|
|
//bin rien a prori |
|
323
|
|
|
} |
|
324
|
|
|
$header[] = ''; |
|
325
|
|
|
|
|
326
|
|
|
//$sHeader = implode("\r\n", $header); |
|
|
|
|
|
|
327
|
|
|
$sHeader = implode("\r\n", $header); |
|
328
|
|
|
|
|
329
|
|
|
return $sHeader; |
|
330
|
|
|
} |
|
331
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.