49@phan-var-force Societe $mysoc
50@phan-var-force CommonObject $object
51@phan-var-force int $error
58if (
GETPOST(
'addfile',
'alpha')) {
59 $trackid =
GETPOST(
'trackid',
'aZ09');
61 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
64 $vardir =
$conf->user->dir_output.
"/".$user->id;
65 $upload_dir_tmp = $vardir.
'/temp';
75 $trackid =
GETPOST(
'trackid',
'aZ09');
77 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
80 $vardir =
$conf->user->dir_output.
"/".$user->id;
81 $upload_dir_tmp = $vardir.
'/temp';
92if (
GETPOST(
'removeAll',
'alpha')) {
93 $trackid =
GETPOST(
'trackid',
'aZ09');
95 $listofpaths = array();
96 $listofnames = array();
97 $listofmimes = array();
98 $keytoavoidconflict = empty($trackid) ?
'' :
'-'.$trackid;
99 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
100 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
102 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
103 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
105 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
106 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
109 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
111 $formmail->trackid = $trackid;
113 foreach ($listofpaths as $key => $value) {
114 $pathtodelete = $value;
115 $filetodelete = $listofnames[$key];
118 $langs->load(
"other");
119 setEventMessages($langs->trans(
"FileWasRemoved", $filetodelete),
null,
'mesgs');
121 $formmail->remove_attached_files($key);
128if (($action ==
'send' || $action ==
'relance') && !
GETPOST(
'addfile') && !
GETPOST(
'removeAll') && !
GETPOST(
'removedfile') && !
GETPOST(
'cancel') && !
GETPOST(
'modelselected')) {
129 if (empty($trackid)) {
130 $trackid =
GETPOST(
'trackid',
'aZ09');
134 $vardir =
$conf->user->dir_output.
"/".$user->id;
135 $upload_dir_tmp = $vardir.
'/temp';
144 $langs->load(
'mails');
151 if (method_exists(
$object,
"fetch_thirdparty") && !in_array(
$object->element, array(
'member',
'user',
'expensereport',
'societe',
'contact'))) {
153 $thirdparty =
$object->thirdparty;
154 if (is_object($thirdparty)) {
155 $sendtosocid = $thirdparty->id;
157 } elseif (
$object->element ==
'member' ||
$object->element ==
'user') {
158 '@phan-var-force Adherent|User $object';
163 } elseif (
$object->element ==
'expensereport') {
164 '@phan-var-force ExpenseReport $object';
166 $tmpuser->fetch(
$object->fk_user_author);
167 $thirdparty = $tmpuser;
171 } elseif (
$object->element ==
'societe') {
172 '@phan-var-force Societe $object';
174 if (is_object($thirdparty) && $thirdparty->id > 0) {
175 $sendtosocid = $thirdparty->id;
177 } elseif (
$object->element ==
'contact') {
178 '@phan-var-force Contact $object';
180 if ($contact->id > 0) {
181 $contact->fetch_thirdparty();
182 $thirdparty = $contact->thirdparty;
183 if (is_object($thirdparty) && $thirdparty->id > 0) {
184 $sendtosocid = $thirdparty->id;
188 dol_print_error(
null,
"Use actions_sendmails.in.php for an element/object '".
$object->element.
"' that is not supported");
191 if (is_object($hookmanager)) {
192 $parameters = array();
193 $reshook = $hookmanager->executeHooks(
'initSendToSocid', $parameters,
$object, $action);
206 $sendtouserid = array();
207 $sendtoccuserid = array();
210 $receiver =
GETPOST(
'receiver',
'alphawithlgt');
211 if (!is_array($receiver)) {
212 if ($receiver ==
'-1') {
215 $receiver = array($receiver);
220 if (trim(
GETPOST(
'sendto',
'alphawithlgt'))) {
222 $tmparray[] = trim(
GETPOST(
'sendto',
'alphawithlgt'));
225 if (trim(
GETPOST(
'tomail',
'alphawithlgt'))) {
227 $tmparray[] = trim(
GETPOST(
'tomail',
'alphawithlgt'));
230 if (count($receiver) > 0) {
232 foreach ($receiver as $key => $val) {
233 if ($val ==
'thirdparty') {
234 $thirdpartyEmail = (is_object($thirdparty) && !empty($thirdparty->email)) ? (
string) $thirdparty->email :
'';
235 if ($thirdpartyEmail !==
'') {
236 $thirdpartyLabel =
'';
237 if (is_object($thirdparty)) {
238 if (method_exists($thirdparty,
'getFullName')) {
239 $thirdpartyLabel = (
string) $thirdparty->getFullName($langs);
240 } elseif (!empty($thirdparty->name)) {
241 $thirdpartyLabel = (
string) $thirdparty->name;
242 } elseif (!empty($thirdparty->nom)) {
243 $thirdpartyLabel = (
string) $thirdparty->nom;
246 if ($thirdpartyLabel !==
'') {
247 $tmparray[] =
dol_string_nospecial($thirdpartyLabel,
' ', array(
",")).
' <'.$thirdpartyEmail.
'>';
249 $tmparray[] = $thirdpartyEmail;
252 } elseif ($val ==
'contact') {
253 $tmparray[] =
dol_string_nospecial($contact->getFullName($langs),
' ', array(
",")).
' <'.$contact->email.
'>';
254 $sendtoid[] = $contact->id;
255 } elseif ($val &&
$object->element ==
'project' && empty(
$object->socid)) {
257 $ret = $contact->fetch((
int) $val);
258 if ($ret > 0 && !empty($contact->socid)) {
260 $thirdparty->fetch($contact->socid);
261 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
262 $sendtoid[] = ((int) $val);
265 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
266 $sendtoid[] = ((int) $val);
272 $receiveruser =
GETPOST(
'receiveruser',
'alphawithlgt');
273 if (is_array($receiveruser) && count($receiveruser) > 0) {
275 foreach ($receiveruser as $key => $val) {
276 $tmparray[] = $fuserdest->user_get_property($val,
'email');
277 $sendtouserid[] = $val;
282 $sendto = implode(
',', $tmparray);
285 $receivercc =
GETPOST(
'receivercc',
'alphawithlgt');
286 if (!is_array($receivercc)) {
287 if ($receivercc ==
'-1') {
288 $receivercc = array();
290 $receivercc = array($receivercc);
294 if (trim(
GETPOST(
'sendtocc',
'alphawithlgt'))) {
295 $tmparray[] = trim(
GETPOST(
'sendtocc',
'alphawithlgt'));
297 if (count($receivercc) > 0) {
298 foreach ($receivercc as $key => $val) {
299 if ($val ==
'thirdparty') {
301 $tmparray[] =
dol_string_nospecial((
string) $thirdparty->name,
' ', array(
",")).
' <'.$thirdparty->email.
'>';
302 } elseif ($val ==
'contact') {
304 $tmparray[] =
dol_string_nospecial((
string) $contact->name,
' ', array(
",")).
' <'.$contact->email.
'>';
307 $tmparray[] = $thirdparty->contact_get_property((
int) $val,
'email');
313 $receiverccuser =
GETPOST(
'receiverccuser',
'alphawithlgt');
315 if (is_array($receiverccuser) && count($receiverccuser) > 0) {
317 foreach ($receiverccuser as $key => $val) {
318 $tmparray[] = $fuserdest->user_get_property($val,
'email');
319 $sendtoccuserid[] = $val;
323 $sendtocc = implode(
',', $tmparray);
328 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
331 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
333 $langs->load(
"commercial");
336 $fromtype =
GETPOST(
'fromtype',
'alpha');
337 $emailsendersignature =
'';
338 if ($fromtype ===
'robot') {
340 } elseif ($fromtype ===
'user') {
341 $from =
dol_string_nospecial($user->getFullName($langs),
' ', array(
",")).
' <'.$user->email.
'>';
342 } elseif ($fromtype ===
'company') {
344 } elseif (preg_match(
'/global_aliases_(\d+)/', $fromtype, $reg)) {
346 $from = trim($tmp[((
int) $reg[1] - 1)]);
347 } elseif (preg_match(
'/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
348 $sql =
'SELECT rowid, label, email, signature FROM '.MAIN_DB_PREFIX.
'c_email_senderprofile';
349 $sql .=
' WHERE rowid = '.(int) $reg[1];
350 $resql =
$db->query($sql);
351 $obj =
$db->fetch_object($resql);
354 $emailsendersignature = $obj->signature;
356 } elseif (preg_match(
'/from_template_(\d+)/', $fromtype, $reg)) {
357 $sql =
'SELECT rowid, email_from FROM '.MAIN_DB_PREFIX.
'c_email_templates';
358 $sql .=
' WHERE rowid = '.(int) $reg[1];
359 $resql =
$db->query($sql);
360 $obj =
$db->fetch_object($resql);
362 $from = $obj->email_from;
371 $replyto .= ($replyto ?
' ' :
'').
'<'.
GETPOST(
'replytomail').
'>';
374 $message =
GETPOST(
'message',
'restricthtml');
375 $subject =
GETPOST(
'subject',
'restricthtml');
381 $message = preg_replace(
'/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/',
'\1'.$urlwithroot.
'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
383 $sendtobcc =
GETPOST(
'sendtoccc',
'alphawithlgt');
386 if (!empty($autocopy)) {
390 $deliveryreceipt =
GETPOSTINT(
'deliveryreceipt') ? 1 : 0;
392 if ($action ==
'send' || $action ==
'relance') {
407 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
409 $formmail->trackid = $trackid;
411 $attachedfiles = $formmail->get_attached_files();
412 $filepath = $attachedfiles[
'paths'];
413 $filename = $attachedfiles[
'names'];
414 $mimetype = $attachedfiles[
'mimes'];
417 $substitutionarray = getCommonSubstitutionArray($langs, 0,
null,
$object);
419 $substitutionarray[
'__SENDEREMAIL_SIGNATURE__'] = (empty($emailsendersignature) ? $user->signature : $emailsendersignature);
420 $substitutionarray[
'__EMAIL__'] = $sendto;
421 $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"/>' :
'';
423 $parameters = array(
'mode' =>
'formemail');
429 if (is_object(
$object) && method_exists(
$object,
'makeSubstitution')) {
430 $subject =
$object->makeSubstitution($subject);
431 $message =
$object->makeSubstitution($message);
435 if (empty($sendcontext)) {
436 $sendcontext =
'standard';
438 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1,
'',
'', $trackid,
'', $sendcontext, $replyto, $upload_dir_tmp);
440 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
444 $result = $mailfile->sendfile();
450 if (empty($actiontypecode)) {
451 $actiontypecode =
'AC_EMAIL';
456 $object->actiontypecode = $actiontypecode;
458 $object->actionmsg2 = $actionmsg2;
460 $object->actionmsg2 = $subject;
466 if (is_array($attachedfiles) && count($attachedfiles) > 0) {
467 $object->attachedfiles = $attachedfiles;
469 if (is_array($sendtouserid) && count($sendtouserid) > 0 &&
getDolGlobalString(
'MAIN_MAIL_ENABLED_USER_DEST_SELECT')) {
470 $object->sendtouserid = $sendtouserid;
474 $object->context[
'email_msgid'] = $mailfile->msgid;
475 $object->context[
'email_from'] = $from;
476 $object->context[
'email_subject'] = $subject;
477 $object->context[
'email_to'] = $sendto;
478 $object->context[
'email_tocc'] = $sendtocc;
479 $object->context[
'email_tobcc'] = $sendtobcc;
481 $object->email_msgid = $mailfile->msgid;
483 $object->email_subject = $subject;
485 $object->email_tocc = $sendtocc;
486 $object->email_tobcc = $sendtobcc;
489 if (!empty($triggersendname)) {
490 if ($triggersendname ==
'BILL_SENTBYMAIL' &&
$object instanceof
Facture) {
494 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"facture SET email_sent_counter = email_sent_counter + 1";
495 $sql .=
" WHERE rowid = ".((int)
$object->id);
497 $resql =
$db->query($sql);
499 $object->email_sent_counter += 1;
503 $result =
$object->call_trigger($triggersendname, $user);
522 $mesg = $langs->trans(
'MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
525 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?'.($paramname ??
'id').
'='.(is_object(
$object) ?
$object->id :
''));
528 $langs->load(
"other");
529 $mesg =
'<div class="error">';
530 if (!empty($mailfile->error) || !empty($mailfile->errors)) {
532 if (!empty($mailfile->error)) {
533 $mesg .=
'<br>'.$mailfile->error;
535 if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
536 $mesg .=
'<br>'.implode(
'<br>', $mailfile->errors);
541 $mesg .=
'<br>Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
543 $mesg .=
'<br>Unknown Error, please refer to your administrator';
553 $langs->load(
"errors");
554 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"MailTo")),
null,
'warnings');
555 dol_syslog(
'Try to send email with no recipient defined', LOG_WARNING);
559 $langs->load(
"errors");
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
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 invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
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_remove_file_process($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid='')
Remove an uploaded file (for example after submitting a new file a mail form).
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.