dolibarr 21.0.3
actions_sendmails.inc.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
6*
7* This program is free software; you can redistribute it and/or modify
8* it under the terms of the GNU General Public License as published by
9* the Free Software Foundation; either version 3 of the License, or
10* (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with this program. If not, see <https://www.gnu.org/licenses/>.
19* or see https://www.gnu.org/
20*/
21
27// $mysoc must be defined
28// $id must be defined
29// $paramname may be defined
30// $autocopy may be defined (used to know the automatic BCC to add)
31// $triggersendname must be set (can be '')
32// $actiontypecode can be set
33// $object and $subject may be defined
46'
47@phan-var-force Societe $mysoc
48@phan-var-force CommonObject $object
49';
50
51$error = 0;
52
53/*
54 * Add file in email form
55 */
56if (GETPOST('addfile', 'alpha')) {
57 $trackid = GETPOST('trackid', 'aZ09');
58
59 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
60
61 // Set tmp user directory
62 $vardir = $conf->user->dir_output."/".$user->id;
63 $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
64
65 dol_add_file_process($upload_dir_tmp, 1, 0, 'addedfile', '', null, $trackid, 0);
66 $action = 'presend';
67}
68
69/*
70 * Remove file in email form
71 */
72if (GETPOST('removedfile') && !GETPOST('removAll')) {
73 $trackid = GETPOST('trackid', 'aZ09');
74
75 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
76
77 // Set tmp user directory
78 $vardir = $conf->user->dir_output."/".$user->id;
79 $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
80
81 // TODO Delete only files that was uploaded from email form. This can be addressed by adding the trackid into the temp path then changing donotdeletefile to 2 instead of 1 to say "delete only if into temp dir"
82 // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
83 dol_remove_file_process(GETPOST('removedfile', 'alpha'), 0, 1, $trackid); // We do not delete because if file is the official PDF of doc, we don't want to remove it physically
84 $action = 'presend';
85}
86
87/*
88 * Remove all files in email form
89 */
90if (GETPOST('removAll', 'alpha')) {
91 $trackid = GETPOST('trackid', 'aZ09');
92
93 $listofpaths = array();
94 $listofnames = array();
95 $listofmimes = array();
96 $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
97 if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
98 $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
99 }
100 if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
101 $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
102 }
103 if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
104 $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
105 }
106
107 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
108 $formmail = new FormMail($db);
109 $formmail->trackid = $trackid;
110
111 foreach ($listofpaths as $key => $value) {
112 $pathtodelete = $value;
113 $filetodelete = $listofnames[$key];
114 $result = dol_delete_file($pathtodelete, 1); // Delete uploaded Files
115
116 $langs->load("other");
117 setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
118
119 $formmail->remove_attached_files($key); // Update Session
120 }
121}
122
123/*
124 * Send mail
125 */
126if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPOST('removAll') && !GETPOST('removedfile') && !GETPOST('cancel') && !GETPOST('modelselected')) {
127 if (empty($trackid)) {
128 $trackid = GETPOST('trackid', 'aZ09');
129 }
130
131 // Set tmp user directory (used to convert images embedded as img src=data:image)
132 $vardir = $conf->user->dir_output."/".$user->id;
133 $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
134
135 $subject = '';
136 //$actionmsg = '';
137 $actionmsg2 = '';
138
139 $langs->load('mails');
140
141 $sendtosocid = 0; // Id of related thirdparty
142
143 if (is_object($object)) {
144 $result = $object->fetch($id);
145
146 if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) {
147 $resultthirdparty = $object->fetch_thirdparty();
148 $thirdparty = $object->thirdparty;
149 if (is_object($thirdparty)) {
150 $sendtosocid = $thirdparty->id;
151 }
152 } elseif ($object->element == 'member' || $object->element == 'user') {
153 $thirdparty = $object;
154 if ($object->socid > 0) {
155 $sendtosocid = $object->socid;
156 }
157 } elseif ($object->element == 'expensereport') {
158 $tmpuser = new User($db);
159 $tmpuser->fetch($object->fk_user_author);
160 $thirdparty = $tmpuser;
161 if ($object->socid > 0) {
162 $sendtosocid = $object->socid;
163 }
164 } elseif ($object->element == 'societe') {
165 $thirdparty = $object;
166 if (is_object($thirdparty) && $thirdparty->id > 0) {
167 $sendtosocid = $thirdparty->id;
168 }
169 } elseif ($object->element == 'contact') {
170 $contact = $object;
171 if ($contact->id > 0) {
172 $contact->fetch_thirdparty();
173 $thirdparty = $contact->thirdparty;
174 if (is_object($thirdparty) && $thirdparty->id > 0) {
175 $sendtosocid = $thirdparty->id;
176 }
177 }
178 } else {
179 dol_print_error(null, "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
180 }
181
182 if (is_object($hookmanager)) {
183 $parameters = array();
184 $reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
185 }
186 } else {
187 $thirdparty = $mysoc;
188 }
189
190 if ($result > 0) {
191 $sendto = '';
192 $sendtocc = '';
193 $sendtobcc = '';
194 $sendtoid = array();
195 $sendtouserid = array();
196 $sendtoccuserid = array();
197
198 // Define $sendto
199 $receiver = GETPOST('receiver', 'alphawithlgt');
200 if (!is_array($receiver)) {
201 if ($receiver == '-1') {
202 $receiver = array();
203 } else {
204 $receiver = array($receiver);
205 }
206 }
207
208 $tmparray = array();
209 if (trim(GETPOST('sendto', 'alphawithlgt'))) {
210 // Recipients are provided into free text field
211 $tmparray[] = trim(GETPOST('sendto', 'alphawithlgt'));
212 }
213
214 if (trim(GETPOST('tomail', 'alphawithlgt'))) {
215 // Recipients are provided into free hidden text field
216 $tmparray[] = trim(GETPOST('tomail', 'alphawithlgt'));
217 }
218
219 if (count($receiver) > 0) {
220 // Recipient was provided from combo list
221 foreach ($receiver as $key => $val) {
222 if ($val == 'thirdparty') { // Key selected means current third party ('thirdparty' may be used for current member or current user too)
223 $tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>';
224 } elseif ($val == 'contact') { // Key selected means current contact
225 $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>';
226 $sendtoid[] = $contact->id;
227 } elseif ($val && $object->element == 'project' && empty($object->socid)) { // $val is the Id of a contact
228 $contact = new Contact($db);
229 $ret = $contact->fetch((int) $val);
230 if ($ret > 0 && !empty($contact->socid)) {
231 $thirdparty = new Societe($db);
232 $thirdparty->fetch($contact->socid);
233 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
234 $sendtoid[] = ((int) $val);
235 }
236 } elseif ($val) { // $val is the Id of a contact
237 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
238 $sendtoid[] = ((int) $val);
239 }
240 }
241 }
242
243 if (getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
244 $receiveruser = GETPOST('receiveruser', 'alphawithlgt');
245 if (is_array($receiveruser) && count($receiveruser) > 0) {
246 $fuserdest = new User($db);
247 foreach ($receiveruser as $key => $val) {
248 $tmparray[] = $fuserdest->user_get_property($val, 'email');
249 $sendtouserid[] = $val;
250 }
251 }
252 }
253
254 $sendto = implode(',', $tmparray);
255
256 // Define $sendtocc
257 $receivercc = GETPOST('receivercc', 'alphawithlgt');
258 if (!is_array($receivercc)) {
259 if ($receivercc == '-1') {
260 $receivercc = array();
261 } else {
262 $receivercc = array($receivercc);
263 }
264 }
265 $tmparray = array();
266 if (trim(GETPOST('sendtocc', 'alphawithlgt'))) {
267 $tmparray[] = trim(GETPOST('sendtocc', 'alphawithlgt'));
268 }
269 if (count($receivercc) > 0) {
270 foreach ($receivercc as $key => $val) {
271 if ($val == 'thirdparty') { // Key selected means current thirdparty (may be usd for current member or current user too)
272 // Recipient was provided from combo list
273 $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
274 } elseif ($val == 'contact') { // Key selected means current contact
275 // Recipient was provided from combo list
276 $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
277 //$sendtoid[] = $contact->id; TODO Add also id of contact in CC ?
278 } elseif ($val) { // $val is the Id of a contact
279 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
280 //$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ?
281 }
282 }
283 }
284 if (getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
285 $receiverccuser = GETPOST('receiverccuser', 'alphawithlgt');
286
287 if (is_array($receiverccuser) && count($receiverccuser) > 0) {
288 $fuserdest = new User($db);
289 foreach ($receiverccuser as $key => $val) {
290 $tmparray[] = $fuserdest->user_get_property($val, 'email');
291 $sendtoccuserid[] = $val;
292 }
293 }
294 }
295 $sendtocc = implode(',', $tmparray);
296
297 if (dol_strlen($sendto)) {
298 // Define $urlwithroot
299 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
300 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
301 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
302
303 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
304
305 $langs->load("commercial");
306
307 $reg = array();
308 $fromtype = GETPOST('fromtype', 'alpha');
309 if ($fromtype === 'robot') {
310 $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM').'>';
311 } elseif ($fromtype === 'user') {
312 $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
313 } elseif ($fromtype === 'company') {
314 $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>';
315 } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
316 $tmp = explode(',', $user->email_aliases);
317 $from = trim($tmp[((int) $reg[1] - 1)]);
318 } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
319 $tmp = explode(',', getDolGlobalString('MAIN_INFO_SOCIETE_MAIL_ALIASES'));
320 $from = trim($tmp[((int) $reg[1] - 1)]);
321 } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
322 $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
323 $sql .= ' WHERE rowid = '.(int) $reg[1];
324 $resql = $db->query($sql);
325 $obj = $db->fetch_object($resql);
326 if ($obj) {
327 $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
328 }
329 } elseif (preg_match('/from_template_(\d+)/', $fromtype, $reg)) {
330 $sql = 'SELECT rowid, email_from FROM '.MAIN_DB_PREFIX.'c_email_templates';
331 $sql .= ' WHERE rowid = '.(int) $reg[1];
332 $resql = $db->query($sql);
333 $obj = $db->fetch_object($resql);
334 if ($obj) {
335 $from = $obj->email_from;
336 }
337 } else {
338 $from = dol_string_nospecial(GETPOST('fromname'), ' ', array(",")).' <'.GETPOST('frommail').'>';
339 }
340
341 $replyto = dol_string_nospecial(GETPOST('replytoname'), ' ', array(",")).' <'.GETPOST('replytomail').'>';
342
343 $message = GETPOST('message', 'restricthtml');
344 $subject = GETPOST('subject', 'restricthtml');
345
346 // Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
347 // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
348 // become
349 // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
350 $message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
351
352 $sendtobcc = GETPOST('sendtoccc', 'alphawithlgt');
353 // Autocomplete the $sendtobcc
354 // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
355 if (!empty($autocopy)) {
356 $sendtobcc .= (getDolGlobalString($autocopy) ? (($sendtobcc ? ", " : "") . getDolGlobalString($autocopy)) : '');
357 }
358
359 $deliveryreceipt = GETPOSTINT('deliveryreceipt') ? 1 : 0;
360
361 if ($action == 'send' || $action == 'relance') {
362 $actionmsg2 = $langs->transnoentities('MailSentByTo', CMailFile::getValidAddress($from, 4, 0, 1), CMailFile::getValidAddress($sendto, 4, 0, 1));
363 /*if ($message) {
364 $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
365 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
366 if ($sendtocc) {
367 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
368 }
369 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
370 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
371 $actionmsg = dol_concatdesc($actionmsg, $message);
372 }*/
373 }
374
375 // Create form object
376 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
377 $formmail = new FormMail($db);
378 $formmail->trackid = $trackid; // $trackid must be defined
379
380 $attachedfiles = $formmail->get_attached_files();
381 $filepath = $attachedfiles['paths'];
382 $filename = $attachedfiles['names'];
383 $mimetype = $attachedfiles['mimes'];
384
385 // Make substitution in email content
386 $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
387 $substitutionarray['__EMAIL__'] = $sendto;
388 $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag=undefined&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY')."-undefined", 'md5').'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
389
390 $parameters = array('mode' => 'formemail');
391 complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
392
393 $subject = make_substitutions($subject, $substitutionarray);
394 $message = make_substitutions($message, $substitutionarray);
395
396 if (is_object($object) && method_exists($object, 'makeSubstitution')) {
397 $subject = $object->makeSubstitution($subject);
398 $message = $object->makeSubstitution($message);
399 }
400
401 // Send mail (substitutionarray must be done just before this)
402 if (empty($sendcontext)) {
403 $sendcontext = 'standard';
404 }
405 $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext, '', $upload_dir_tmp);
406
407 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
408 setEventMessages($mailfile->error, $mailfile->errors, 'errors');
409 $action = 'presend';
410 } else {
411 $result = $mailfile->sendfile();
412 if ($result) {
413 // Initialisation of datas of object to call trigger
414 if (is_object($object)) {
415 if (empty($actiontypecode)) {
416 $actiontypecode = 'AC_OTH_AUTO'; // Event inserted into agenda automatically
417 }
418
419 $object->socid = $sendtosocid; // To link to a company
420 $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
421 $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
422 $object->actionmsg = $message; // Long text
423 $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentByTo')...);
424 if (getDolGlobalString('MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT')) {
425 $object->actionmsg2 = $subject; // Short text
426 }
427
428 $object->trackid = $trackid;
429 $object->fk_element = $object->id;
430 $object->elementtype = $object->element;
431 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
432 $object->attachedfiles = $attachedfiles;
433 }
434 if (is_array($sendtouserid) && count($sendtouserid) > 0 && getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
435 $object->sendtouserid = $sendtouserid;
436 }
437
438 $object->email_msgid = $mailfile->msgid; // @todo Set msgid into $mailfile after sending
439 $object->email_from = $from;
440 $object->email_subject = $subject;
441 $object->email_to = $sendto;
442 $object->email_tocc = $sendtocc;
443 $object->email_tobcc = $sendtobcc;
444 $object->email_subject = $subject;
445
446 // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated)
447 if (!empty($triggersendname) || !empty($trigger_name)) {
448 // Call trigger
449 $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user); // @phan-suppress-current-line PhanPossiblyUndeclaredGlobalVariable
450 if ($result < 0) {
451 $error++;
452 }
453 // End call triggers
454 if ($error) {
455 setEventMessages($object->error, $object->errors, 'errors');
456 }
457 }
458 // End call of triggers
459 }
460
461 // Redirect here
462 // This avoid sending mail twice if going out and then back to page
463 $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
464 setEventMessages($mesg, null, 'mesgs');
465
466 $moreparam = '';
467 if (isset($paramval2)) { // @phan-var-suppress-current-line PhanPluginUndeclaredVariableIsset
468 // @phan-var-suppress-next-line PhanUndeclaredGlobalVariable
469 $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
470 }
471 header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ?? 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
472 exit;
473 } else {
474 $langs->load("other");
475 $mesg = '<div class="error">';
476 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
477 $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
478 if (!empty($mailfile->error)) {
479 $mesg .= '<br>'.$mailfile->error;
480 }
481 if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
482 $mesg .= '<br>'.implode('<br>', $mailfile->errors);
483 }
484 } else {
485 $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
486 if (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
487 $mesg .= '<br>Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
488 } else {
489 $mesg .= '<br>Unknown Error, please refer to your administrator';
490 }
491 }
492 $mesg .= '</div>';
493
494 setEventMessages($mesg, null, 'warnings');
495 $action = 'presend';
496 }
497 }
498 } else {
499 $langs->load("errors");
500 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
501 dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
502 $action = 'presend';
503 }
504 } else {
505 $langs->load("errors");
506 setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors');
507 dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
508 $action = 'presend';
509 }
510}
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Class to manage contact/addresses.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTestIndexation='')
Get and save an upload file (for example after submitting a new file a mail form).
dol_remove_file_process($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid='')
Remove an uploaded file (for example after submitting a new file a mail form).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.