html.formmail.class.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <?php
  2. /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  4. * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
  5. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/core/class/html.formmail.class.php
  22. * \ingroup core
  23. * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire
  24. */
  25. require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
  26. /**
  27. * Classe permettant la generation du formulaire html d'envoi de mail unitaire
  28. * Usage: $formail = new FormMail($db)
  29. * $formmail->proprietes=1 ou chaine ou tableau de valeurs
  30. * $formmail->show_form() affiche le formulaire
  31. */
  32. class FormMail extends Form
  33. {
  34. var $db;
  35. var $withform; // 1=Include HTML form tag and show submit button, 0=Do not include form tag and submit button, -1=Do not include form tag but include submit button
  36. var $fromname;
  37. var $frommail;
  38. var $replytoname;
  39. var $replytomail;
  40. var $toname;
  41. var $tomail;
  42. var $trackid;
  43. var $withsubstit; // Show substitution array
  44. var $withfrom;
  45. /**
  46. * @var int
  47. * @deprecated Fill withto with array before calling method.
  48. * @see withto
  49. */
  50. public $withtosocid;
  51. /**
  52. * @var int|int[]
  53. */
  54. public $withto; // Show recipient emails
  55. var $withtofree; // Show free text for recipient emails
  56. var $withtocc;
  57. var $withtoccc;
  58. var $withtopic;
  59. var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
  60. var $withbody;
  61. var $withfromreadonly;
  62. var $withreplytoreadonly;
  63. var $withtoreadonly;
  64. var $withtoccreadonly;
  65. var $withtocccreadonly;
  66. var $withtopicreadonly;
  67. var $withfilereadonly;
  68. var $withdeliveryreceipt;
  69. var $withcancel;
  70. var $withfckeditor;
  71. var $substit=array();
  72. var $param=array();
  73. var $error;
  74. public $lines_model;
  75. /**
  76. * Constructor
  77. *
  78. * @param DoliDB $db Database handler
  79. */
  80. function __construct($db)
  81. {
  82. $this->db = $db;
  83. $this->withform=1;
  84. $this->withfrom=1;
  85. $this->withto=1;
  86. $this->withtofree=1;
  87. $this->withtocc=1;
  88. $this->withtoccc=0;
  89. $this->witherrorsto=0;
  90. $this->withtopic=1;
  91. $this->withfile=0;
  92. $this->withbody=1;
  93. $this->withfromreadonly=1;
  94. $this->withreplytoreadonly=1;
  95. $this->withtoreadonly=0;
  96. $this->withtoccreadonly=0;
  97. $this->withtocccreadonly=0;
  98. $this->witherrorstoreadonly=0;
  99. $this->withtopicreadonly=0;
  100. $this->withfilereadonly=0;
  101. $this->withbodyreadonly=0;
  102. $this->withdeliveryreceiptreadonly=0;
  103. $this->withfckeditor=-1; // -1 = Auto
  104. return 1;
  105. }
  106. /**
  107. * Clear list of attached files in send mail form (also stored in session)
  108. *
  109. * @return void
  110. */
  111. function clear_attached_files()
  112. {
  113. global $conf,$user;
  114. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  115. // Set tmp user directory
  116. $vardir=$conf->user->dir_output."/".$user->id;
  117. $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
  118. if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
  119. $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
  120. unset($_SESSION["listofpaths".$keytoavoidconflict]);
  121. unset($_SESSION["listofnames".$keytoavoidconflict]);
  122. unset($_SESSION["listofmimes".$keytoavoidconflict]);
  123. }
  124. /**
  125. * Add a file into the list of attached files (stored in SECTION array)
  126. *
  127. * @param string $path Full absolute path on filesystem of file, including file name
  128. * @param string $file Only filename
  129. * @param string $type Mime type
  130. * @return void
  131. */
  132. function add_attached_files($path,$file,$type)
  133. {
  134. $listofpaths=array();
  135. $listofnames=array();
  136. $listofmimes=array();
  137. $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
  138. if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
  139. if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
  140. if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
  141. if (! in_array($file,$listofnames))
  142. {
  143. $listofpaths[]=$path;
  144. $listofnames[]=$file;
  145. $listofmimes[]=$type;
  146. $_SESSION["listofpaths".$keytoavoidconflict]=join(';',$listofpaths);
  147. $_SESSION["listofnames".$keytoavoidconflict]=join(';',$listofnames);
  148. $_SESSION["listofmimes".$keytoavoidconflict]=join(';',$listofmimes);
  149. }
  150. }
  151. /**
  152. * Remove a file from the list of attached files (stored in SECTION array)
  153. *
  154. * @param string $keytodelete Key in file array (0, 1, 2, ...)
  155. * @return void
  156. */
  157. function remove_attached_files($keytodelete)
  158. {
  159. $listofpaths=array();
  160. $listofnames=array();
  161. $listofmimes=array();
  162. $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
  163. if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
  164. if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
  165. if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
  166. if ($keytodelete >= 0)
  167. {
  168. unset ($listofpaths[$keytodelete]);
  169. unset ($listofnames[$keytodelete]);
  170. unset ($listofmimes[$keytodelete]);
  171. $_SESSION["listofpaths".$keytoavoidconflict]=join(';',$listofpaths);
  172. $_SESSION["listofnames".$keytoavoidconflict]=join(';',$listofnames);
  173. $_SESSION["listofmimes".$keytoavoidconflict]=join(';',$listofmimes);
  174. //var_dump($_SESSION['listofpaths']);
  175. }
  176. }
  177. /**
  178. * Return list of attached files (stored in SECTION array)
  179. *
  180. * @return array array('paths'=> ,'names'=>, 'mimes'=> )
  181. */
  182. function get_attached_files()
  183. {
  184. $listofpaths=array();
  185. $listofnames=array();
  186. $listofmimes=array();
  187. $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
  188. if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
  189. if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
  190. if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
  191. return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
  192. }
  193. /**
  194. * Show the form to input an email
  195. * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
  196. *
  197. * @param string $addfileaction Name of action when posting file attachments
  198. * @param string $removefileaction Name of action when removing file attachments
  199. * @return void
  200. */
  201. function show_form($addfileaction='addfile',$removefileaction='removefile')
  202. {
  203. print $this->get_form($addfileaction,$removefileaction);
  204. }
  205. /**
  206. * Get the form to input an email
  207. * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
  208. * this->param: Contains more parameteres like email templates info
  209. *
  210. * @param string $addfileaction Name of action when posting file attachments
  211. * @param string $removefileaction Name of action when removing file attachments
  212. * @return string Form to show
  213. */
  214. function get_form($addfileaction='addfile',$removefileaction='removefile')
  215. {
  216. global $conf, $langs, $user, $hookmanager, $form;
  217. if (! is_object($form)) $form=new Form($this->db);
  218. $langs->load("other");
  219. $langs->load("mails");
  220. $hookmanager->initHooks(array('formmail'));
  221. $parameters=array(
  222. 'addfileaction' => $addfileaction,
  223. 'removefileaction'=> $removefileaction,
  224. 'trackid'=> $this->trackid
  225. );
  226. $reshook=$hookmanager->executeHooks('getFormMail', $parameters, $this);
  227. if (!empty($reshook))
  228. {
  229. return $hookmanager->resPrint;
  230. }
  231. else
  232. {
  233. $out='';
  234. // Define list of attached files
  235. $listofpaths=array();
  236. $listofnames=array();
  237. $listofmimes=array();
  238. $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
  239. if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]);
  240. if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]);
  241. if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]);
  242. // Define output language
  243. $outputlangs = $langs;
  244. $newlang = '';
  245. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels'];
  246. if (! empty($newlang))
  247. {
  248. $outputlangs = new Translate("", $conf);
  249. $outputlangs->setDefaultLang($newlang);
  250. $outputlangs->load('other');
  251. }
  252. // Get message template
  253. $model_id=0;
  254. if (array_key_exists('models_id',$this->param))
  255. {
  256. $model_id=$this->param["models_id"];
  257. }
  258. $arraydefaultmessage=$this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
  259. //var_dump($arraydefaultmessage);
  260. $out.= "\n<!-- Begin form mail -->\n";
  261. if ($this->withform == 1)
  262. {
  263. $out.= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'#formmail">'."\n";
  264. $out.= '<input style="display:none" type="submit" id="sendmail" name="sendmail">';
  265. $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
  266. $out.= '<input type="hidden" name="trackid" value="'.$this->trackid.'" />';
  267. $out.= '<a id="formmail" name="formmail"></a>';
  268. }
  269. foreach ($this->param as $key=>$value)
  270. {
  271. $out.= '<input type="hidden" id="'.$key.'" name="'.$key.'" value="'.$value.'" />'."\n";
  272. }
  273. $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
  274. if ($result<0)
  275. {
  276. setEventMessages($this->error, $this->errors, 'errors');
  277. }
  278. $modelmail_array=array();
  279. foreach($this->lines_model as $line)
  280. {
  281. $modelmail_array[$line->id]=$line->label;
  282. }
  283. // Zone to select its email template
  284. if (count($modelmail_array)>0)
  285. {
  286. $out.= '<div style="padding: 3px 0 3px 0">'."\n";
  287. $out.= $langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1);
  288. if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
  289. $out.= ' &nbsp; ';
  290. $out.= '<input class="button" type="submit" value="'.$langs->trans('Use').'" name="modelselected" id="modelselected">';
  291. $out.= ' &nbsp; ';
  292. $out.= '</div>';
  293. }
  294. elseif (! empty($this->param['models']) && in_array($this->param['models'], array(
  295. 'propal_send','order_send','facture_send',
  296. 'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send',
  297. 'invoice_supplier_send','thirdparty'
  298. )))
  299. {
  300. $out.= '<div style="padding: 3px 0 3px 0">'."\n";
  301. $out.= $langs->trans('SelectMailModel').': <select name="modelmailselected" disabled="disabled"><option value="none">'.$langs->trans("NoTemplateDefined").'</option></select>'; // Do not put disabled on option, it is already on select and it makes chrome crazy.
  302. if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
  303. $out.= ' &nbsp; ';
  304. $out.= '<input class="button" type="submit" value="'.$langs->trans('Use').'" name="modelselected" disabled="disabled" id="modelselected">';
  305. $out.= ' &nbsp; ';
  306. $out.= '</div>';
  307. }
  308. $out.= '<table class="border" width="100%">'."\n";
  309. // Substitution array
  310. if (! empty($this->withsubstit))
  311. {
  312. $out.= '<tr><td colspan="2">';
  313. $help="";
  314. foreach($this->substit as $key => $val)
  315. {
  316. $help.=$key.' -> '.$langs->trans($val).'<br>';
  317. }
  318. $out.= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help);
  319. $out.= "</td></tr>\n";
  320. }
  321. // From
  322. if (! empty($this->withfrom))
  323. {
  324. if (! empty($this->withfromreadonly))
  325. {
  326. $out.= '<input type="hidden" id="fromname" name="fromname" value="'.$this->fromname.'" />';
  327. $out.= '<input type="hidden" id="frommail" name="frommail" value="'.$this->frommail.'" />';
  328. $out.= '<tr><td width="180">'.$langs->trans("MailFrom").'</td><td>';
  329. if ($this->fromtype == 'user' && $this->fromid > 0)
  330. {
  331. $langs->load("users");
  332. $fuser=new User($this->db);
  333. $fuser->fetch($this->fromid);
  334. $out.= $fuser->getNomUrl(1);
  335. }
  336. else
  337. {
  338. $out.= $this->fromname;
  339. }
  340. if ($this->frommail)
  341. {
  342. $out.= " &lt;".$this->frommail."&gt;";
  343. }
  344. else
  345. {
  346. if ($this->fromtype)
  347. {
  348. $langs->load("errors");
  349. $out.= '<font class="warning"> &lt;'.$langs->trans("ErrorNoMailDefinedForThisUser").'&gt; </font>';
  350. }
  351. }
  352. $out.= "</td></tr>\n";
  353. $out.= "</td></tr>\n";
  354. }
  355. else
  356. {
  357. $out.= "<tr><td>".$langs->trans("MailFrom")."</td><td>";
  358. $out.= $langs->trans("Name").':<input type="text" id="fromname" name="fromname" size="32" value="'.$this->fromname.'" />';
  359. $out.= '&nbsp; &nbsp; ';
  360. $out.= $langs->trans("EMail").':&lt;<input type="text" id="frommail" name="frommail" size="32" value="'.$this->frommail.'" />&gt;';
  361. $out.= "</td></tr>\n";
  362. }
  363. }
  364. // Replyto
  365. if (! empty($this->withreplyto))
  366. {
  367. if ($this->withreplytoreadonly)
  368. {
  369. $out.= '<input type="hidden" id="replyname" name="replyname" value="'.$this->replytoname.'" />';
  370. $out.= '<input type="hidden" id="replymail" name="replymail" value="'.$this->replytomail.'" />';
  371. $out.= "<tr><td>".$langs->trans("MailReply")."</td><td>".$this->replytoname.($this->replytomail?(" &lt;".$this->replytomail."&gt;"):"");
  372. $out.= "</td></tr>\n";
  373. }
  374. }
  375. // Errorsto
  376. if (! empty($this->witherrorsto))
  377. {
  378. //if (! $this->errorstomail) $this->errorstomail=$this->frommail;
  379. $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail);
  380. if ($this->witherrorstoreadonly)
  381. {
  382. $out.= '<input type="hidden" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
  383. $out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
  384. $out.= $errorstomail;
  385. $out.= "</td></tr>\n";
  386. }
  387. else
  388. {
  389. $out.= '<tr><td>'.$langs->trans("MailErrorsTo").'</td><td>';
  390. $out.= '<input size="30" id="errorstomail" name="errorstomail" value="'.$errorstomail.'" />';
  391. $out.= "</td></tr>\n";
  392. }
  393. }
  394. // To
  395. if (! empty($this->withto) || is_array($this->withto))
  396. {
  397. $out.= '<tr><td width="180">';
  398. if ($this->withtofree) $out.= $form->textwithpicto($langs->trans("MailTo"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
  399. else $out.= $langs->trans("MailTo");
  400. $out.= '</td><td>';
  401. if ($this->withtoreadonly)
  402. {
  403. if (! empty($this->toname) && ! empty($this->tomail))
  404. {
  405. $out.= '<input type="hidden" id="toname" name="toname" value="'.$this->toname.'" />';
  406. $out.= '<input type="hidden" id="tomail" name="tomail" value="'.$this->tomail.'" />';
  407. if ($this->totype == 'thirdparty')
  408. {
  409. $soc=new Societe($this->db);
  410. $soc->fetch($this->toid);
  411. $out.= $soc->getNomUrl(1);
  412. }
  413. else if ($this->totype == 'contact')
  414. {
  415. $contact=new Contact($this->db);
  416. $contact->fetch($this->toid);
  417. $out.= $contact->getNomUrl(1);
  418. }
  419. else
  420. {
  421. $out.= $this->toname;
  422. }
  423. $out.= ' &lt;'.$this->tomail.'&gt;';
  424. if ($this->withtofree)
  425. {
  426. $out.= '<br>'.$langs->trans("or").' <input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
  427. }
  428. }
  429. else
  430. {
  431. $out.= (! is_array($this->withto) && ! is_numeric($this->withto))?$this->withto:"";
  432. }
  433. }
  434. else
  435. {
  436. if (! empty($this->withtofree))
  437. {
  438. $out.= '<input size="'.(is_array($this->withto)?"30":"60").'" id="sendto" name="sendto" value="'.(! is_array($this->withto) && ! is_numeric($this->withto)? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto) :"").'" />';
  439. }
  440. if (! empty($this->withto) && is_array($this->withto))
  441. {
  442. if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
  443. $out.= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1);
  444. }
  445. if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
  446. {
  447. $liste=array();
  448. $soc=new Societe($this->db);
  449. $soc->fetch($this->withtosocid);
  450. foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
  451. {
  452. $liste[$key]=$value;
  453. }
  454. if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
  455. $out.= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1);
  456. }
  457. }
  458. $out.= "</td></tr>\n";
  459. }
  460. // CC
  461. if (! empty($this->withtocc) || is_array($this->withtocc))
  462. {
  463. $out.= '<tr><td width="180">';
  464. $out.= $form->textwithpicto($langs->trans("MailCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
  465. $out.= '</td><td>';
  466. if ($this->withtoccreadonly)
  467. {
  468. $out.= (! is_array($this->withtocc) && ! is_numeric($this->withtocc))?$this->withtocc:"";
  469. }
  470. else
  471. {
  472. $out.= '<input size="'.(is_array($this->withtocc)?"30":"60").'" id="sendtocc" name="sendtocc" value="'.((! is_array($this->withtocc) && ! is_numeric($this->withtocc))? (isset($_POST["sendtocc"])?$_POST["sendtocc"]:$this->withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />';
  473. if (! empty($this->withtocc) && is_array($this->withtocc))
  474. {
  475. $out.= " ".$langs->trans("or")." ";
  476. $out.= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1);
  477. }
  478. }
  479. $out.= "</td></tr>\n";
  480. }
  481. // CCC
  482. if (! empty($this->withtoccc) || is_array($this->withtoccc))
  483. {
  484. $out.= '<tr><td width="180">';
  485. $out.= $form->textwithpicto($langs->trans("MailCCC"),$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
  486. $out.= '</td><td>';
  487. if (! empty($this->withtocccreadonly))
  488. {
  489. $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
  490. }
  491. else
  492. {
  493. $out.= '<input size="'.(is_array($this->withtoccc)?"30":"60").'" id="sendtoccc" name="sendtoccc" value="'.((! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))? (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:$this->withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />';
  494. if (! empty($this->withtoccc) && is_array($this->withtoccc))
  495. {
  496. $out.= " ".$langs->trans("or")." ";
  497. $out.= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1);
  498. }
  499. }
  500. $showinfobcc='';
  501. if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO;
  502. if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO;
  503. if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO;
  504. if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO;
  505. if ($showinfobcc) $out.=' + '.$showinfobcc;
  506. $out.= "</td></tr>\n";
  507. }
  508. // Ask delivery receipt
  509. if (! empty($this->withdeliveryreceipt))
  510. {
  511. $out.= '<tr><td width="180">'.$langs->trans("DeliveryReceipt").'</td><td>';
  512. if (! empty($this->withdeliveryreceiptreadonly))
  513. {
  514. $out.= yn($this->withdeliveryreceipt);
  515. }
  516. else
  517. {
  518. $defaultvaluefordeliveryreceipt=0;
  519. if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1;
  520. if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $defaultvaluefordeliveryreceipt=1;
  521. if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt=1;
  522. if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1;
  523. $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1);
  524. }
  525. $out.= "</td></tr>\n";
  526. }
  527. // Topic
  528. if (! empty($this->withtopic))
  529. {
  530. $defaulttopic="";
  531. if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) $defaulttopic=$arraydefaultmessage['topic'];
  532. elseif (! is_numeric($this->withtopic)) $defaulttopic=$this->withtopic;
  533. $defaulttopic=make_substitutions($defaulttopic,$this->substit);
  534. $out.= '<tr>';
  535. $out.= '<td width="180">'.$langs->trans("MailTopic").'</td>';
  536. $out.= '<td>';
  537. if ($this->withtopicreadonly)
  538. {
  539. $out.= $defaulttopic;
  540. $out.= '<input type="hidden" size="60" id="subject" name="subject" value="'.$defaulttopic.'" />';
  541. }
  542. else
  543. {
  544. $out.= '<input type="text" size="60" id="subject" name="subject" value="'. ((isset($_POST["subject"]) && ! $_POST['modelselected'])?$_POST["subject"]:($defaulttopic?$defaulttopic:'')) .'" />';
  545. }
  546. $out.= "</td></tr>\n";
  547. }
  548. // Attached files
  549. if (! empty($this->withfile))
  550. {
  551. $out.= '<tr>';
  552. $out.= '<td width="180">'.$langs->trans("MailFile").'</td>';
  553. $out.= '<td>';
  554. if (is_numeric($this->withfile))
  555. {
  556. // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
  557. $out.= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
  558. $out.= '<script type="text/javascript" language="javascript">';
  559. $out.= 'jQuery(document).ready(function () {';
  560. $out.= ' jQuery(".removedfile").click(function() {';
  561. $out.= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
  562. $out.= ' });';
  563. $out.= '})';
  564. $out.= '</script>'."\n";
  565. if (count($listofpaths))
  566. {
  567. foreach($listofpaths as $key => $val)
  568. {
  569. $out.= '<div id="attachfile_'.$key.'">';
  570. $out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
  571. if (! $this->withfilereadonly)
  572. {
  573. $out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
  574. //$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>';
  575. }
  576. $out.= '<br></div>';
  577. }
  578. }
  579. else
  580. {
  581. $out.= $langs->trans("NoAttachedFiles").'<br>';
  582. }
  583. if ($this->withfile == 2) // Can add other files
  584. {
  585. if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out.= '<input type="file" class="flat" id="addedfile" name="addedfile[]" value="'.$langs->trans("Upload").'" multiple />';
  586. else $out.= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
  587. $out.= ' ';
  588. $out.= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
  589. }
  590. }
  591. else
  592. {
  593. $out.=$this->withfile;
  594. }
  595. $out.= "</td></tr>\n";
  596. }
  597. // Message
  598. if (! empty($this->withbody))
  599. {
  600. $defaultmessage="";
  601. if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['content']) $defaultmessage=$arraydefaultmessage['content'];
  602. elseif (! is_numeric($this->withbody)) $defaultmessage=$this->withbody;
  603. // Complete substitution array
  604. if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_ADD_PAYMENT_URL))
  605. {
  606. require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
  607. $langs->load('paypal');
  608. // Set the paypal message and url link into __PERSONALIZED__ key
  609. if ($this->param["models"]=='order_send')
  610. {
  611. $url=getPaypalPaymentUrl(0,'order',$this->substit['__ORDERREF__']?$this->substit['__ORDERREF__']:$this->substit['__REF__']);
  612. $this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url));
  613. }
  614. if ($this->param["models"]=='facture_send')
  615. {
  616. $url=getPaypalPaymentUrl(0,'invoice',$this->substit['__REF__']);
  617. $this->substit['__PERSONALIZED__']=str_replace('\n',"\n",$langs->transnoentitiesnoconv("PredefinedMailContentLink",$url));
  618. }
  619. }
  620. $defaultmessage=str_replace('\n',"\n",$defaultmessage);
  621. // Deal with format differences between message and signature (text / HTML)
  622. if(dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) {
  623. $this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']);
  624. } else if(!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) {
  625. $defaultmessage = dol_nl2br($defaultmessage);
  626. }
  627. if (isset($_POST["message"]) && ! $_POST['modelselected']) $defaultmessage=$_POST["message"];
  628. else
  629. {
  630. $defaultmessage=make_substitutions($defaultmessage,$this->substit);
  631. // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
  632. $defaultmessage=preg_replace("/^(<br>)+/","",$defaultmessage);
  633. $defaultmessage=preg_replace("/^\n+/","",$defaultmessage);
  634. }
  635. $out.= '<tr>';
  636. $out.= '<td width="180" valign="top">'.$langs->trans("MailText").'</td>';
  637. $out.= '<td>';
  638. if ($this->withbodyreadonly)
  639. {
  640. $out.= nl2br($defaultmessage);
  641. $out.= '<input type="hidden" id="message" name="message" value="'.$defaultmessage.'" />';
  642. }
  643. else
  644. {
  645. if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes';
  646. // Editor wysiwyg
  647. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  648. if ($this->withfckeditor == -1)
  649. {
  650. if (! empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor=1;
  651. else $this->withfckeditor=0;
  652. }
  653. $doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,'95%');
  654. $out.= $doleditor->Create(1);
  655. }
  656. $out.= "</td></tr>\n";
  657. }
  658. $out.= '</table>'."\n";
  659. if ($this->withform == 1 || $this->withform == -1)
  660. {
  661. $out.= '<br><div class="center">';
  662. $out.= '<input class="button" type="submit" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"';
  663. // Add a javascript test to avoid to forget to submit file before sending email
  664. if ($this->withfile == 2 && $conf->use_javascript_ajax)
  665. {
  666. $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
  667. }
  668. $out.= ' />';
  669. if ($this->withcancel)
  670. {
  671. $out.= ' &nbsp; &nbsp; ';
  672. $out.= '<input class="button" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />';
  673. }
  674. $out.= '</div>'."\n";
  675. }
  676. if ($this->withform == 1) $out.= '</form>'."\n";
  677. // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set
  678. if (! empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY))
  679. {
  680. $out.= '<script type="text/javascript" language="javascript">';
  681. $out.= 'jQuery(document).ready(function () {';
  682. $out.= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is calle at every key pressed ! */
  683. var code = e.keyCode || e.which;
  684. if (code == 13) {
  685. e.preventDefault();
  686. return false;
  687. }
  688. });';
  689. $out.=' })';
  690. $out.= '</script>';
  691. }
  692. $out.= "<!-- End form mail -->\n";
  693. return $out;
  694. }
  695. }
  696. /**
  697. * Return template of email
  698. * Search into table c_email_templates
  699. *
  700. * @param DoliDB $db Database handler
  701. * @param string $type_template Get message for key module
  702. * @param string $user Use template public or limited to this user
  703. * @param Translate $outputlangs Output lang object
  704. * @param int $id Id template to find
  705. * @param int $active 1=Only active template, 0=Only disabled, -1=All
  706. * @return array array('topic'=>,'content'=>,..)
  707. */
  708. private function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1)
  709. {
  710. $ret=array();
  711. $sql = "SELECT label, topic, content, lang";
  712. $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
  713. $sql.= " WHERE type_template='".$db->escape($type_template)."'";
  714. $sql.= " AND entity IN (".getEntity("c_email_templates").")";
  715. $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
  716. if ($active >= 0) $sql.=" AND active = ".$active;
  717. if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
  718. if (!empty($id)) $sql.= " AND rowid=".$id;
  719. $sql.= $db->order("lang,label","ASC");
  720. //print $sql;
  721. $resql = $db->query($sql);
  722. if ($resql)
  723. {
  724. $obj = $db->fetch_object($resql); // Get first found
  725. if ($obj)
  726. {
  727. $ret['label']=$obj->label;
  728. $ret['topic']=$obj->topic;
  729. $ret['content']=$obj->content;
  730. $ret['lang']=$obj->lang;
  731. }
  732. else
  733. {
  734. $defaultmessage='';
  735. if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); }
  736. elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); }
  737. elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); }
  738. elseif ($type_template=='supplier_proposal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); }
  739. elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); }
  740. elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); }
  741. elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); }
  742. elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); }
  743. elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); }
  744. elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); }
  745. $ret['label']='default';
  746. $ret['topic']='';
  747. $ret['content']=$defaultmessage;
  748. $ret['lang']=$outputlangs->defaultlang;
  749. }
  750. $db->free($resql);
  751. return $ret;
  752. }
  753. else
  754. {
  755. dol_print_error($db);
  756. return -1;
  757. }
  758. }
  759. /**
  760. * Find if template exists
  761. * Search into table c_email_templates
  762. *
  763. * @param string $type_template Get message for key module
  764. * @param string $user Use template public or limited to this user
  765. * @param Translate $outputlangs Output lang object
  766. * @return int <0 if KO,
  767. */
  768. public function isEMailTemplate($type_template, $user, $outputlangs)
  769. {
  770. $ret=array();
  771. $sql = "SELECT label, topic, content, lang";
  772. $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
  773. $sql.= " WHERE type_template='".$this->db->escape($type_template)."'";
  774. $sql.= " AND entity IN (".getEntity("c_email_templates").")";
  775. $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
  776. if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
  777. $sql.= $this->db->order("lang,label","ASC");
  778. //print $sql;
  779. $resql = $this->db->query($sql);
  780. if ($resql)
  781. {
  782. $num= $this->db->num_rows($resql);
  783. $this->db->free($resql);
  784. return $num;
  785. }
  786. else
  787. {
  788. $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror();
  789. return -1;
  790. }
  791. }
  792. /**
  793. * Find if template exists
  794. * Search into table c_email_templates
  795. *
  796. * @param string $type_template Get message for key module
  797. * @param string $user Use template public or limited to this user
  798. * @param Translate $outputlangs Output lang object
  799. * @param int $active 1=Only active template, 0=Only disabled, -1=All
  800. * @return int <0 if KO, nb of records found if OK
  801. */
  802. public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active=1)
  803. {
  804. $ret=array();
  805. $sql = "SELECT rowid, label, topic, content, lang, position";
  806. $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates';
  807. $sql.= " WHERE type_template='".$this->db->escape($type_template)."'";
  808. $sql.= " AND entity IN (".getEntity("c_email_templates").")";
  809. $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
  810. if ($active >= 0) $sql.=" AND active = ".$active;
  811. if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
  812. $sql.= $this->db->order("position,lang,label","ASC");
  813. //print $sql;
  814. $resql = $this->db->query($sql);
  815. if ($resql)
  816. {
  817. $num=$this->db->num_rows($resql);
  818. $this->lines_model=array();
  819. while ($obj = $this->db->fetch_object($resql))
  820. {
  821. $line = new ModelMail();
  822. $line->id=$obj->rowid;
  823. $line->label=$obj->label;
  824. $line->topic=$obj->topic;
  825. $line->content=$obj->content;
  826. $line->lang=$obj->lang;
  827. $this->lines_model[]=$line;
  828. }
  829. $this->db->free($resql);
  830. return $num;
  831. }
  832. else
  833. {
  834. $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror();
  835. return -1;
  836. }
  837. }
  838. /**
  839. * Set substit array from object
  840. *
  841. * @param Object $object Object to use
  842. * @param Translate $outputlangs Object lang
  843. * @return void
  844. */
  845. function setSubstitFromObject($object, $outputlangs=null)
  846. {
  847. global $user;
  848. $this->substit['__REF__'] = $object->ref;
  849. $this->substit['__REFCLIENT__'] = $object->ref_client;
  850. $this->substit['__REFSUPPLIER__'] = $object->ref_supplier;
  851. $this->substit['__DATE_YMD__'] = dol_print_date($object->date, 'day', 0, $outputlangs);
  852. $this->substit['__DATE_DUE_YMD__'] = dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs);
  853. $this->substit['__AMOUNT__'] = price($object->total_ttc);
  854. $this->substit['__AMOUNT_WO_TAX__'] = price($object->total_ht);
  855. $this->substit['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:'');
  856. $this->substit['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:'');
  857. $this->substit['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:'');
  858. $this->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:'');
  859. $this->substit['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:'');
  860. $this->substit['__SIGNATURE__'] = $user->signature;
  861. $this->substit['__PERSONALIZED__'] = '';
  862. $this->substit['__CONTACTCIVNAME__'] = ''; // Will be replace just before sending
  863. }
  864. /**
  865. * Set substit array from object
  866. *
  867. * @param string $mode 'form' or 'emailing'
  868. * @return void
  869. */
  870. function getAvailableSubstitKey($mode='form')
  871. {
  872. global $conf;
  873. $vars=array();
  874. if ($mode == 'form')
  875. {
  876. $vars=array(
  877. '__REF__',
  878. '__REFCLIENT__',
  879. '__THIRDPARTY_NAME__',
  880. '__PROJECT_REF__',
  881. '__PROJECT_NAME__',
  882. '__CONTACTCIVNAME__',
  883. '__PERSONALIZED__', // Paypal link will be added here in form mode
  884. '__SIGNATURE__',
  885. );
  886. }
  887. if ($mode == 'emailing')
  888. {
  889. // For mass emailing, we have different keys
  890. $vars=array(
  891. '__ID__' => 'IdRecord',
  892. '__EMAIL__' => 'EMailRecipient',
  893. '__LASTNAME__' => 'Lastname',
  894. '__FIRSTNAME__' => 'Firstname',
  895. '__MAILTOEMAIL__' => 'TagMailtoEmail',
  896. '__OTHER1__' => 'Other1',
  897. '__OTHER2__' => 'Other2',
  898. '__OTHER3__' => 'Other3',
  899. '__OTHER4__' => 'Other4',
  900. '__OTHER5__' => 'Other5',
  901. '__SIGNATURE__' => 'TagSignature',
  902. '__CHECK_READ__' => 'TagCheckMail',
  903. '__UNSUBSCRIBE__' => 'TagUnsubscribe'
  904. //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing
  905. );
  906. if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN))
  907. {
  908. $vars['__SECUREKEYPAYPAL__']='SecureKeyPaypal';
  909. if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE))
  910. {
  911. if ($conf->adherent->enabled) $vars['__SECUREKEYPAYPAL_MEMBER__']='SecureKeyPaypalUniquePerMember';
  912. if ($conf->facture->enabled) $vars['__SECUREKEYPAYPAL_INVOICE__']='SecureKeyPaypalUniquePerInvoice';
  913. if ($conf->commande->enabled) $vars['__SECUREKEYPAYPAL_ORDER__']='SecureKeyPaypalUniquePerOrder';
  914. if ($conf->contrat->enabled) $vars['__SECUREKEYPAYPAL_CONTRACTLINE__']='SecureKeyPaypalUniquePerContractLine';
  915. }
  916. }
  917. else
  918. {
  919. $vars['__SECUREKEYPAYPAL__']='';
  920. $vars['__SECUREKEYPAYPAL_MEMBER__']='';
  921. }
  922. }
  923. return $vars;
  924. }
  925. }
  926. /**
  927. * ModelMail
  928. */
  929. class ModelMail
  930. {
  931. public $id;
  932. public $label;
  933. public $topic;
  934. public $content;
  935. public $lang;
  936. }