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