dolibarr 20.0.2
mails_templates.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
8 * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
9 * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
10 * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
11 * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
12 * Copyright (C) 2015-2024 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
14 * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <https://www.gnu.org/licenses/>.
28 */
29
36// Load Dolibarr environment
37require '../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
45
46// Load translation files required by the page
47$langsArray = array("errors", "admin", "mails", "languages");
48
49if (isModEnabled('member')) {
50 $langsArray[] = 'members';
51}
52if (isModEnabled('eventorganization')) {
53 $langsArray[] = 'eventorganization';
54}
55
56$langs->loadLangs($langsArray);
57
58$toselect = GETPOST('toselect', 'array');
59$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view';
60$massaction = GETPOST('massaction', 'alpha');
61$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
62$mode = GETPOST('mode', 'aZ09');
63$optioncss = GETPOST('optioncss', 'alpha');
64
65$id = $rowid = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('rowid'));
66$search_label = GETPOST('search_label', 'alphanohtml'); // Must allow value like 'Abc Def' or '(MyTemplateName)'
67$search_type_template = GETPOST('search_type_template', 'alpha');
68$search_lang = GETPOST('search_lang', 'alpha');
69$search_fk_user = GETPOST('search_fk_user', 'intcomma');
70$search_topic = GETPOST('search_topic', 'alpha');
71$search_module = GETPOST('search_module', 'alpha');
72
73$acts = array();
74$actl = array();
75$acts[0] = "activate";
76$acts[1] = "disable";
77$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"');
78$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"');
79
80$listoffset = GETPOST('listoffset', 'alpha');
81$listlimit = GETPOST('listlimit', 'alpha') > 0 ? GETPOST('listlimit', 'alpha') : 1000;
82
83$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
84$sortfield = GETPOST('sortfield', 'aZ09comma');
85$sortorder = GETPOST('sortorder', 'aZ09comma');
86$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
87if (empty($page) || $page == -1) {
88 $page = 0;
89} // If $page is not defined, or '' or -1
90$offset = $listlimit * $page;
91$pageprev = $page - 1;
92$pagenext = $page + 1;
93
94if (empty($sortfield)) {
95 $sortfield = 'type_template,lang,position,label';
96}
97if (empty($sortorder)) {
98 $sortorder = 'ASC';
99}
100
101// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
102$hookmanager->initHooks(array('emailtemplates'));
103
104
105// Name of SQL tables of dictionaries
106$tabname = array();
107$tabname[25] = MAIN_DB_PREFIX."c_email_templates";
108
109// Nom des champs en resultat de select pour affichage du dictionnaire
110$tabfield = array();
111$tabfield[25] = "label,lang,type_template,fk_user,private,position,module,topic,joinfiles,defaultfortype,content";
112if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
113 $tabfield[25] .= ',content_lines';
114}
115
116// Nom des champs d'edition pour modification d'un enregistrement
117$tabfieldvalue = array();
118$tabfieldvalue[25] = "label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content";
119if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
120 $tabfieldvalue[25] .= ',content_lines';
121}
122
123// Nom des champs dans la table pour insertion d'un enregistrement
124$tabfieldinsert = array();
125$tabfieldinsert[25] = "label,lang,type_template,fk_user,private,position,topic,email_from,joinfiles,defaultfortype,content";
126if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
127 $tabfieldinsert[25] .= ',content_lines';
128}
129$tabfieldinsert[25] .= ',entity'; // Must be at end because not into other arrays
130
131// Condition to show dictionary in setup page
132$tabcond = array();
133$tabcond[25] = true;
134
135// List of help for fields
136// Set MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES to allow edit of template for lines
137require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
138$formmail = new FormMail($db);
139if (!getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
140 $tmp = FormMail::getAvailableSubstitKey('formemail');
141 $tmp['__(AnyTranslationKey)__'] = 'Translation';
142 $helpsubstit = $langs->trans("AvailableVariables").':<br>';
143 $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
144 foreach ($tmp as $key => $val) {
145 $helpsubstit .= $key.' -> '.$val.'<br>';
146 $helpsubstitforlines .= $key.' -> '.$val.'<br>';
147 }
148} else {
149 $tmp = FormMail::getAvailableSubstitKey('formemailwithlines');
150 $tmp['__(AnyTranslationKey)__'] = 'Translation';
151 $helpsubstit = $langs->trans("AvailableVariables").':<br>';
152 $helpsubstitforlines = $langs->trans("AvailableVariables").':<br>';
153 foreach ($tmp as $key => $val) {
154 $helpsubstit .= $key.' -> '.$val.'<br>';
155 }
156 $tmp = FormMail::getAvailableSubstitKey('formemailforlines');
157 foreach ($tmp as $key => $val) {
158 $helpsubstitforlines .= $key.' -> '.$val.'<br>';
159 }
160}
161
162
163$tabhelp = array();
164$tabhelp[25] = array(
165 'label' => $langs->trans('EnterAnyCode'),
166 'type_template' => $langs->trans("TemplateForElement"),
167 'private' => $langs->trans("TemplateIsVisibleByOwnerOnly"),
168 'position' => $langs->trans("PositionIntoComboList"),
169 'topic' => '<span class="small">'.$helpsubstit.'</span>',
170 'email_from' => $langs->trans('ForceEmailFrom'),
171 'joinfiles' => $langs->trans('AttachMainDocByDefault'),
172 'defaultfortype' => $langs->trans("DefaultForTypeDesc"),
173 'content' => '<span class="small">'.$helpsubstit.'</span>',
174 'content_lines' => '<span class="small">'.$helpsubstitforlines.'</span>'
175);
176
177
178// We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']"
179$elementList = array();
180// Add all and none after the sort
181
182$elementList['all'] = '-- '.dol_escape_htmltag($langs->trans("All")).' --';
183$elementList['none'] = '-- '.dol_escape_htmltag($langs->trans("None")).' --';
184$elementList['user'] = img_picto('', 'user', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToUser'));
185if (isModEnabled('member') && $user->hasRight('adherent', 'lire')) {
186 $elementList['member'] = img_picto('', 'object_member', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToMember'));
187}
188if (isModEnabled('recruitment') && $user->hasRight('recruitment', 'recruitmentjobposition', 'read')) {
189 $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures'));
190}
191if (isModEnabled("societe") && $user->hasRight('societe', 'lire')) {
192 $elementList['thirdparty'] = img_picto('', 'company', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToThirdparty'));
193}
194if (isModEnabled("societe") && $user->hasRight('societe', 'contact', 'lire')) {
195 $elementList['contact'] = img_picto('', 'contact', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToContact'));
196}
197if (isModEnabled('project')) {
198 $elementList['project'] = img_picto('', 'project', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToProject'));
199}
200if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
201 $elementList['propal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendProposal'));
202}
203if (isModEnabled('order') && $user->hasRight('commande', 'lire')) {
204 $elementList['order_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendOrder'));
205}
206if (isModEnabled('invoice') && $user->hasRight('facture', 'lire')) {
207 $elementList['facture_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendInvoice'));
208}
209if (isModEnabled("shipping")) {
210 $elementList['shipping_send'] = img_picto('', 'dolly', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
211}
212if (isModEnabled("reception")) {
213 $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendReception'));
214}
215if (isModEnabled('intervention')) {
216 $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
217}
218if (isModEnabled('supplier_proposal')) {
219 $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation'));
220}
221if (isModEnabled("supplier_order") && ($user->hasRight('fournisseur', 'commande', 'lire') || $user->hasRight('supplier_order', 'read'))) {
222 $elementList['order_supplier_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder'));
223}
224if (isModEnabled("supplier_invoice") && ($user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'read'))) {
225 $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice'));
226}
227if (isModEnabled('contract') && $user->hasRight('contrat', 'lire')) {
228 $elementList['contract'] = img_picto('', 'contract', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendContract'));
229}
230if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) {
231 $elementList['ticket_send'] = img_picto('', 'ticket', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToTicket'));
232}
233if (isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire')) {
234 $elementList['expensereport_send'] = img_picto('', 'trip', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToExpenseReport'));
235}
236if (isModEnabled('agenda')) {
237 $elementList['actioncomm_send'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventPush'));
238}
239if (isModEnabled('eventorganization') && $user->hasRight('eventorganization', 'read')) {
240 $elementList['conferenceorbooth'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization'));
241}
242if (isModEnabled('partnership') && $user->hasRight('partnership', 'read')) {
243 $elementList['partnership_send'] = img_picto('', 'partnership', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToPartnership'));
244}
245
246$parameters = array('elementList' => $elementList);
247$reshook = $hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks
248if ($reshook == 0) {
249 foreach ($hookmanager->resArray as $item => $value) {
250 $elementList[$item] = $value;
251 }
252}
253
254$error = 0;
255
256$acceptlocallinktomedia = (acceptLocalLinktoMedia() > 0 ? 1 : 0);
257
258// Security
259if (!empty($user->socid)) {
261}
262
263$permissiontoadd = 1;
264$permissiontoedit = ($user->admin ? 1 : 0);
265$permissiontodelete = ($user->admin ? 1 : 0);
266if ($rowid > 0) {
267 $tmpmailtemplate = new ModelMail($db);
268 $tmpmailtemplate->fetch($rowid);
269 if ($tmpmailtemplate->fk_user == $user->id) {
270 $permissiontoedit = 1;
271 $permissiontodelete = 1;
272 }
273}
274
275
276/*
277 * Actions
278 */
279
280if (GETPOST('cancel', 'alpha')) {
281 $action = 'list';
282 $massaction = '';
283}
284if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
285 $massaction = '';
286}
287
288$parameters = array();
289$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
290if ($reshook < 0) {
291 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
292}
293
294if (empty($reshook)) {
295 // Selection of new fields
296 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
297
298 // Purge search criteria
299 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
300 // All tests are required to be compatible with all browsers
301 $search_label = '';
302 $search_type_template = '';
303 $search_lang = '';
304 $search_fk_user = '';
305 $search_topic = '';
306 $search_module = '';
307 $toselect = array();
308 $search_array_options = array();
309 }
310
311 // Actions add or modify an email template
312 if ((GETPOST('actionadd', 'alpha') && $permissiontoadd) || (GETPOST('actionmodify', 'alpha') && $permissiontoedit)) {
313 $listfield = explode(',', str_replace(' ', '', $tabfield[25]));
314 $listfieldinsert = explode(',', $tabfieldinsert[25]);
315 $listfieldmodify = explode(',', $tabfieldinsert[25]);
316 $listfieldvalue = explode(',', $tabfieldvalue[25]);
317
318 // Check that all fields are filled
319 $ok = 1;
320 foreach ($listfield as $f => $value) {
321 // Not mandatory fields
322 if (in_array($value, ['joinfiles', 'defaultfortype', 'content', 'content_lines', 'module'])) {
323 continue;
324 }
325
326 // Rename some POST variables into a generic name
327 if (GETPOST('actionmodify', 'alpha') && $value == 'topic') {
328 $_POST['topic'] = GETPOST('topic-'.$rowid);
329 }
330
331 if ((!GETPOSTISSET($value) || GETPOST($value) == '' || GETPOST($value) == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') {
332 $ok = 0;
333 $fieldnamekey = $listfield[$f];
334 // We take translate key of field
335 if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
336 $fieldnamekey = 'Code';
337 }
338 if ($fieldnamekey == 'code') {
339 $fieldnamekey = 'Code';
340 }
341 if ($fieldnamekey == 'note') {
342 $fieldnamekey = 'Note';
343 }
344 if ($fieldnamekey == 'type_template') {
345 $fieldnamekey = 'TypeOfTemplate';
346 }
347 if ($fieldnamekey == 'fk_user') {
348 $fieldnamekey = 'Owner';
349 }
350 if ($fieldnamekey == 'private') {
351 $fieldnamekey = 'Private';
352 }
353 if ($fieldnamekey == 'position') {
354 $fieldnamekey = 'Position';
355 }
356 if ($fieldnamekey == 'topic') {
357 $fieldnamekey = 'Topic';
358 }
359
360 setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
361 $action = 'create';
362 }
363 }
364
365 // If previous test is ok action is add, we add the line
366 if ($ok && GETPOST('actionadd')) {
367 // Add new entry
368 $sql = "INSERT INTO ".$tabname[25]." (";
369 // List of fields
370 $sql .= $tabfieldinsert[25];
371 $sql .= ", active, enabled)";
372 $sql .= " VALUES(";
373
374 // List of values
375 $i = 0;
376 foreach ($listfieldinsert as $f => $value) {
377 $keycode = isset($listfieldvalue[$i]) ? $listfieldvalue[$i] : "";
378 if ($value == 'lang') {
379 $keycode = 'langcode';
380 }
381 if (empty($keycode)) {
382 $keycode = $value;
383 }
384
385 // Clean input variables
386 if ($value == 'entity') {
387 $_POST[$keycode] = $conf->entity;
388 }
389 if ($value == 'fk_user' && !($_POST[$keycode] > 0)) {
390 $_POST[$keycode] = '';
391 }
392 if ($value == 'private' && !is_numeric($_POST[$keycode])) {
393 $_POST[$keycode] = '0';
394 }
395 if ($value == 'position' && !is_numeric($_POST[$keycode])) {
396 $_POST[$keycode] = '1';
397 }
398 if ($value == 'defaultfortype' && !is_numeric($_POST[$keycode])) {
399 $_POST[$keycode] = '0';
400 }
401 //var_dump($keycode.' '.$value);
402
403 if ($i) {
404 $sql .= ", ";
405 }
406 if (GETPOST($keycode) == '' && $keycode != 'langcode') {
407 $sql .= "null"; // langcode must be '' if not defined so the unique key that include lang will work
408 } elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') {
409 $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
410 } elseif ($keycode == 'fk_user') {
411 if (!$user->admin) { // A non admin user can only edit its own template
412 $sql .= " ".((int) $user->id);
413 } else {
414 $sql .= " ".(GETPOSTINT($keycode));
415 }
416 } elseif ($keycode == 'content') {
417 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
418 } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position', 'entity'))) {
419 $sql .= GETPOSTINT($keycode);
420 } else {
421 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
422 }
423 $i++;
424 }
425 $sql .= ", 1, 1)";
426
427 dol_syslog("actionadd", LOG_DEBUG);
428 $result = $db->query($sql);
429 if ($result) { // Add is ok
430 setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
431 $_POST = array('id' => 25); // Clean $_POST array, we keep only id
432 } else {
433 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
434 setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
435 } else {
436 dol_print_error($db);
437 }
438 $action = 'create';
439 }
440 }
441
442 // We modify the line
443 if ($ok && GETPOST('actionmodify')) {
444 $rowidcol = "rowid";
445
446 if (GETPOSTINT('fk_user') <= 0 && GETPOST('private')) {
447 setEventMessages($langs->trans("AnOwnerMustBeSetIfEmailTemplateIsPrivate"), null, 'errors');
448 $error++;
449 $action = 'edit';
450 }
451
452 if (!$error) {
453 // Modify entry
454 $sql = "UPDATE ".$tabname[25]." SET ";
455 // Modify value of fields
456 $i = 0;
457 foreach ($listfieldmodify as $field) {
458 if ($field == 'entity') {
459 // entity not present on listfieldmodify array
460 $keycode = $field;
461 $_POST[$keycode] = $conf->entity;
462 } else {
463 $keycode = $listfieldvalue[$i];
464 }
465
466 if ($field == 'lang') {
467 $keycode = 'langcode';
468 }
469 if (empty($keycode)) {
470 $keycode = $field;
471 }
472
473 // Rename some POST variables into a generic name
474 if ($field == 'fk_user' && !(GETPOSTINT('fk_user') > 0)) {
475 $_POST['fk_user'] = '';
476 }
477 if ($field == 'topic') {
478 $_POST['topic'] = GETPOST('topic-'.$rowid);
479 }
480 if ($field == 'joinfiles') {
481 $_POST['joinfiles'] = GETPOST('joinfiles-'.$rowid);
482 }
483 if ($field == 'content') {
484 $_POST['content'] = GETPOST('content-'.$rowid, 'restricthtml');
485 }
486 if ($field == 'content_lines') {
487 $_POST['content_lines'] = GETPOST('content_lines-'.$rowid, 'restricthtml');
488 }
489 if ($field == 'email_from') {
490 $_POST['email_from'] = GETPOST('email_from-'.$rowid, 'restricthtml');
491 }
492
493 if ($i) {
494 $sql .= ", ";
495 }
496 $sql .= $field."=";
497
498 if (GETPOST($keycode) == '' || (!in_array($keycode, array('langcode', 'position', 'private', 'defaultfortype')) && !GETPOST($keycode))) {
499 $sql .= "null"; // langcode,... must be '' if not defined so the unique key that include lang will work
500 } elseif (GETPOST($keycode) == '0' && $keycode == 'langcode') {
501 $sql .= "''"; // langcode must be '' if not defined so the unique key that include lang will work
502 } elseif ($keycode == 'fk_user') {
503 if (!$user->admin) { // A non admin user can only edit its own template
504 $sql .= " ".((int) $user->id);
505 } else {
506 $sql .= " ".(GETPOSTINT($keycode));
507 }
508 } elseif ($keycode == 'content') {
509 $sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
510 } elseif (in_array($keycode, array('joinfiles', 'defaultfortype', 'private', 'position'))) {
511 $sql .= GETPOSTINT($keycode);
512 } else {
513 $sql .= "'".$db->escape(GETPOST($keycode, 'alphanohtml'))."'";
514 }
515 $i++;
516 }
517
518 $sql .= " WHERE ".$db->escape($rowidcol)." = ".((int) $rowid);
519 if (!$user->admin) { // A non admin user can only edit its own template
520 $sql .= " AND fk_user = ".((int) $user->id);
521 }
522 //print $sql;exit;
523 dol_syslog("actionmodify", LOG_DEBUG);
524
525 //print $sql;
526 $resql = $db->query($sql);
527 if (!$resql) {
528 $error++;
529 setEventMessages($db->error(), null, 'errors');
530 $action = 'edit';
531 }
532 }
533
534 if (!$error) {
535 setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
536 }
537 }
538 }
539
540 if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) { // delete
541 $rowidcol = "rowid";
542
543 $sql = "DELETE from ".$tabname[25]." WHERE ".$rowidcol." = ".((int) $rowid);
544 if (!$user->admin) { // A non admin user can only edit its own template
545 $sql .= " AND fk_user = ".((int) $user->id);
546 }
547 dol_syslog("delete", LOG_DEBUG);
548 $result = $db->query($sql);
549 if (!$result) {
550 if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
551 setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
552 } else {
553 dol_print_error($db);
554 }
555 }
556 }
557
558 // activate
559 if ($action == $acts[0] && $permissiontoedit) {
560 $rowidcol = "rowid";
561
562 $sql = "UPDATE ".$tabname[25]." SET active = 1 WHERE rowid = ".((int) $rowid);
563
564 $result = $db->query($sql);
565 if (!$result) {
566 dol_print_error($db);
567 }
568 }
569
570 // disable
571 if ($action == $acts[1] && $permissiontoedit) {
572 $rowidcol = "rowid";
573
574 $sql = "UPDATE ".$tabname[25]." SET active = 0 WHERE rowid = ".((int) $rowid);
575
576 $result = $db->query($sql);
577 if (!$result) {
578 dol_print_error($db);
579 }
580 }
581}
582
583
584/*
585 * View
586 */
587
588$form = new Form($db);
589$formadmin = new FormAdmin($db);
590
591$now = dol_now();
592
593//$help_url = "EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
594$help_url = '';
595if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
596 $title = $langs->trans("EMailsSetup");
597} else {
598 $title = $langs->trans("EMailTemplates");
599}
600$morejs = array();
601$morecss = array();
602
603$sql = "SELECT rowid as rowid, module, label, type_template, lang, fk_user, private, position, topic, email_from,joinfiles, defaultfortype, content_lines, content, enabled, active";
604$sql .= " FROM ".MAIN_DB_PREFIX."c_email_templates";
605$sql .= " WHERE entity IN (".getEntity('email_template').")";
606if (!$user->admin) {
607 $sql .= " AND (private = 0 OR (private = 1 AND fk_user = ".((int) $user->id)."))"; // Show only public and private to me
608 $sql .= " AND (active = 1 OR fk_user = ".((int) $user->id).")"; // Show only active or owned by me
609}
610if (!getDolGlobalInt('MAIN_MULTILANGS')) {
611 $sql .= " AND (lang = '".$db->escape($langs->defaultlang)."' OR lang IS NULL OR lang = '')";
612}
613if ($search_label) {
614 $sql .= natural_search('label', $search_label);
615}
616if ($search_type_template != '' && $search_type_template != '-1') {
617 $sql .= natural_search('type_template', $search_type_template);
618}
619if ($search_lang) {
620 $sql .= natural_search('lang', $search_lang);
621}
622if ($search_fk_user != '' && $search_fk_user != '-1') {
623 $sql .= natural_search('fk_user', $search_fk_user, 2);
624}
625if ($search_module) {
626 $sql .= natural_search('module', $search_module);
627}
628if ($search_topic) {
629 $sql .= natural_search('topic', $search_topic);
630}
631// If sort order is "country", we use country_code instead
632if ($sortfield == 'country') {
633 $sortfield = 'country_code';
634}
635$sql .= $db->order($sortfield, $sortorder);
636$sql .= $db->plimit($listlimit + 1, $offset);
637//print $sql;
638
639// Output page
640// --------------------------------------------------------------------
641
642llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-admin page-mails_templates');
643
644$arrayofselected = is_array($toselect) ? $toselect : array();
645
646$param = '';
647if (!empty($mode)) {
648 $param .= '&mode='.urlencode($mode);
649}
650if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
651 $param .= '&contextpage='.urlencode($contextpage);
652}
653if ($limit > 0 && $limit != $conf->liste_limit) {
654 $param .= '&limit='.((int) $limit);
655}
656if (!empty($search) && is_array($search)) {
657 foreach ($search as $key => $val) {
658 if (is_array($search[$key]) && count($search[$key])) {
659 foreach ($search[$key] as $skey) {
660 if ($skey != '') {
661 $param .= '&search_'.$key.'[]='.urlencode($skey);
662 }
663 }
664 } elseif ($search[$key] != '') {
665 $param .= '&search_'.$key.'='.urlencode($search[$key]);
666 }
667 }
668}
669if ($optioncss != '') {
670 $param .= '&optioncss='.urlencode($optioncss);
671}
672// Add $param from extra fields
673include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
674// Add $param from hooks
675$parameters = array();
676$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
677$param .= $hookmanager->resPrint;
678
679
680$linkback = '';
681$titlepicto = 'title_setup';
682
683
684$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=create';
685$newcardbutton = '';
686$newcardbutton .= dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
687
688
689if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
690 print load_fiche_titre($title, '', $titlepicto);
691} else {
692 print load_fiche_titre($title, $newcardbutton, $titlepicto);
693}
694
695if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
696 $head = email_admin_prepare_head();
697
698 print dol_get_fiche_head($head, 'templates', '', -1);
699
700 if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
701 print load_fiche_titre('', $newcardbutton, '');
702 }
703}
704
705
706// Confirm deletion of record
707if ($action == 'delete') {
708 print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.((int) $rowid), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
709}
710
711
712$fieldlist = explode(',', $tabfield[25]);
713
714if ($action == 'create') {
715 // If data was already input, we define them in obj to populate input fields.
716 $obj = new stdClass();
717 $obj->label = GETPOST('label');
718 $obj->lang = GETPOST('lang');
719 $obj->type_template = GETPOST('type_template');
720 $obj->fk_user = GETPOSTINT('fk_user');
721 $obj->private = GETPOSTINT('private');
722 $obj->position = GETPOST('position');
723 $obj->topic = GETPOST('topic');
724 $obj->joinfiles = GETPOST('joinfiles');
725 $obj->defaultfortype = GETPOST('defaultfortype') ? 1 : 0;
726 $obj->content = GETPOST('content', 'restricthtml');
727
728 // Form to add a new line
729 print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
730 print '<input type="hidden" name="token" value="'.newToken().'">';
731 print '<input type="hidden" name="action" value="add">';
732 print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
733
734 print '<div class="div-table-responsive-no-min">';
735 print '<table class="noborder centpercent">';
736
737 // Line to enter new values (title)
738 print '<tr class="liste_titre">';
739 foreach ($fieldlist as $field => $value) {
740 // Determine le nom du champ par rapport aux noms possibles
741 // dans les dictionnaires de donnees
742 $valuetoshow = ucfirst($fieldlist[$field]); // Par default
743 $valuetoshow = $langs->trans($valuetoshow); // try to translate
744 $css = "left";
745 if ($fieldlist[$field] == 'module') {
746 $valuetoshow = '&nbsp;';
747 }
748 if ($fieldlist[$field] == 'fk_user') {
749 $valuetoshow = $langs->trans("Owner");
750 }
751 if ($fieldlist[$field] == 'lang') {
752 $valuetoshow = (!getDolGlobalInt('MAIN_MULTILANGS') ? '&nbsp;' : $langs->trans("Language"));
753 }
754 if ($fieldlist[$field] == 'type') {
755 $valuetoshow = $langs->trans("Type");
756 }
757 if ($fieldlist[$field] == 'position') {
758 $css = 'center';
759 }
760 if ($fieldlist[$field] == 'code') {
761 $valuetoshow = $langs->trans("Code");
762 }
763 if ($fieldlist[$field] == 'label') {
764 $valuetoshow = $langs->trans("Code");
765 }
766 if ($fieldlist[$field] == 'type_template') {
767 $valuetoshow = $langs->trans("TypeOfTemplate");
768 $css = "center";
769 }
770 if (in_array($fieldlist[$field], array('private', 'private', 'defaultfortype'))) {
771 $css = 'center';
772 }
773
774 if ($fieldlist[$field] == 'topic') {
775 $valuetoshow = '';
776 }
777 if ($fieldlist[$field] == 'joinfiles') {
778 $valuetoshow = '';
779 }
780 if ($fieldlist[$field] == 'content') {
781 $valuetoshow = '';
782 }
783 if ($fieldlist[$field] == 'content_lines') {
784 $valuetoshow = '';
785 }
786 if ($valuetoshow != '') {
787 print '<th class="'.$css.'">';
788 if (!empty($tabhelp[25][$value]) && preg_match('/^http(s*):/i', $tabhelp[25][$value])) {
789 print '<a href="'.$tabhelp[25][$value].'" target="_blank" rel="noopener noreferrer">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
790 } elseif (!empty($tabhelp[25][$value])) {
791 if (in_array($value, array('topic'))) {
792 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2, $value); // Tooltip on click
793 } else {
794 print $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2); // Tooltip on hover
795 }
796 } else {
797 print $valuetoshow;
798 }
799 print '</th>';
800 }
801 }
802 print '<th>';
803 print '</th>';
804 print '</tr>';
805
806 $tmpaction = 'create';
807 $parameters = array(
808 'fieldlist' => $fieldlist,
809 'tabname' => $tabname[25]
810 );
811 $reshook = $hookmanager->executeHooks('createEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
812 $error = $hookmanager->error;
813 $errors = $hookmanager->errors;
814
815
816 // Line to enter new values (input fields)
817 print '<tr class="oddeven">';
818
819 if (empty($reshook)) {
820 if ($action == 'edit') {
821 fieldList($fieldlist, $obj, $tabname[25], 'hide');
822 } else {
823 fieldList($fieldlist, $obj, $tabname[25], 'add');
824 }
825 }
826 // Action column
827 print '<td class="right">';
828 print '</td>';
829 print "</tr>";
830
831 print '<tr class="oddeven nodrag nodrop nohover"><td colspan="9">';
832
833 // Show fields for topic, join files and body
834 $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content');
835 if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
836 $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content', 'content_lines');
837 }
838 foreach ($fieldsforcontent as $tmpfieldlist) {
839 // Topic of email
840 if ($tmpfieldlist == 'topic') {
841 print '<strong>'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
842 }
843 if ($tmpfieldlist == 'email_from') {
844 print $form->textwithpicto($langs->trans("MailFrom"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist);
845 }
846 if ($tmpfieldlist == 'joinfiles') {
847 print '<strong>'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> ';
848 }
849 if ($tmpfieldlist == 'content') {
850 print $form->textwithpicto($langs->trans("Content"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
851 }
852 if ($tmpfieldlist == 'content_lines') {
853 print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
854 }
855
856 // Input field
857 if ($tmpfieldlist == 'topic') {
858 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '').'">';
859 } elseif ($tmpfieldlist == 'email_from') {
860 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="'.(!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '').'">';
861 } elseif ($tmpfieldlist == 'joinfiles') {
862 print $form->selectyesno($tmpfieldlist, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1);
863 } else {
864 $okforextended = true;
865 if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
866 $okforextended = false;
867 }
868 $doleditor = new DolEditor($tmpfieldlist, (!empty($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : ''), '', 400, 'dolibarr_mailings', 'In', false, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%');
869 print $doleditor->Create(1);
870 }
871 print '<br>';
872 }
873
874 print '</tr>';
875
876 print '</table>';
877
878 if ($action != 'edit') {
879 print '<center>';
880 print '<input type="submit" class="button button-add" name="actionadd" value="'.$langs->trans("Add").'"> ';
881 print '<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
882 print '</center>';
883 }
884
885 print '</div>';
886 print '</form>';
887
888 print '<br><br><br>';
889}
890
891// List of available record in database
892dol_syslog("htdocs/admin/dict", LOG_DEBUG);
893$resql = $db->query($sql);
894if (!$resql) {
895 dol_print_error($db);
896 exit;
897}
898
899$num = $db->num_rows($resql);
900
901print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
902print '<input type="hidden" name="token" value="'.newToken().'">';
903print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
904
905print '<div class="div-table-responsive-no-min">';
906print '<table class="noborder centpercent">';
907
908$i = 0;
909
910$param = '';
911if ($search_label) {
912 $param .= '&search_label='.urlencode($search_label);
913}
914if (!empty($search_lang) && $search_lang != '-1') {
915 $param .= '&search_lang='.urlencode($search_lang);
916}
917if ($search_type_template != '-1') {
918 $param .= '&search_type_template='.urlencode($search_type_template);
919}
920if ($search_fk_user > 0) {
921 $param .= '&search_fk_user='.urlencode($search_fk_user);
922}
923if ($search_module) {
924 $param .= '&search_module='.urlencode($search_module);
925}
926if ($search_topic) {
927 $param .= '&search_topic='.urlencode($search_topic);
928}
929
930$paramwithsearch = $param;
931if ($sortorder) {
932 $paramwithsearch .= '&sortorder='.urlencode($sortorder);
933}
934if ($sortfield) {
935 $paramwithsearch .= '&sortfield='.urlencode($sortfield);
936}
937if (GETPOST('from', 'alpha')) {
938 $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha'));
939}
940
941// There is several pages
942if ($num > $listlimit) {
943 print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
944 print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
945 print '</td></tr>';
946}
947
948
949// Title line with search boxes
950print '<tr class="liste_titre">';
951// Action column
952if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
953 print '<td class="liste_titre center" width="64">';
954 $searchpicto = $form->showFilterButtons();
955 print $searchpicto;
956 print '</td>';
957}
958foreach ($fieldlist as $field => $value) {
959 if ($value == 'module') {
960 print '<td class="liste_titre"><input type="text" name="search_module" class="maxwidth75" value="'.dol_escape_htmltag($search_module).'"></td>';
961 } elseif ($value == 'label') {
962 print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth75" value="'.dol_escape_htmltag($search_label).'"></td>';
963 } elseif ($value == 'lang') {
964 print '<td class="liste_titre">';
965 print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100');
966 print '</td>';
967 } elseif ($value == 'fk_user') {
968 print '<td class="liste_titre">';
969 print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth100', 1);
970 print '</td>';
971 } elseif ($value == 'topic') {
972 print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
973 } elseif ($value == 'type_template') {
974 print '<td class="liste_titre center">';
975 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
976 print $form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth125', 1, '', 0, 1);
977 print '</td>';
978 } elseif (!in_array($value, array('content', 'content_lines'))) {
979 print '<td class="liste_titre"></td>';
980 }
981}
982/*if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) {
983 print '<td class="liste_titre"></td>';
984}*/
985// Status
986print '<td></td>';
987// Action column
988if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
989 print '<td class="liste_titre center" width="64">';
990 $searchpicto = $form->showFilterButtons();
991 print $searchpicto;
992 print '</td>';
993}
994print '</tr>';
995
996// Title of lines
997print '<tr class="liste_titre">';
998// Action column
999if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1000 print getTitleFieldOfList('');
1001}
1002foreach ($fieldlist as $field => $value) {
1003 $showfield = 1; // By default
1004 $css = "left";
1005 $sortable = 1;
1006 $valuetoshow = '';
1007 $forcenowrap = 1;
1008 /*
1009 $tmparray=getLabelOfField($fieldlist[$field]);
1010 $showfield=$tmp['showfield'];
1011 $valuetoshow=$tmp['valuetoshow'];
1012 $css=$tmp['align'];
1013 $sortable=$tmp['sortable'];
1014 */
1015 $valuetoshow = ucfirst($fieldlist[$field]); // By default
1016 $valuetoshow = $langs->trans($valuetoshow); // try to translate
1017 if ($fieldlist[$field] == 'module') {
1018 $css = 'tdoverflowmax100';
1019 }
1020 if ($fieldlist[$field] == 'fk_user') {
1021 $valuetoshow = $langs->trans("Owner");
1022 }
1023 if ($fieldlist[$field] == 'lang') {
1024 $valuetoshow = $langs->trans("Language");
1025 }
1026 if ($fieldlist[$field] == 'type') {
1027 $valuetoshow = $langs->trans("Type");
1028 }
1029 if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
1030 $valuetoshow = $langs->trans("Code");
1031 }
1032 if ($fieldlist[$field] == 'type_template') {
1033 $css = 'center';
1034 $valuetoshow = $langs->trans("TypeOfTemplate");
1035 }
1036 if ($fieldlist[$field] == 'private') {
1037 $css = 'center';
1038 }
1039 if ($fieldlist[$field] == 'position') {
1040 $css = 'center';
1041 }
1042
1043 if ($fieldlist[$field] == 'joinfiles') {
1044 $valuetoshow = $langs->trans("FilesAttachedToEmail");
1045 $css = 'center';
1046 $forcenowrap = 0;
1047 }
1048 if ($fieldlist[$field] == 'content') {
1049 $valuetoshow = $langs->trans("Content");
1050 $showfield = 0;
1051 }
1052 if ($fieldlist[$field] == 'content_lines') {
1053 $valuetoshow = $langs->trans("ContentForLines");
1054 $showfield = 0;
1055 }
1056
1057 // Show fields
1058 if ($showfield) {
1059 if (!empty($tabhelp[25][$value])) {
1060 if (in_array($value, array('topic'))) {
1061 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2, 'tooltip'.$value, $forcenowrap); // Tooltip on click
1062 } else {
1063 $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[25][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover
1064 }
1065 }
1066 $sortfieldtouse = ($sortable ? $fieldlist[$field] : '');
1067 if ($sortfieldtouse == 'type_template') {
1068 $sortfieldtouse .= ',lang,position,label';
1069 }
1070 print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $css.' ');
1071 }
1072}
1073
1074print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
1075// Action column
1076if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1077 print getTitleFieldOfList('');
1078}
1079print '</tr>';
1080
1081if ($num) {
1082 $nbqualified = 0;
1083
1084 // Lines with values
1085 while ($i < $num) {
1086 $obj = $db->fetch_object($resql);
1087
1088 if ($obj) {
1089 if (($action == 'edit' || $action == 'preview') && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
1090 print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
1091
1092 $tmpaction = 'edit';
1093 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[25]);
1094 $reshook = $hookmanager->executeHooks('editEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1095 $error = $hookmanager->error;
1096 $errors = $hookmanager->errors;
1097
1098 // Action column
1099 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1100 print '<td class="center">';
1101 print '<input type="hidden" name="page" value="'.$page.'">';
1102 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
1103 if ($action == 'edit') {
1104 print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">';
1105 }
1106 print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
1107 print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
1108 print '</td>';
1109 }
1110 // Show main fields
1111 if (empty($reshook)) {
1112 fieldList($fieldlist, $obj, $tabname[25], $action);
1113 }
1114 // Action column
1115 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1116 print '<td class="center">';
1117 print '<input type="hidden" name="page" value="'.$page.'">';
1118 print '<input type="hidden" name="rowid" value="'.$rowid.'">';
1119 if ($action == 'edit') {
1120 print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">';
1121 }
1122 print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
1123 print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">';
1124 print '</td>';
1125 }
1126 print "</tr>\n";
1127
1128 print '<tr class="oddeven nohover" id="tr-aaa-'.$rowid.'">';
1129 print '<td colspan="10">';
1130
1131 $fieldsforcontent = array('topic', 'email_from','joinfiles', 'content');
1132 if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) {
1133 $fieldsforcontent[] = 'content_lines';
1134 }
1135
1136 $parameters = array('fieldsforcontent' => &$fieldsforcontent, 'tabname' => $tabname[$id]);
1137 $hookmanager->executeHooks('editEmailTemplateFieldsForContent', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1138
1139 foreach ($fieldsforcontent as $tmpfieldlist) {
1140 $showfield = 1;
1141 $css = "left";
1142 $valuetoshow = $obj->$tmpfieldlist;
1143
1144 $class = 'tddict';
1145 // Show value for field
1146 if ($showfield) {
1147 // Show line for topic, joinfiles and content
1148 if ($tmpfieldlist == 'topic') {
1149 print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1150 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>';
1151 print '<br>'."\n";
1152 }
1153 if ($tmpfieldlist == 'email_from') {
1154 print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("MailFrom"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1155 print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>';
1156 print '<br>'."\n";
1157 }
1158 if ($tmpfieldlist == 'joinfiles') {
1159 print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> ';
1160 print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, ($action != 'edit'), 0, 1);
1161 print '<br>'."\n";
1162 }
1163
1164 if ($tmpfieldlist == 'content') {
1165 print $form->textwithpicto($langs->trans("Content"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
1166 $okforextended = true;
1167 if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
1168 $okforextended = false;
1169 }
1170 $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%', ($action != 'edit' ? 1 : 0));
1171 print $doleditor->Create(1);
1172 }
1173 if ($tmpfieldlist == 'content_lines') {
1174 print '<br>'."\n";
1175 print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[25][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
1176 $okforextended = true;
1177 if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) {
1178 $okforextended = false;
1179 }
1180 $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 140, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%');
1181 print $doleditor->Create(1);
1182 }
1183 }
1184 }
1185 print '</td>';
1186 print '<td></td>';
1187 print '<td></td>';
1188
1189 print "</tr>\n";
1190
1191 $nbqualified++;
1192 } else {
1193 // If template is for a module, check module is enabled.
1194 if ($obj->module) {
1195 $tempmodulekey = $obj->module;
1196 if (empty($conf->$tempmodulekey) || !isModEnabled($tempmodulekey)) {
1197 $i++;
1198 continue;
1199 }
1200 }
1201
1202 $keyforobj = 'type_template';
1203 if (!in_array($obj->$keyforobj, array_keys($elementList))) {
1204 $i++;
1205 continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled)
1206 }
1207 // Test on 'enabled'
1208 if (! (int) dol_eval($obj->enabled, 1, 1, '1')) {
1209 $i++;
1210 continue; // Email template not qualified
1211 }
1212
1213 $nbqualified++;
1214
1215 // Can an entry be erased or disabled ?
1216 $iserasable = 1;
1217 $canbedisabled = 1;
1218 $canbemodified = 1; // true by default
1219 if (!$user->admin && $obj->fk_user != $user->id) {
1220 $iserasable = 0;
1221 $canbedisabled = 0;
1222 $canbemodified = 0;
1223 }
1224
1225 $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).(!empty($obj->code) ? '&code='.urlencode($obj->code) : '');
1226 if ($param) {
1227 $url .= '&'.$param;
1228 }
1229
1230 print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
1231
1232 // Action column - Modify link / Delete link
1233 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1234 print '<td class="center nowraponall" width="64">';
1235 if ($canbemodified) {
1236 print '<a class="reposition editfielda" href="'.$url.'&action=edit&token='.newToken().'">'.img_edit().'</a>';
1237 } else {
1238 print '<a class="reposition editfielda" href="'.$url.'&action=preview&token='.newToken().'">'.img_view().'</a>';
1239 }
1240 if ($iserasable) {
1241 print '<a class="reposition marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a>';
1242 //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
1243 }
1244 print '</td>';
1245 }
1246
1247 $tmpaction = 'view';
1248 $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[25]);
1249 $reshook = $hookmanager->executeHooks('viewEmailTemplateFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
1250
1251 $error = $hookmanager->error;
1252 $errors = $hookmanager->errors;
1253
1254 if (empty($reshook)) {
1255 foreach ($fieldlist as $field => $value) {
1256 if (in_array($fieldlist[$field], array('content', 'content_lines'))) {
1257 continue;
1258 }
1259 $showfield = 1;
1260 $css = "";
1261 $class = "tddict";
1262 $title = '';
1263 $tmpvar = $fieldlist[$field];
1264 $valuetoshow = $obj->$tmpvar;
1265 if ($value == 'label' || $value == 'topic') {
1266 if ($langs->trans($valuetoshow) != $valuetoshow) {
1267 $valuetoshow = $langs->trans($valuetoshow);
1268 }
1269 $valuetoshow = dol_escape_htmltag($valuetoshow);
1270 }
1271 if ($value == 'label') {
1272 $class .= ' tdoverflowmax200';
1273 }
1274 if ($value == 'topic') {
1275 $class .= ' tdoverflowmax200 small';
1276 }
1277 if ($value == 'type_template') {
1278 $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
1279 $css = "center tdoverflowmax150";
1280 }
1281 if ($value == 'lang' && $valuetoshow) {
1282 $valuetoshow = $valuetoshow.' - '.$langs->trans("Language_".$valuetoshow);
1283 $class .= ' tdoverflowmax100';
1284 }
1285 if ($value == 'fk_user') {
1286 if ($valuetoshow > 0) {
1287 $fuser = new User($db);
1288 $fuser->fetch($valuetoshow);
1289 $valuetoshow = $fuser->getNomUrl(-1);
1290 $class .= ' tdoverflowmax100';
1291 }
1292 }
1293 if ($value == 'private') {
1294 $css = "center";
1295 if ($valuetoshow) {
1296 $valuetoshow = yn($valuetoshow);
1297 } else {
1298 $valuetoshow = '';
1299 }
1300 }
1301 if ($value == 'position') {
1302 $css = "center";
1303 }
1304 if (in_array($value, array('joinfiles', 'defaultfortype'))) {
1305 $css = "center";
1306 if ($valuetoshow) {
1307 //$valuetoshow = yn(1);
1308 $valuetoshow = '<input type="checkbox" checked="checked" disabled>';
1309 } else {
1310 $valuetoshow = '';
1311 }
1312 }
1313 if ($css) {
1314 $class .= ' '.$css;
1315 }
1316
1317 // Show value for field
1318 if ($showfield) {
1319 print '<!-- '.$fieldlist[$field].' -->';
1320 print '<td class="'.$class.'"';
1321 if (in_array($value, array('code', 'label', 'topic'))) {
1322 print ' title="'.dol_escape_htmltag($valuetoshow).'"';
1323 }
1324 print '>';
1325 print $valuetoshow;
1326 print '</td>';
1327 }
1328 }
1329 }
1330
1331 // Status / Active
1332 print '<td class="center nowrap">';
1333 if ($canbedisabled) {
1334 print '<a class="reposition" href="'.$url.'&action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
1335 } else {
1336 print '<span class="opacitymedium">'.$actl[$obj->active].'</span>';
1337 }
1338 print "</td>";
1339
1340 // Action column - Modify link / Delete link
1341 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
1342 print '<td class="center nowraponall" width="64">';
1343 if ($canbemodified) {
1344 print '<a class="reposition editfielda" href="'.$url.'&action=edit&token='.newToken().'">'.img_edit().'</a>';
1345 }
1346 if ($iserasable) {
1347 print '<a class="reposition marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a>';
1348 //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
1349 }
1350 print '</td>';
1351 }
1352
1353 print "</tr>\n";
1354 }
1355 }
1356
1357 $i++;
1358 }
1359}
1360
1361// If no record found
1362if ($nbqualified == 0) {
1363 $colspan = 12;
1364 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1365}
1366
1367print '</table>';
1368print '</div>';
1369
1370print '</form>';
1371
1372
1373if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) {
1374 print dol_get_fiche_end();
1375}
1376
1377
1378// End of page
1379llxFooter();
1380$db->close();
1381
1382
1392function fieldList($fieldlist, $obj = null, $tabname = '', $context = '')
1393{
1394 global $langs, $user, $db;
1395 global $form;
1396 global $elementList;
1397
1398 $formadmin = new FormAdmin($db);
1399
1400 foreach ($fieldlist as $field => $value) {
1401 //print $value;
1402 if ($value == 'module') {
1403 print '<td></td>';
1404 } elseif ($value == 'fk_user') {
1405 print '<td>';
1406 if ($user->admin && $context != 'preview') {
1407 print $form->select_dolusers(GETPOSTISSET('fk_user') ? GETPOSTINT('fk_user') : (empty($obj->$value) ? '' : $obj->$value), 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth75 maxwidth100');
1408 } else {
1409 if ($context == 'add') { // I am not admin and we show the add form
1410 print $user->getNomUrl(-1); // Me
1411 $forcedvalue = $user->id;
1412 } else {
1413 if ($obj && !empty($obj->$value) && $obj->$value > 0) {
1414 $fuser = new User($db);
1415 $fuser->fetch($obj->$value);
1416 print $fuser->getNomUrl(-1);
1417 $forcedvalue = $fuser->id;
1418 } else {
1419 $forcedvalue = $obj->$value;
1420 }
1421 }
1422 $keyname = $value;
1423 print '<input type="hidden" value="'.$forcedvalue.'" name="'.$keyname.'">';
1424 }
1425 print '</td>';
1426 } elseif ($value == 'lang') {
1427 print '<td>';
1428 if (getDolGlobalInt('MAIN_MULTILANGS') && $context != 'preview') {
1429 $selectedlang = GETPOSTISSET('langcode') ? GETPOST('langcode', 'aZ09') : $langs->defaultlang;
1430 if ($context == 'edit') {
1431 $selectedlang = $obj->lang;
1432 }
1433 print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth100');
1434 } else {
1435 if (!empty($obj->lang)) {
1436 print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang);
1437 }
1438 $keyname = $value;
1439 if ($keyname == 'lang') {
1440 $keyname = 'langcode'; // Avoid conflict with lang param
1441 }
1442 print '<input type="hidden" value="'.(empty($obj->lang) ? '' : $obj->lang).'" name="'.$keyname.'">';
1443 }
1444 print '</td>';
1445 } elseif ($value == 'type_template') {
1446 // Le type de template
1447 print '<td class="center">';
1448 if (($context == 'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) || $context == 'preview') {
1449 // Current template type is an unknown type, so we must keep it as it is.
1450 print '<input type="hidden" name="type_template" value="'.$obj->type_template.'">';
1451 print $obj->type_template;
1452 } else {
1453 print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template : ''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth75 maxwidth125', 1, '', 0, 1);
1454 }
1455 print '</td>';
1456 } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1457 //print '<td></td>';
1458 } elseif ($context == 'edit' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1459 print '<td></td>';
1460 } elseif ($context == 'preview' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1461 print '<td></td>';
1462 } elseif ($context == 'hide' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) {
1463 //print '<td></td>';
1464 } else {
1465 $size = '';
1466 $class = '';
1467 $classtd = '';
1468 if ($value == 'code') {
1469 $class = 'maxwidth100';
1470 }
1471 if ($value == 'label') {
1472 $class = 'maxwidth200';
1473 }
1474 if ($value == 'private') {
1475 $class = 'maxwidth50';
1476 $classtd = 'center';
1477 }
1478 if ($value == 'position') {
1479 $class = 'maxwidth50 center';
1480 $classtd = 'center';
1481 }
1482 if ($value == 'topic') {
1483 $class = 'quatrevingtpercent';
1484 }
1485 if ($value == 'defaultfortype') {
1486 $class = 'width25 center';
1487 $classtd = 'center';
1488 }
1489
1490 print '<td'.($classtd ? ' class="'.$classtd.'"' : '').'>';
1491 if ($value == 'private' && $context != 'preview') {
1492 if (empty($user->admin)) {
1493 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1494 print $form->selectyesno($value, GETPOSTISSET($value) ? GETPOSTINT($value) : (($context != 'add' && isset($obj->$value)) ? $obj->$value : '1'), 1, false, 0, 1);
1495 } else {
1496 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
1497 print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value : ''), 1, false, 0, 1);
1498 }
1499 } else {
1500 print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->$value) ? $obj->$value : '').'" name="'. $value .'"'.($context == 'preview' ? ' disabled' : '').'>';
1501 }
1502 print '</td>';
1503 }
1504 }
1505}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
email_admin_prepare_head()
Return array head with list of tabs to view object information.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage a WYSIWYG editor.
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
static getAvailableSubstitKey($mode='formemail', $object=null)
Get list of substitution keys available for emails.
Object of table llx_c_email_templates.
Class to manage Dolibarr users.
acceptLocalLinktoMedia()
Check the syntax of some PHP code.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
print_fleche_navigation($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0, $beforearrows='', $hidenavigation=0)
Function to show navigation arrows into lists.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_view($titlealt='default', $float=0, $other='class="valignmiddle"')
Show logo view card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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...
fieldList($fieldlist, $obj=null, $tabname='', $context='')
Show fields in insert/edit mode.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.