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