dolibarr 20.0.4
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 && $object->element == 'project' && empty($object->socid)) { // $val is the Id of a contact
212 $contact = new Contact($db);
213 $ret = $contact->fetch((int) $val);
214 if ($ret > 0 && !empty($contact->socid)) {
215 $thirdparty = new Societe($db);
216 $thirdparty->fetch($contact->socid);
217 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
218 $sendtoid[] = ((int) $val);
219 }
220 } elseif ($val) { // $val is the Id of a contact
221 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
222 $sendtoid[] = ((int) $val);
223 }
224 }
225 }
226
227 if (getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
228 $receiveruser = GETPOST('receiveruser', 'alphawithlgt');
229 if (is_array($receiveruser) && count($receiveruser) > 0) {
230 $fuserdest = new User($db);
231 foreach ($receiveruser as $key => $val) {
232 $tmparray[] = $fuserdest->user_get_property($val, 'email');
233 $sendtouserid[] = $val;
234 }
235 }
236 }
237
238 $sendto = implode(',', $tmparray);
239
240 // Define $sendtocc
241 $receivercc = GETPOST('receivercc', 'alphawithlgt');
242 if (!is_array($receivercc)) {
243 if ($receivercc == '-1') {
244 $receivercc = array();
245 } else {
246 $receivercc = array($receivercc);
247 }
248 }
249 $tmparray = array();
250 if (trim(GETPOST('sendtocc', 'alphawithlgt'))) {
251 $tmparray[] = trim(GETPOST('sendtocc', 'alphawithlgt'));
252 }
253 if (count($receivercc) > 0) {
254 foreach ($receivercc as $key => $val) {
255 if ($val == 'thirdparty') { // Key selected means current thirdparty (may be usd for current member or current user too)
256 // Recipient was provided from combo list
257 $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
258 } elseif ($val == 'contact') { // Key selected means current contact
259 // Recipient was provided from combo list
260 $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
261 //$sendtoid[] = $contact->id; TODO Add also id of contact in CC ?
262 } elseif ($val) { // $val is the Id of a contact
263 $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
264 //$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ?
265 }
266 }
267 }
268 if (getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
269 $receiverccuser = GETPOST('receiverccuser', 'alphawithlgt');
270
271 if (is_array($receiverccuser) && count($receiverccuser) > 0) {
272 $fuserdest = new User($db);
273 foreach ($receiverccuser as $key => $val) {
274 $tmparray[] = $fuserdest->user_get_property($val, 'email');
275 $sendtoccuserid[] = $val;
276 }
277 }
278 }
279 $sendtocc = implode(',', $tmparray);
280
281 if (dol_strlen($sendto)) {
282 // Define $urlwithroot
283 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
284 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
285 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
286
287 require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
288
289 $langs->load("commercial");
290
291 $reg = array();
292 $fromtype = GETPOST('fromtype', 'alpha');
293 if ($fromtype === 'robot') {
294 $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <' . getDolGlobalString('MAIN_MAIL_EMAIL_FROM').'>';
295 } elseif ($fromtype === 'user') {
296 $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
297 } elseif ($fromtype === 'company') {
298 $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>';
299 } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
300 $tmp = explode(',', $user->email_aliases);
301 $from = trim($tmp[($reg[1] - 1)]);
302 } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
303 $tmp = explode(',', getDolGlobalString('MAIN_INFO_SOCIETE_MAIL_ALIASES'));
304 $from = trim($tmp[($reg[1] - 1)]);
305 } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
306 $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
307 $sql .= ' WHERE rowid = '.(int) $reg[1];
308 $resql = $db->query($sql);
309 $obj = $db->fetch_object($resql);
310 if ($obj) {
311 $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
312 }
313 } elseif (preg_match('/from_template_(\d+)/', $fromtype, $reg)) {
314 $sql = 'SELECT rowid, email_from FROM '.MAIN_DB_PREFIX.'c_email_templates';
315 $sql .= ' WHERE rowid = '.(int) $reg[1];
316 $resql = $db->query($sql);
317 $obj = $db->fetch_object($resql);
318 if ($obj) {
319 $from = $obj->email_from;
320 }
321 } else {
322 $from = dol_string_nospecial(GETPOST('fromname'), ' ', array(",")).' <'.GETPOST('frommail').'>';
323 }
324
325 $replyto = dol_string_nospecial(GETPOST('replytoname'), ' ', array(",")).' <'.GETPOST('replytomail').'>';
326
327 $message = GETPOST('message', 'restricthtml');
328 $subject = GETPOST('subject', 'restricthtml');
329
330 // Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
331 // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
332 // become
333 // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
334 $message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
335
336 $sendtobcc = GETPOST('sendtoccc', 'alphawithlgt');
337 // Autocomplete the $sendtobcc
338 // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
339 if (!empty($autocopy)) {
340 $sendtobcc .= (getDolGlobalString($autocopy) ? (($sendtobcc ? ", " : "") . getDolGlobalString($autocopy)) : '');
341 }
342
343 $deliveryreceipt = GETPOST('deliveryreceipt');
344
345 if ($action == 'send' || $action == 'relance') {
346 $actionmsg2 = $langs->transnoentities('MailSentByTo', CMailFile::getValidAddress($from, 4, 0, 1), CMailFile::getValidAddress($sendto, 4, 0, 1));
347 /*if ($message) {
348 $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
349 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
350 if ($sendtocc) {
351 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
352 }
353 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
354 $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
355 $actionmsg = dol_concatdesc($actionmsg, $message);
356 }*/
357 }
358
359 // Create form object
360 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
361 $formmail = new FormMail($db);
362 $formmail->trackid = $trackid; // $trackid must be defined
363
364 $attachedfiles = $formmail->get_attached_files();
365 $filepath = $attachedfiles['paths'];
366 $filename = $attachedfiles['names'];
367 $mimetype = $attachedfiles['mimes'];
368
369 // Make substitution in email content
370 $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
371 $substitutionarray['__EMAIL__'] = $sendto;
372 $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"/>' : '';
373
374 $parameters = array('mode' => 'formemail');
375 complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
376
377 $subject = make_substitutions($subject, $substitutionarray);
378 $message = make_substitutions($message, $substitutionarray);
379
380 if (is_object($object) && method_exists($object, 'makeSubstitution')) {
381 $subject = $object->makeSubstitution($subject);
382 $message = $object->makeSubstitution($message);
383 }
384
385 // Send mail (substitutionarray must be done just before this)
386 if (empty($sendcontext)) {
387 $sendcontext = 'standard';
388 }
389 $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext, '', $upload_dir_tmp);
390
391 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
392 setEventMessages($mailfile->error, $mailfile->errors, 'errors');
393 $action = 'presend';
394 } else {
395 $result = $mailfile->sendfile();
396 if ($result) {
397 // Initialisation of datas of object to call trigger
398 if (is_object($object)) {
399 if (empty($actiontypecode)) {
400 $actiontypecode = 'AC_OTH_AUTO'; // Event inserted into agenda automatically
401 }
402
403 $object->socid = $sendtosocid; // To link to a company
404 $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
405 $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
406 $object->actionmsg = $message; // Long text
407 $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentByTo')...);
408 if (getDolGlobalString('MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT')) {
409 $object->actionmsg2 = $subject; // Short text
410 }
411
412 $object->trackid = $trackid;
413 $object->fk_element = $object->id;
414 $object->elementtype = $object->element;
415 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
416 $object->attachedfiles = $attachedfiles;
417 }
418 if (is_array($sendtouserid) && count($sendtouserid) > 0 && getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
419 $object->sendtouserid = $sendtouserid;
420 }
421
422 $object->email_msgid = $mailfile->msgid; // @todo Set msgid into $mailfile after sending
423 $object->email_from = $from;
424 $object->email_subject = $subject;
425 $object->email_to = $sendto;
426 $object->email_tocc = $sendtocc;
427 $object->email_tobcc = $sendtobcc;
428 $object->email_subject = $subject;
429
430 // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated)
431 if (!empty($triggersendname) || !empty($trigger_name)) {
432 // Call trigger
433 $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user);
434 if ($result < 0) {
435 $error++;
436 }
437 // End call triggers
438 if ($error) {
439 setEventMessages($object->error, $object->errors, 'errors');
440 }
441 }
442 // End call of triggers
443 }
444
445 // Redirect here
446 // This avoid sending mail twice if going out and then back to page
447 $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
448 setEventMessages($mesg, null, 'mesgs');
449
450 $moreparam = '';
451 if (isset($paramval2)) {
452 $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
453 }
454 header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ?? 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
455 exit;
456 } else {
457 $langs->load("other");
458 $mesg = '<div class="error">';
459 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
460 $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
461 if (!empty($mailfile->error)) {
462 $mesg .= '<br>'.$mailfile->error;
463 }
464 if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
465 $mesg .= '<br>'.implode('<br>', $mailfile->errors);
466 }
467 } else {
468 $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
469 if (getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
470 $mesg .= '<br>Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
471 } else {
472 $mesg .= '<br>Unknown Error, please refer to your administrator';
473 }
474 }
475 $mesg .= '</div>';
476
477 setEventMessages($mesg, null, 'warnings');
478 $action = 'presend';
479 }
480 }
481 } else {
482 $langs->load("errors");
483 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
484 dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
485 $action = 'presend';
486 }
487 } else {
488 $langs->load("errors");
489 setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors');
490 dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
491 $action = 'presend';
492 }
493}
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 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)
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.