dolibarr  13.0.2
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 {
38  $trackid = GETPOST('trackid', 'aZ09');
39 
40  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
41 
42  // Set tmp user directory
43  $vardir = $conf->user->dir_output."/".$user->id;
44  $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
45 
46  dol_add_file_process($upload_dir_tmp, 1, 0, 'addedfile', '', null, $trackid, 0);
47  $action = 'presend';
48 }
49 
50 /*
51  * Remove file in email form
52  */
53 if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
54 {
55  $trackid = GETPOST('trackid', 'aZ09');
56 
57  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
58 
59  // Set tmp user directory
60  $vardir = $conf->user->dir_output."/".$user->id;
61  $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
62 
63  // 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"
64  // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
65  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
66  $action = 'presend';
67 }
68 
69 /*
70  * Remove all files in email form
71  */
72 if (GETPOST('removAll', 'alpha'))
73 {
74  $trackid = GETPOST('trackid', 'aZ09');
75 
76  $listofpaths = array();
77  $listofnames = array();
78  $listofmimes = array();
79  $keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
80  if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
81  if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
82  if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
83 
84  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
85  $formmail = new FormMail($db);
86  $formmail->trackid = $trackid;
87 
88  foreach ($listofpaths as $key => $value)
89  {
90  $pathtodelete = $value;
91  $filetodelete = $listofnames[$key];
92  $result = dol_delete_file($pathtodelete, 1); // Delete uploded Files
93 
94  $langs->load("other");
95  setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
96 
97  $formmail->remove_attached_files($key); // Update Session
98  }
99 }
100 
101 /*
102  * Send mail
103  */
104 if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected'])
105 {
106  if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09');
107 
108  $subject = ''; $actionmsg = ''; $actionmsg2 = '';
109 
110  $langs->load('mails');
111 
112  if (is_object($object))
113  {
114  $result = $object->fetch($id);
115 
116  $sendtosocid = 0; // Id of related thirdparty
117  if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact')))
118  {
119  $resultthirdparty = $object->fetch_thirdparty();
120  $thirdparty = $object->thirdparty;
121  if (is_object($thirdparty)) $sendtosocid = $thirdparty->id;
122  } elseif ($object->element == 'member' || $object->element == 'user')
123  {
124  $thirdparty = $object;
125  if ($object->socid > 0) $sendtosocid = $object->socid;
126  } elseif ($object->element == 'expensereport')
127  {
128  $tmpuser = new User($db);
129  $tmpuser->fetch($object->fk_user_author);
130  $thirdparty = $tmpuser;
131  if ($object->socid > 0) $sendtosocid = $object->socid;
132  } elseif ($object->element == 'societe')
133  {
134  $thirdparty = $object;
135  if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
136  } elseif ($object->element == 'contact')
137  {
138  $contact = $object;
139  if ($contact->id > 0) {
140  $contact->fetch_thirdparty();
141  $thirdparty = $contact->thirdparty;
142  if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
143  }
144  } else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
145 
146  if (is_object($hookmanager))
147  {
148  $parameters = array();
149  $reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
150  }
151  } else {
152  $thirdparty = $mysoc;
153  }
154 
155  if ($result > 0)
156  {
157  $sendto = '';
158  $sendtocc = '';
159  $sendtobcc = '';
160  $sendtoid = array();
161  $sendtouserid = array();
162  $sendtoccuserid = array();
163 
164  // Define $sendto
165  $receiver = $_POST['receiver'];
166  if (!is_array($receiver))
167  {
168  if ($receiver == '-1') $receiver = array();
169  else $receiver = array($receiver);
170  }
171 
172  $tmparray = array();
173  if (trim($_POST['sendto']))
174  {
175  // Recipients are provided into free text
176  $tmparray[] = trim($_POST['sendto']);
177  }
178 
179  if (count($receiver) > 0)
180  {
181  // Recipient was provided from combo list
182  foreach ($receiver as $key=>$val)
183  {
184  if ($val == 'thirdparty') // Key selected means current third party ('thirdparty' may be used for current member or current user too)
185  {
186  $tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>';
187  }
188  elseif ($val == 'contact') // Key selected means current contact
189  {
190  $tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>';
191  $sendtoid[] = $contact->id;
192  } elseif ($val) // $val is the Id of a contact
193  {
194  $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
195  $sendtoid[] = ((int) $val);
196  }
197  }
198  }
199 
200  if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
201  {
202  $receiveruser = $_POST['receiveruser'];
203  if (is_array($receiveruser) && count($receiveruser) > 0)
204  {
205  $fuserdest = new User($db);
206  foreach ($receiveruser as $key=>$val)
207  {
208  $tmparray[] = $fuserdest->user_get_property($val, 'email');
209  $sendtouserid[] = $val;
210  }
211  }
212  }
213 
214  $sendto = implode(',', $tmparray);
215 
216  // Define $sendtocc
217  $receivercc = $_POST['receivercc'];
218  if (!is_array($receivercc))
219  {
220  if ($receivercc == '-1') $receivercc = array();
221  else $receivercc = array($receivercc);
222  }
223  $tmparray = array();
224  if (trim($_POST['sendtocc']))
225  {
226  $tmparray[] = trim($_POST['sendtocc']);
227  }
228  if (count($receivercc) > 0)
229  {
230  foreach ($receivercc as $key=>$val)
231  {
232  // Recipient was provided from combo list
233  if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too)
234  {
235  $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
236  }
237  // Recipient was provided from combo list
238  elseif ($val == 'contact') // Key selected means current contact
239  {
240  $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
241  //$sendtoid[] = $contact->id; TODO Add also id of contact in CC ?
242  } elseif ($val) // $val is the Id of a contact
243  {
244  $tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
245  //$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ?
246  }
247  }
248  }
249  if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
250  $receiverccuser = $_POST['receiverccuser'];
251 
252  if (is_array($receiverccuser) && count($receiverccuser) > 0)
253  {
254  $fuserdest = new User($db);
255  foreach ($receiverccuser as $key=>$val)
256  {
257  $tmparray[] = $fuserdest->user_get_property($val, 'email');
258  $sendtoccuserid[] = $val;
259  }
260  }
261  }
262  $sendtocc = implode(',', $tmparray);
263 
264  if (dol_strlen($sendto))
265  {
266  // Define $urlwithroot
267  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
268  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
269  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
270 
271  require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
272 
273  $langs->load("commercial");
274 
275  $reg = array();
276  $fromtype = GETPOST('fromtype', 'alpha');
277  if ($fromtype === 'robot') {
278  $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
279  } elseif ($fromtype === 'user') {
280  $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")).' <'.$user->email.'>';
281  } elseif ($fromtype === 'company') {
282  $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
283  } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
284  $tmp = explode(',', $user->email_aliases);
285  $from = trim($tmp[($reg[1] - 1)]);
286  } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
287  $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
288  $from = trim($tmp[($reg[1] - 1)]);
289  } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
290  $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
291  $sql .= ' WHERE rowid = '.(int) $reg[1];
292  $resql = $db->query($sql);
293  $obj = $db->fetch_object($resql);
294  if ($obj)
295  {
296  $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
297  }
298  } else {
299  $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")).' <'.$_POST['frommail'].'>';
300  }
301 
302  $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")).' <'.$_POST['replytomail'].'>';
303  $message = GETPOST('message', 'restricthtml');
304  $subject = GETPOST('subject', 'restricthtml');
305 
306  // Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
307  // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
308  // become
309  // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
310  $message = preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
311 
312  $sendtobcc = GETPOST('sendtoccc');
313  // Autocomplete the $sendtobcc
314  // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
315  if (!empty($autocopy))
316  {
317  $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
318  }
319 
320  $deliveryreceipt = $_POST['deliveryreceipt'];
321 
322  if ($action == 'send' || $action == 'relance')
323  {
324  $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('at').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
325  if ($message)
326  {
327  $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
328  $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
329  if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
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  // Feature to push mail sent into Sent folder
347  /* This code must be now included into the hook mail, method sendMailAfter
348  if (! empty($conf->dolimail->enabled))
349  {
350  $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
351  if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
352  else
353  {
354  $mbid = $mailfromid[1];
355 
356  // IMAP Postbox
357  $mailboxconfig = new IMAP($db);
358  $mailboxconfig->fetch($mbid);
359  if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
360 
361  $mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox;
362  $mailboxconfig->userfolder_fetch();
363 
364  if ($mailboxconfig->mailbox_save_sent_mails == 1)
365  {
366 
367  $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key);
368  if (!$folder) $folder = "Sent"; // Default Sent folder
369 
370  $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
371  if (false === $mailboxconfig->mbox)
372  {
373  $info = false;
374  $err = $langs->trans('Error3_Imap_Connection_Error');
375  setEventMessages($err,$mailboxconfig->element, null, 'errors');
376  }
377  else
378  {
379  $mailboxconfig->mailboxid=$_POST['frommail'];
380  $mailboxconfig->foldername=$folder;
381  $from = $mailfromid[0] . $mailfromid[2];
382  $imap=1;
383  }
384 
385  }
386  }
387  }
388  */
389 
390  // Make substitution in email content
391  $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
392  $substitutionarray['__EMAIL__'] = $sendto;
393  $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '';
394 
395  $parameters = array('mode'=>'formemail');
396  complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
397 
398  $subject = make_substitutions($subject, $substitutionarray);
399  $message = make_substitutions($message, $substitutionarray);
400 
401  if (method_exists($object, 'makeSubstitution'))
402  {
403  $subject = $object->makeSubstitution($subject);
404  $message = $object->makeSubstitution($message);
405  }
406 
407  // Send mail (substitutionarray must be done just before this)
408  if (empty($sendcontext)) $sendcontext = 'standard';
409  $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
410 
411  if ($mailfile->error)
412  {
413  setEventMessages($mailfile->error, $mailfile->errors, 'errors');
414  $action = 'presend';
415  } else {
416  $result = $mailfile->sendfile();
417  if ($result)
418  {
419  // Initialisation of datas of object to call trigger
420  if (is_object($object))
421  {
422  if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
423 
424  $object->socid = $sendtosocid; // To link to a company
425  $object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
426  $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
427  $object->actionmsg = $actionmsg; // Long text (@todo Replace this with $message, we already have details of email in dedicated properties)
428  $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
429 
430  $object->trackid = $trackid;
431  $object->fk_element = $object->id;
432  $object->elementtype = $object->element;
433  if (is_array($attachedfiles) && count($attachedfiles) > 0) {
434  $object->attachedfiles = $attachedfiles;
435  }
436  if (is_array($sendtouserid) && count($sendtouserid) > 0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
437  $object->sendtouserid = $sendtouserid;
438  }
439 
440  $object->email_msgid = $mailfile->msgid; // @todo Set msgid into $mailfile after sending
441  $object->email_from = $from;
442  $object->email_subject = $subject;
443  $object->email_to = $sendto;
444  $object->email_tocc = $sendtocc;
445  $object->email_tobcc = $sendtobcc;
446  $object->email_subject = $subject;
447  $object->email_msgid = $mailfile->msgid;
448 
449  // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated)
450  if (!empty($triggersendname) || !empty($trigger_name))
451  {
452  // Call trigger
453  $result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user);
454  if ($result < 0) $error++;
455  // End call triggers
456 
457  if ($error) {
458  setEventMessages($object->error, $object->errors, 'errors');
459  }
460  }
461  // End call of triggers
462  }
463 
464  // Redirect here
465  // This avoid sending mail twice if going out and then back to page
466  $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
467  setEventMessages($mesg, null, 'mesgs');
468 
469  $moreparam = '';
470  if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
471  header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
472  exit;
473  } else {
474  $langs->load("other");
475  $mesg = '<div class="error">';
476  if ($mailfile->error) {
477  $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
478  $mesg .= '<br>'.$mailfile->error;
479  } else {
480  $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
481  if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
482  $mesg .= '<br>Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
483  } else {
484  $mesg .= '<br>Unkown Error, please refers to your administrator';
485  }
486  }
487  $mesg .= '</div>';
488 
489  setEventMessages($mesg, null, 'warnings');
490  $action = 'presend';
491  }
492  }
493  } else {
494  $langs->load("errors");
495  setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
496  dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
497  $action = 'presend';
498  }
499  } else {
500  $langs->load("errors");
501  setEventMessages($langs->trans('ErrorFailedToReadObject', $object->element), null, 'errors');
502  dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
503  $action = 'presend';
504  }
505 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Classe permettant la generation du formulaire html d&#39;envoi de mail unitaire Usage: $formail = new For...
Class to manage Dolibarr users.
Definition: user.class.php:44
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_string_nospecial($str, $newstr= '_', $badcharstoreplace= '')
Clean a string from all punctuation characters to use it as a ref or login.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile-&gt;sendfile();.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
Definition: files.lib.php:1144
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:1689
print $_SERVER["PHP_SELF"]
Edit parameters.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=&gt;newva...
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:1528
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 &quot;subst...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...