actions_sendmails.inc.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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 <http://www.gnu.org/licenses/>.
  17. * or see http://www.gnu.org/
  18. */
  19. /**
  20. * \file htdocs/core/actions_sendmails.inc.php
  21. * \brief Code for actions on sending mails from object page
  22. */
  23. // $mysoc must be defined
  24. // $id must be defined
  25. // $paramname may be defined
  26. // $autocopy may be defined (used to know the automatic BCC to add)
  27. // $trigger_name must be set (can be '')
  28. // $actiontypecode can be set
  29. // $object and $uobject may be defined
  30. /*
  31. * Add file in email form
  32. */
  33. if (GETPOST('addfile','alpha'))
  34. {
  35. $trackid = GETPOST('trackid','aZ09');
  36. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  37. // Set tmp user directory
  38. $vardir=$conf->user->dir_output."/".$user->id;
  39. $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
  40. dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0);
  41. $action='presend';
  42. }
  43. /*
  44. * Remove file in email form
  45. */
  46. if (! empty($_POST['removedfile']) && empty($_POST['removAll']))
  47. {
  48. $trackid = GETPOST('trackid','aZ09');
  49. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  50. // Set tmp user directory
  51. $vardir=$conf->user->dir_output."/".$user->id;
  52. $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
  53. // 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"
  54. // GETPOST('removedfile','alpha') is position of file into $_SESSION["listofpaths"...] array.
  55. 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
  56. $action='presend';
  57. }
  58. /*
  59. * Remove all files in email form
  60. */
  61. if (GETPOST('removAll','alpha'))
  62. {
  63. $trackid = GETPOST('trackid','aZ09');
  64. $listofpaths=array();
  65. $listofnames=array();
  66. $listofmimes=array();
  67. $keytoavoidconflict = empty($trackid)?'':'-'.$trackid;
  68. if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
  69. if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
  70. if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
  71. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  72. $formmail = new FormMail($db);
  73. $formmail->trackid = $trackid;
  74. foreach($listofpaths as $key => $value)
  75. {
  76. $pathtodelete = $value;
  77. $filetodelete = $listofnames[$key];
  78. $result = dol_delete_file($pathtodelete,1); // Delete uploded Files
  79. $langs->load("other");
  80. setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
  81. $formmail->remove_attached_files($key); // Update Session
  82. }
  83. }
  84. /*
  85. * Send mail
  86. */
  87. if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected'])
  88. {
  89. if (empty($trackid)) $trackid = GETPOST('trackid','aZ09');
  90. $subject='';$actionmsg='';$actionmsg2='';
  91. $langs->load('mails');
  92. if (is_object($object))
  93. {
  94. $result=$object->fetch($id);
  95. $sendtosocid=0; // Thirdparty on object
  96. if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport')))
  97. {
  98. $result=$object->fetch_thirdparty();
  99. if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok
  100. $thirdparty=$object->thirdparty;
  101. $sendtosocid=$thirdparty->id;
  102. }
  103. else if ($object->element == 'member' || $object->element == 'user')
  104. {
  105. $thirdparty=$object;
  106. if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
  107. }
  108. else if ($object->element == 'societe')
  109. {
  110. $thirdparty=$object;
  111. if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
  112. }
  113. else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported');
  114. if (is_object($hookmanager))
  115. {
  116. $parameters=array();
  117. $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  118. }
  119. }
  120. else $thirdparty = $mysoc;
  121. if ($result > 0)
  122. {
  123. $sendto='';
  124. $sendtocc='';
  125. $sendtobcc='';
  126. $sendtoid = array();
  127. $sendtouserid=array();
  128. $sendtoccuserid=array();
  129. // Define $sendto
  130. $receiver=$_POST['receiver'];
  131. if (! is_array($receiver))
  132. {
  133. if ($receiver == '-1') $receiver=array();
  134. else $receiver=array($receiver);
  135. }
  136. $tmparray=array();
  137. if (trim($_POST['sendto']))
  138. {
  139. // Recipients are provided into free text
  140. $tmparray[] = trim($_POST['sendto']);
  141. }
  142. if (count($receiver)>0)
  143. {
  144. foreach($receiver as $key=>$val)
  145. {
  146. // Recipient was provided from combo list
  147. if ($val == 'thirdparty') // Id of third party
  148. {
  149. $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
  150. }
  151. elseif ($val) // Id du contact
  152. {
  153. $tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
  154. $sendtoid[] = $val;
  155. }
  156. }
  157. }
  158. if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
  159. {
  160. $receiveruser=$_POST['receiveruser'];
  161. if (is_array($receiveruser) && count($receiveruser)>0)
  162. {
  163. $fuserdest = new User($db);
  164. foreach($receiveruser as $key=>$val)
  165. {
  166. $tmparray[] = $fuserdest->user_get_property($val,'email');
  167. $sendtouserid[] = $val;
  168. }
  169. }
  170. }
  171. $sendto=implode(',',$tmparray);
  172. // Define $sendtocc
  173. $receivercc=$_POST['receivercc'];
  174. if (! is_array($receivercc))
  175. {
  176. if ($receivercc == '-1') $receivercc=array();
  177. else $receivercc=array($receivercc);
  178. }
  179. $tmparray=array();
  180. if (trim($_POST['sendtocc']))
  181. {
  182. $tmparray[] = trim($_POST['sendtocc']);
  183. }
  184. if (count($receivercc) > 0)
  185. {
  186. foreach($receivercc as $key=>$val)
  187. {
  188. // Recipient was provided from combo list
  189. if ($val == 'thirdparty') // Id of third party
  190. {
  191. $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
  192. }
  193. elseif ($val) // Id du contact
  194. {
  195. $tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
  196. //$sendtoid[] = $val; TODO Add also id of contact in CC ?
  197. }
  198. }
  199. }
  200. if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
  201. $receiverccuser=$_POST['receiverccuser'];
  202. if (is_array($receiverccuser) && count($receiverccuser)>0)
  203. {
  204. $fuserdest = new User($db);
  205. foreach($receiverccuser as $key=>$val)
  206. {
  207. $tmparray[] = $fuserdest->user_get_property($val,'email');
  208. $sendtoccuserid[] = $val;
  209. }
  210. }
  211. }
  212. $sendtocc=implode(',',$tmparray);
  213. if (dol_strlen($sendto))
  214. {
  215. // Define $urlwithroot
  216. $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
  217. $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
  218. //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
  219. require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  220. $langs->load("commercial");
  221. $fromtype = GETPOST('fromtype','alpha');
  222. if ($fromtype === 'robot') {
  223. $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
  224. }
  225. elseif ($fromtype === 'user') {
  226. $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>';
  227. }
  228. elseif ($fromtype === 'company') {
  229. $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
  230. }
  231. elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) {
  232. $tmp=explode(',', $user->email_aliases);
  233. $from = trim($tmp[($reg[1] - 1)]);
  234. }
  235. elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
  236. $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
  237. $from = trim($tmp[($reg[1] - 1)]);
  238. }
  239. elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
  240. $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
  241. $resql = $db->query($sql);
  242. $obj = $db->fetch_object($resql);
  243. if ($obj)
  244. {
  245. $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
  246. }
  247. }
  248. else {
  249. $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>';
  250. }
  251. $replyto = dol_string_nospecial($_POST['replytoname'], ' ', array(",")). ' <' . $_POST['replytomail'].'>';
  252. $message = GETPOST('message','none');
  253. $subject = GETPOST('subject','none');
  254. // Make a change into HTML code to allow to include images from medias directory with an external reabable URL.
  255. // <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
  256. // become
  257. // <img alt="" src="'.$urlwithroot.'viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
  258. $message=preg_replace('/(<img.*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $message);
  259. $sendtobcc= GETPOST('sendtoccc');
  260. // Autocomplete the $sendtobcc
  261. // $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
  262. if (! empty($autocopy))
  263. {
  264. $sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc?", ":"").$conf->global->$autocopy));
  265. }
  266. $deliveryreceipt = $_POST['deliveryreceipt'];
  267. if ($action == 'send' || $action == 'relance')
  268. {
  269. $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1);
  270. if ($message)
  271. {
  272. $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
  273. $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
  274. if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
  275. $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
  276. $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
  277. $actionmsg = dol_concatdesc($actionmsg, $message);
  278. }
  279. }
  280. // Create form object
  281. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  282. $formmail = new FormMail($db);
  283. $formmail->trackid = $trackid; // $trackid must be defined
  284. $attachedfiles=$formmail->get_attached_files();
  285. $filepath = $attachedfiles['paths'];
  286. $filename = $attachedfiles['names'];
  287. $mimetype = $attachedfiles['mimes'];
  288. // Feature to push mail sent into Sent folder
  289. /* This code must be now included into the hook mail, method sendMailAfter
  290. if (! empty($conf->dolimail->enabled))
  291. {
  292. $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
  293. if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
  294. else
  295. {
  296. $mbid = $mailfromid[1];
  297. // IMAP Postbox
  298. $mailboxconfig = new IMAP($db);
  299. $mailboxconfig->fetch($mbid);
  300. if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
  301. $mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox;
  302. $mailboxconfig->userfolder_fetch();
  303. if ($mailboxconfig->mailbox_save_sent_mails == 1)
  304. {
  305. $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key);
  306. if (!$folder) $folder = "Sent"; // Default Sent folder
  307. $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
  308. if (false === $mailboxconfig->mbox)
  309. {
  310. $info = false;
  311. $err = $langs->trans('Error3_Imap_Connection_Error');
  312. setEventMessages($err,$mailboxconfig->element, null, 'errors');
  313. }
  314. else
  315. {
  316. $mailboxconfig->mailboxid=$_POST['frommail'];
  317. $mailboxconfig->foldername=$folder;
  318. $from = $mailfromid[0] . $mailfromid[2];
  319. $imap=1;
  320. }
  321. }
  322. }
  323. }
  324. */
  325. // Make substitution in email content
  326. $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object);
  327. $substitutionarray['__EMAIL__'] = $sendto;
  328. $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"/>':'';
  329. $parameters=array('mode'=>'formemail');
  330. complete_substitutions_array($substitutionarray, $langs, $object, $parameters);
  331. $subject=make_substitutions($subject, $substitutionarray);
  332. $message=make_substitutions($message, $substitutionarray);
  333. if (method_exists($object, 'makeSubstitution'))
  334. {
  335. $subject = $object->makeSubstitution($subject);
  336. $message = $object->makeSubstitution($message);
  337. }
  338. // Send mail (substitutionarray must be done just before this)
  339. if (empty($sendcontext)) $sendcontext = 'standard';
  340. $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext);
  341. if ($mailfile->error)
  342. {
  343. setEventMessages($mailfile->error, $mailfile->errors, 'errors');
  344. $action='presend';
  345. }
  346. else
  347. {
  348. $result=$mailfile->sendfile();
  349. if ($result)
  350. {
  351. // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required
  352. /*
  353. if (! empty($conf->dolimail->enabled))
  354. {
  355. $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ?
  356. if ($mid)
  357. {
  358. // set imap flag answered if it is an answered mail
  359. $dolimail=new DoliMail($db);
  360. $dolimail->id = $mid;
  361. $res=$dolimail->set_prop($user, 'answered',1);
  362. }
  363. if ($imap==1)
  364. {
  365. // write mail to IMAP Server
  366. $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile);
  367. if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs');
  368. else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings');
  369. }
  370. }*/
  371. // Initialisation of datas of object to call trigger
  372. if (is_object($object))
  373. {
  374. if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically
  375. $object->socid = $sendtosocid; // To link to a company
  376. $object->sendtoid = $sendtoid; // To link to contact addresses. This is an array.
  377. $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
  378. $object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
  379. $object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
  380. $object->trackid = $trackid;
  381. $object->fk_element = $object->id;
  382. $object->elementtype = $object->element;
  383. if (is_array($attachedfiles) && count($attachedfiles)>0) {
  384. $object->attachedfiles = $attachedfiles;
  385. }
  386. if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
  387. $object->sendtouserid = $sendtouserid;
  388. }
  389. $object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending
  390. $object->email_from = $from;
  391. $object->email_subject = $subject;
  392. $object->email_to = $sendto;
  393. $object->email_tocc = $sendtocc;
  394. $object->email_tobcc = $sendtobcc;
  395. $object->email_subject = $subject;
  396. $object->email_msgid = $mailfile->msgid;
  397. // Call of triggers
  398. if (! empty($trigger_name))
  399. {
  400. include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
  401. $interface=new Interfaces($db);
  402. $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
  403. if ($result < 0) {
  404. setEventMessages($interface->error, $interface->errors, 'errors');
  405. }
  406. }
  407. }
  408. // Redirect here
  409. // This avoid sending mail twice if going out and then back to page
  410. $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
  411. setEventMessages($mesg, null, 'mesgs');
  412. $moreparam='';
  413. if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2;
  414. header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam);
  415. exit;
  416. }
  417. else
  418. {
  419. $langs->load("other");
  420. $mesg='<div class="error">';
  421. if ($mailfile->error)
  422. {
  423. $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
  424. $mesg.='<br>'.$mailfile->error;
  425. }
  426. else
  427. {
  428. $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
  429. }
  430. $mesg.='</div>';
  431. setEventMessages($mesg, null, 'warnings');
  432. $action = 'presend';
  433. }
  434. }
  435. }
  436. else
  437. {
  438. $langs->load("errors");
  439. setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
  440. dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
  441. $action = 'presend';
  442. }
  443. }
  444. else
  445. {
  446. $langs->load("other");
  447. setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors');
  448. dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
  449. $action = 'presend';
  450. }
  451. }