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