diff --git a/dev/tools/codespell/codespell-dict.txt b/dev/tools/codespell/codespell-dict.txt index c40c7608602..dce7bdff144 100644 --- a/dev/tools/codespell/codespell-dict.txt +++ b/dev/tools/codespell/codespell-dict.txt @@ -11,6 +11,7 @@ aplphanothtml->alphanohtml choosed->chosen dokument->document dolibar->dolibarr +dolibarrr->dolibarr dollibar->dolibarr dollibarr->dolibarr # fiche->card diff --git a/dev/tools/codespell/codespell-lines-ignore.txt b/dev/tools/codespell/codespell-lines-ignore.txt index 80e4f25e296..5fa92f8c13e 100644 --- a/dev/tools/codespell/codespell-lines-ignore.txt +++ b/dev/tools/codespell/codespell-lines-ignore.txt @@ -326,6 +326,7 @@ $usercanread = (($user->hasRight('stock', 'mouvement', 'lire'))); * The hook contaxt thirdpartycard has been renamed thirdpartycontact * The private array ->status_short, ->statuts and ->status_long are now array ->labelStatusShort and ->labelStatus everywhere. - New: Add proposals into referer page of thirdparty. +AmountIn NEW: ModuleBuilder: Checkin comments begin and end before each actions for /F "tokens=2 delims=," %%i in ('tasklist /FI "IMAGENAME eq php.exe" /FO CSV /NH') do ( foreach ($TWeek as $week_number) { diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index d54fdc2363c..3e73236ccf5 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -79,7 +79,6 @@ return [ 'htdocs/core/modules/societe/modules_societe.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSignatureMismatch', 'PhanParamSuspiciousOrder'], 'htdocs/core/modules/syslog/mod_syslog_syslog.php' => ['PhanParamSignatureMismatch'], - 'htdocs/core/triggers/interface_80_modStripe_Stripe.class.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchPropertyProbablyReal'], 'htdocs/don/class/don.class.php' => ['PhanParamTooMany'], 'htdocs/expedition/class/api_shipments.class.php' => ['PhanTypeMismatchReturn'], 'htdocs/expensereport/class/api_expensereports.class.php' => ['PhanTypeMismatchReturn'], diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 8dcbff61b8d..59a412fa3a4 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -2,6 +2,7 @@ /* Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2024 Alexandre Spangaro * Copyright (C) 2014 Florian Henry + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -241,7 +242,7 @@ if ($action == 'create') { // Account parent print ''.$langs->trans("Accountparent").''; print ''; - print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200'); + print $formaccounting->select_account($object->account_parent, 'account_parent', 1, [], 0, 0, 'minwidth200'); print ''; // Chart of accounts type diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 465f2836122..0231856071a 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -2,6 +2,7 @@ /* Copyright (C) 2016 Jamal Elbaz * Copyright (C) 2017-2024 Alexandre Spangaro * Copyright (C) 2022 Laurent Destailleur + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -164,7 +165,7 @@ if (!empty($cat_id)) { if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwith"'); - print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories")); + print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), 0, 0, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories")); print ' '; } } diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 8204c4ba6a2..2f1b22cf778 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -1,6 +1,7 @@ * Copyright (C) 2011-2024 Alexandre Spangaro + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -305,9 +306,9 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } -if (GETPOST('actioncancel', 'alpha')) { - //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition -} +// if (GETPOST('actioncancel', 'alpha')) { +// $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition +// } if ($action == 'confirm_delete' && $confirm == 'yes') { // delete $rowidcol = "rowid"; diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 9853dd08bf1..5d5269892bd 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -24,7 +24,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } $code = getDolGlobalString('MAIN_INFO_ACCOUNTANT_CODE'); diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php index 419b32f3c34..582d2eb2499 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php @@ -19,7 +19,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } ?> diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php index 9056ff201e4..88631d23a40 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php @@ -19,7 +19,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 1ad9e4ff3d4..6417e6a32b2 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -19,7 +19,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 5582c60e30f..62a3a08aa49 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -21,7 +21,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } echo "\n"; diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index f6e6361fa34..839125a8da3 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -104,7 +104,7 @@ if ($action == 'updateMask') { } } elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey)."_ADDON"; dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); @@ -115,7 +115,7 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (getDolGlobalString($constforval) == "$value") { @@ -125,7 +125,7 @@ if ($action == 'updateMask') { } }/* elseif ($action == 'setdoc') { // Set or unset default model - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { @@ -141,7 +141,7 @@ if ($action == 'updateMask') { } } } elseif ($action == 'unsetdoc') { - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'EVENTORGANIZATION_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index fecafa518f5..c55622f1a11 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -69,7 +69,12 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $moduledir = 'hrm'; $myTmpObjects = array(); // TODO Scan list of objects to fill this array -$myTmpObjects['evaluation'] = array('label' => 'Evaluation', 'includerefgeneration' => 1, 'includedocgeneration' => 0); +$myTmpObjects['evaluation'] = array('label' => 'Evaluation', 'includerefgeneration' => 1, 'includedocgeneration' => 0, 'class' => 'Evaluation'); + +$tmpobjectkey = GETPOST('object', 'aZ09'); +if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) { + accessforbidden('Bad value for object. Hack attempt ?'); +} /* @@ -112,47 +117,43 @@ if ($action == 'update') { } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') { +} elseif ($action == 'specimen' && $tmpobjectkey) { $modele = GETPOST('module', 'alpha'); - $tmpobjectkey = GETPOST('object', 'aZ09'); - if (array_key_exists($tmpobjectkey, $myTmpObjects)) { - $nameofclass = ucfirst($tmpobjectkey); - $tmpobject = new $nameofclass($db); - $tmpobject->initAsSpecimen(); + $className = $myTmpObjects[$tmpobjectkey]['class']; + $tmpobject = new $className($db); + $tmpobject->initAsSpecimen(); - // Search template files - $file = ''; - $classname = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); - if (file_exists($file)) { - $classname = "pdf_".$modele; - break; - } + // Search template files + $file = ''; + $classname = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/hrm/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); + if (file_exists($file)) { + $classname = "pdf_".$modele; + break; } + } - if ($classname !== '') { - require_once $file; + if ($classname !== '') { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($tmpobject, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, null, 'errors'); - dol_syslog($module->error, LOG_ERR); - } + if ($module->write_file($tmpobject, $langs) > 0) { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + return; } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey)."_ADDON"; dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); @@ -163,7 +164,6 @@ if ($action == 'update') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (getDolGlobalString($constforval) == "$value") { @@ -173,7 +173,6 @@ if ($action == 'update') { } } elseif ($action == 'setdoc') { // Set or unset default model - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { @@ -189,7 +188,6 @@ if ($action == 'update') { } } } elseif ($action == 'unsetdoc') { - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'HRMTEST_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index 731f703f1cd..ef80a03cbcb 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -63,11 +63,20 @@ if (!$user->admin) { accessforbidden(); } +if (!getDolGlobalString('KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON')) { + $conf->global->KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_ADDON = 'mod_knowledgerecord_standard'; +} + $moduledir = 'knowledgemanagement'; $myTmpObjects = array(); // TODO Scan list of objects to fill this array $myTmpObjects['knowledgemanagement'] = array('label' => 'KnowledgeManagement', 'includerefgeneration' => 1, 'includedocgeneration' => 0, 'class' => 'KnowledgeRecord'); +$tmpobjectkey = GETPOST('object', 'aZ09'); +if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) { + accessforbidden('Bad value for object. Hack attempt ?'); +} + /* * Actions @@ -91,47 +100,43 @@ if ($action == 'updateMask') { } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') { +} elseif ($action == 'specimen' && $tmpobjectkey) { $modele = GETPOST('module', 'alpha'); - $tmpobjectkey = GETPOST('object', 'aZ09'); - if (array_key_exists($tmpobjectkey, $myTmpObjects)) { - $className = $myTmpObjects[$tmpobjectkey]['class']; - $tmpobject = new $className($db); - $tmpobject->initAsSpecimen(); + $className = $myTmpObjects[$tmpobjectkey]['class']; + $tmpobject = new $className($db); + $tmpobject->initAsSpecimen(); - // Search template files - $file = ''; - $className = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/knowledgemanagement/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); - if (file_exists($file)) { - $className = "pdf_".$modele; - break; - } + // Search template files + $file = ''; + $className = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/knowledgemanagement/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); + if (file_exists($file)) { + $className = "pdf_".$modele; + break; } + } - if ($className !== '') { - require_once $file; + if ($className !== '') { + require_once $file; - $module = new $className($db); + $module = new $className($db); - if ($module->write_file($tmpobject, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, null, 'errors'); - dol_syslog($module->error, LOG_ERR); - } + if ($module->write_file($tmpobject, $langs) > 0) { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + return; } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey)."_ADDON"; dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); @@ -142,7 +147,7 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (getDolGlobalString($constforval) == "$value") { @@ -152,7 +157,6 @@ if ($action == 'updateMask') { } } elseif ($action == 'setdoc') { // Set or unset default model - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { @@ -168,7 +172,6 @@ if ($action == 'updateMask') { } } } elseif ($action == 'unsetdoc') { - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'KNOWLEDGEMANAGEMENT_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index 879c17af00d..a0ef3ee897c 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -92,7 +92,7 @@ if ($action == 'updateMask') { } } elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey)."_ADDON"; dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); @@ -103,7 +103,7 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (getDolGlobalString($constforval) == "$value") { @@ -113,7 +113,7 @@ if ($action == 'updateMask') { } } elseif ($action == 'setdoc') { // Set or unset default model - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { @@ -129,7 +129,7 @@ if ($action == 'updateMask') { } } } elseif ($action == 'unsetdoc') { - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'WEBHOOK_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index c98e036c1d3..11d0b08e7f3 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -53,8 +53,12 @@ if (!$user->admin) { $moduledir = 'workstation'; $myTmpObjects = array(); -$myTmpObjects['workstation'] = array('includerefgeneration' => 1, 'includedocgeneration' => 0); +$myTmpObjects['workstation'] = array('label' => 'Workstation', 'includerefgeneration' => 1, 'includedocgeneration' => 0, 'class' => 'Workstation'); +$tmpobjectkey = GETPOST('object', 'aZ09'); +if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) { + accessforbidden('Bad value for object. Hack attempt ?'); +} /* @@ -82,48 +86,43 @@ if ($action == 'updateMask') { } } elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); - $tmpobjectkey = GETPOST('object', 'aZ09'); - if (array_key_exists($tmpobjectkey, $myTmpObjects)) { - $nameofclass = ucfirst($tmpobjectkey); - $tmpobject = new $nameofclass($db); - $tmpobject->initAsSpecimen(); + $nameofclass = ucfirst($tmpobjectkey); + $tmpobject = new $nameofclass($db); + $tmpobject->initAsSpecimen(); - // Search template files - $file = ''; - $classname = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/workstation/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); - if (file_exists($file)) { - $classname = "pdf_".$modele; - break; - } + // Search template files + $file = ''; + $classname = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/workstation/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); + if (file_exists($file)) { + $classname = "pdf_".$modele; + break; } + } - if ($classname !== '') { - require_once $file; + if ($classname !== '') { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($tmpobject, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, null, 'errors'); - dol_syslog($module->error, LOG_ERR); - } + if ($module->write_file($tmpobject, $langs) > 0) { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + return; } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } elseif ($action == 'set') { // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); } elseif ($action == 'del') { - $tmpobjectkey = GETPOST('object'); - $ret = delDocumentModel($value, $type); if ($ret > 0) { $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; @@ -133,7 +132,6 @@ if ($action == 'updateMask') { } } elseif ($action == 'setdoc') { // Set default model - $tmpobjectkey = GETPOST('object'); $constforval = strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { // The constant that was read before the new set @@ -149,7 +147,6 @@ if ($action == 'updateMask') { } elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated // by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); $constforval = 'WORKSTATION_'.strtoupper($tmpobjectkey)."_ADDON"; dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/ai/admin/custom_prompt.php b/htdocs/ai/admin/custom_prompt.php index 5836a0d5b26..83506888d74 100644 --- a/htdocs/ai/admin/custom_prompt.php +++ b/htdocs/ai/admin/custom_prompt.php @@ -207,7 +207,7 @@ if ($action == 'deleteproperty') { } if ($action == 'edit') { - $out .= '
'; + $out = ''; $out .= ''; $out .= ''; diff --git a/htdocs/ai/admin/setup.php b/htdocs/ai/admin/setup.php index a2bb8f77a23..e74f3c3b5d9 100644 --- a/htdocs/ai/admin/setup.php +++ b/htdocs/ai/admin/setup.php @@ -88,68 +88,6 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'aZ09'); - $maskvalue = GETPOST('maskvalue', 'alpha'); - - if ($maskconst && preg_match('/_MASK$/', $maskconst)) { - $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } - } - - if (!$error) { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans("Error"), null, 'errors'); - } -} elseif ($action == 'setmod') { - // TODO Check if numbering module chosen can be activated by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); - if (!empty($tmpobjectkey)) { - $constforval = 'Ai_'.strtoupper($tmpobjectkey)."_ADDON"; - dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); - } -} elseif ($action == 'set') { - // Activate a model - $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') { - $ret = delDocumentModel($value, $type); - if ($ret > 0) { - $tmpobjectkey = GETPOST('object'); - if (!empty($tmpobjectkey)) { - $constforval = 'Ai_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if (getDolGlobalString($constforval) == "$value") { - dolibarr_del_const($db, $constforval, $conf->entity); - } - } - } -} elseif ($action == 'setdoc') { - // Set or unset default model - $tmpobjectkey = GETPOST('object'); - if (!empty($tmpobjectkey)) { - $constforval = 'Ai_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { - // The constant that was read before the new set - // We therefore requires a variable to have a coherent view - $conf->global->$constforval = $value; - } - - // We disable/enable the document template (into llx_document_model table) - $ret = delDocumentModel($value, $type); - if ($ret > 0) { - $ret = addDocumentModel($value, $type, $label, $scandir); - } - } -} elseif ($action == 'unsetdoc') { - $tmpobjectkey = GETPOST('object'); - if (!empty($tmpobjectkey)) { - $constforval = 'Ai_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - dolibarr_del_const($db, $constforval, $conf->entity); - } -} - $action = 'edit'; diff --git a/htdocs/ai/ajax/generate_content.php b/htdocs/ai/ajax/generate_content.php index bba1402d340..ad854743b20 100644 --- a/htdocs/ai/ajax/generate_content.php +++ b/htdocs/ai/ajax/generate_content.php @@ -69,7 +69,7 @@ $generatedContent = $ai->generateContent($instructions, 'auto', $function, $form if (is_array($generatedContent) && $generatedContent['error']) { // Output error - if ($generatedContent['code'] == 429) { + if (!empty($generatedContent['code']) && $generatedContent['code'] == 429) { print "Quota or allowed period exceeded. Retry Later !"; } elseif ($generatedContent['code'] >= 400) { print "Error : " . $generatedContent['message']; diff --git a/htdocs/ai/class/ai.class.php b/htdocs/ai/class/ai.class.php index 68002b62bb8..7b46636c411 100644 --- a/htdocs/ai/class/ai.class.php +++ b/htdocs/ai/class/ai.class.php @@ -28,6 +28,7 @@ class Ai * @var DoliDB $db Database object */ protected $db; + /** * @var string $apiEndpoint */ @@ -131,9 +132,12 @@ class Ai 'Authorization: Bearer ' . $this->apiKey, 'Content-Type: application/json' ]); - $response = getURLContent($this->apiEndpoint, 'POST', $payload, $headers); + $response = getURLContent($this->apiEndpoint, 'POST', $payload, 1, $headers); - if ($response['http_code'] != 200) { + if (empty($response['http_code'])) { + throw new Exception('API request failed. No http received'); + } + if (!empty($response['http_code']) && $response['http_code'] != 200) { throw new Exception('API request failed with status code ' . $response['http_code']); } // Decode JSON response @@ -149,7 +153,17 @@ class Ai return $generatedEmailContent; } catch (Exception $e) { - return array('error' => true, 'message' => $e->getMessage()); + $errormessage = $e->getMessage(); + if (!empty($response['content'])) { + $decodedResponse = json_decode($response['content'], true); + + // With OpenAI, error is into an object error into the content + if (!empty($decodedResponse['error']['message'])) { + $errormessage .= ' - '.$decodedResponse['error']['message']; + } + } + + return array('error' => true, 'message' => $errormessage, 'code' => (empty($response['http_code']) ? 0 : $response['http_code']), 'curl_error_no' => (empty($response['curl_error_no']) ? $response['curl_error_no'] : '')); } } } diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 5850128b3d2..0016c5e82e5 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -66,7 +66,12 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $moduledir = 'asset'; $myTmpObjects = array(); -$myTmpObjects['Asset'] = array('includerefgeneration' => 1, 'includedocgeneration' => 0); +$myTmpObjects['asset'] = array('label' => 'Asset', 'includerefgeneration' => 1, 'includedocgeneration' => 0, 'class' => 'Asset'); + +$tmpobjectkey = GETPOST('object', 'aZ09'); +if ($tmpobjectkey && !array_key_exists($tmpobjectkey, $myTmpObjects)) { + accessforbidden('Bad value for object. Hack attempt ?'); +} /* @@ -91,47 +96,43 @@ if ($action == 'updateMask') { } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') { +} elseif ($action == 'specimen' && $tmpobjectkey) { $modele = GETPOST('module', 'alpha'); - $tmpobjectkey = GETPOST('object', 'aZ09'); - if (array_key_exists($tmpobjectkey, $myTmpObjects)) { - $nameofclass = ucfirst($tmpobjectkey); - $tmpobject = new $nameofclass($db); - $tmpobject->initAsSpecimen(); + $className = $myTmpObjects[$tmpobjectkey]['class']; + $tmpobject = new $className($db); + $tmpobject->initAsSpecimen(); - // Search template files - $file = ''; - $classname = ''; - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $file = dol_buildpath($reldir."core/modules/asset/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); - if (file_exists($file)) { - $classname = "pdf_".$modele; - break; - } + // Search template files + $file = ''; + $classname = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir."core/modules/asset/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); + if (file_exists($file)) { + $classname = "pdf_".$modele; + break; } + } - if ($classname !== '') { - require_once $file; + if ($classname !== '') { + require_once $file; - $module = new $classname($db); + $module = new $classname($db); - if ($module->write_file($tmpobject, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); - return; - } else { - setEventMessages($module->error, null, 'errors'); - dol_syslog($module->error, LOG_ERR); - } + if ($module->write_file($tmpobject, $langs) > 0) { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + return; } else { - setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); - dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); } + } else { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'ASSET_'.strtoupper($tmpobjectkey)."_ADDON"; dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); @@ -142,7 +143,6 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (getDolGlobalString($constforval) == "$value") { @@ -152,7 +152,6 @@ if ($action == 'updateMask') { } } elseif ($action == 'setdoc') { // Set or unset default model - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { @@ -168,7 +167,6 @@ if ($action == 'updateMask') { } } } elseif ($action == 'unsetdoc') { - $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); @@ -201,11 +199,7 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "asse echo ''.$langs->trans("AssetSetupPage").''; - foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { - if ($myTmpObjectKey == 'MyObject') { - continue; - } if ($myTmpObjectArray['includerefgeneration']) { /* * Assets Numbering model @@ -278,7 +272,8 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { } print ''; - $mytmpinstance = new $myTmpObjectKey($db); + $className = $myTmpObjectArray['class']; + $mytmpinstance = new $className($db); $mytmpinstance->initAsSpecimen(); // Info diff --git a/htdocs/asset/tpl/accountancy_codes_edit.tpl.php b/htdocs/asset/tpl/accountancy_codes_edit.tpl.php index 93a261c442a..d0bd4f0c468 100644 --- a/htdocs/asset/tpl/accountancy_codes_edit.tpl.php +++ b/htdocs/asset/tpl/accountancy_codes_edit.tpl.php @@ -27,7 +27,7 @@ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } if (!is_object($form)) { diff --git a/htdocs/asset/tpl/accountancy_codes_view.tpl.php b/htdocs/asset/tpl/accountancy_codes_view.tpl.php index 16c333b8c6b..b48f642c4c2 100644 --- a/htdocs/asset/tpl/accountancy_codes_view.tpl.php +++ b/htdocs/asset/tpl/accountancy_codes_view.tpl.php @@ -28,7 +28,7 @@ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } if (!is_object($form)) { diff --git a/htdocs/asset/tpl/depreciation_options_edit.tpl.php b/htdocs/asset/tpl/depreciation_options_edit.tpl.php index ea55ab5999a..2741da86c2b 100644 --- a/htdocs/asset/tpl/depreciation_options_edit.tpl.php +++ b/htdocs/asset/tpl/depreciation_options_edit.tpl.php @@ -27,7 +27,7 @@ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } if (!is_object($form)) { diff --git a/htdocs/asset/tpl/depreciation_options_view.tpl.php b/htdocs/asset/tpl/depreciation_options_view.tpl.php index d7350801020..c801d74505e 100644 --- a/htdocs/asset/tpl/depreciation_options_view.tpl.php +++ b/htdocs/asset/tpl/depreciation_options_view.tpl.php @@ -28,7 +28,7 @@ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } if (!is_object($form)) { diff --git a/htdocs/asset/tpl/depreciation_view.tpl.php b/htdocs/asset/tpl/depreciation_view.tpl.php index 2660fbbaee7..424d989665f 100644 --- a/htdocs/asset/tpl/depreciation_view.tpl.php +++ b/htdocs/asset/tpl/depreciation_view.tpl.php @@ -27,7 +27,7 @@ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } if (!is_object($form)) { diff --git a/htdocs/asset/tpl/linkedobjectblock.tpl.php b/htdocs/asset/tpl/linkedobjectblock.tpl.php index 7dddd8cbeb1..0e8d62a6921 100644 --- a/htdocs/asset/tpl/linkedobjectblock.tpl.php +++ b/htdocs/asset/tpl/linkedobjectblock.tpl.php @@ -20,7 +20,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } print "\n"; diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index 082936be50a..3ededc6bffa 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -21,7 +21,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } print "\n"; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 5535f3dbf5a..2d456007c73 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php"; // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } '@phan-var-force CommonObject $this diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index b2b8d94bc51..303e735a498 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -36,7 +36,7 @@ // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } '@phan-var-force CommonObject $this diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 179bec8f474..38da2d0077c 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -41,7 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; // Protection to avoid direct call of template if (empty($object) || !is_object($object)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } '@phan-var-force CommonObject $this diff --git a/htdocs/bookcal/admin/setup.php b/htdocs/bookcal/admin/setup.php index 737ad9558a8..dd16dfb720e 100644 --- a/htdocs/bookcal/admin/setup.php +++ b/htdocs/bookcal/admin/setup.php @@ -138,7 +138,7 @@ if ($action == 'updateMask') { } } elseif ($action == 'setmod') { // TODO Check if numbering module chosen can be activated by calling method canBeActivated - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'BOOKCAL_'.strtoupper($tmpobjectkey)."_ADDON"; dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity); @@ -149,7 +149,7 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'BOOKCAL_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (getDolGlobalString($constforval) == "$value") { @@ -159,7 +159,7 @@ if ($action == 'updateMask') { } } elseif ($action == 'setdoc') { // Set or unset default model - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'BOOKCAL_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { @@ -175,7 +175,7 @@ if ($action == 'updateMask') { } } } elseif ($action == 'unsetdoc') { - $tmpobjectkey = GETPOST('object'); + $tmpobjectkey = GETPOST('object', 'aZ09'); if (!empty($tmpobjectkey)) { $constforval = 'BOOKCAL_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; dolibarr_del_const($db, $constforval, $conf->entity); @@ -207,7 +207,6 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "fa-c // Setup page goes here //echo ''.$langs->trans("BookCalSetupPage").'

'; - if ($action == 'edit') { print $formSetup->generateOutput(true); print '
'; diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index b81a31e1891..05692d23ae0 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -26,7 +26,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 2ced0e73a63..4d37b71e10e 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -20,7 +20,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } print "\n"; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 09ca6cdef05..ea6f8d6c4a1 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -20,7 +20,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } print "\n"; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index d888d1fd5d7..bd8fa94cf19 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -20,7 +20,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } diff --git a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php index bc8ff9ebcf4..42f31475c00 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_create.tpl.php @@ -18,7 +18,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } ?> diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index cf193e25274..f1bea679d32 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -18,7 +18,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index 1a66208288f..ab7f560ec47 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -18,7 +18,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index 86c7abfb7f2..0aaf9e98993 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -19,7 +19,7 @@ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; - exit; + exit(1); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 07dfa7db829..72c1c2c9dd9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5646,7 +5646,7 @@ abstract class CommonObject $filefound = dol_sanitizePathName($filefound); // If generator was found - global $db; // Required to solve a conception default making an include of some code that uses $db instead of $this->db just after. + global $db; // Required to solve a conception error making an include of some code that uses $db instead of $this->db just after. require_once $filefound; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 2bca27f5aca..edef301c3de 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1455,8 +1455,9 @@ class FormMail extends Form $out .= ''; $out .= ''; $out .= ''; - $out .= '
'; - $out .= ''.$langs->trans("AIProcessingPleaseWait").'
'; + $out .= '
'; + $out .= ''.$langs->trans("AIProcessingPleaseWait"); + $out .= '
'; $out .= "\n"; $out .= "