From b52c79dcfec372a4a873a3da909795fa0b223120 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2023 04:37:10 +0200 Subject: [PATCH 1/8] Fix warnings --- htdocs/contact/class/contact.class.php | 2 - htdocs/core/lib/website.lib.php | 2 +- htdocs/core/modules/DolibarrModules.class.php | 42 ++++++++++--------- htdocs/societe/class/societeaccount.class.php | 2 + 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 4fbdf3f096b..24ee091238d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -2194,8 +2194,6 @@ class Contact extends CommonObject */ public function getKanbanView($option = '', $arraydata = null) { - global $langs; - $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); $return = '
'; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index e6e8dd819c0..d27c4dac376 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -760,7 +760,7 @@ function getStructuredData($type, $data = array()) $ret .= "\n".'}'."\n"; $ret .= ''."\n"; } else { - $ret .= ''."\n"; + $ret = ''."\n"; } } elseif ($type == 'product') { $ret = ''."\n"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 83676b29f43..466469423d8 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -2430,7 +2430,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $versiontrans .= 'warning'; } - print ' + $return = '
picto, 'class="inline-block valignmiddle"', 1); } else { - print img_object($alttext, $this->picto, 'class="inline-block valignmiddle"'); + $return .= img_object($alttext, $this->picto, 'class="inline-block valignmiddle"'); } } else { - print img_object($alttext, 'generic', 'class="inline-block valignmiddle"'); + $return .= img_object($alttext, 'generic', 'class="inline-block valignmiddle"'); } if ($this->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { @@ -2458,34 +2458,36 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $versionTitle.= '
'.$langs->trans('ModuleUpdateAvailable').' : '.$this->lastVersion; } - print ''; - print $this->getVersion(1); - print ''; + $return .= ''; + $return .= $this->getVersion(1); + $return .= ''; } - print '
+ $return .= '
'.$this->getName().' '.nl2br($this->getDesc()).''; - print '
'; - print '
'; - print '
'; - print $codetoconfig; - print '
'; - print '
'; - print $codeenabledisable; - print '
'; - print '
'; + $return .= '
'; + $return .= '
'; + $return .= $codetoconfig; + $return .= '
'; + $return .= '
'; + $return .= $codeenabledisable; + $return .= '
'; + $return .= '
'; - print ' + $return .= '
'; + + return $return; } /** diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 82ff5c41c11..4d4fdc012d8 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -534,6 +534,8 @@ class SocieteAccount extends CommonObject return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } + + return ''; } /** From e0d4a5160ea1839a931ad01f5678e506cde9f9b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2023 10:57:55 +0200 Subject: [PATCH 2/8] Fix case --- htdocs/fichinter/card-rec.php | 2 +- htdocs/fichinter/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 068a90a3371..575b38a0cdd 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -581,7 +581,7 @@ if ($action == 'create') { print ''; print ''; if ($action == 'contrat') { - $formcontract = new Formcontract($db); + $formcontract = new FormContract($db); $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1); } else { if ($object->fk_contrat) { diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 36ff728fe75..fe5850a6cd9 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1248,7 +1248,7 @@ if ($action == 'create') { print ''; print ''; if ($action == 'contrat') { - $formcontract = new Formcontract($db); + $formcontract = new FormContract($db); $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1); } else { if ($object->fk_contrat) { From f6285de2acdf3e3eb2fd5d4e217215ba276387f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2023 14:48:18 +0200 Subject: [PATCH 3/8] FIX Solve timeout when deploying compex modules --- htdocs/admin/modules.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 464f3e72e97..3cd35480a5d 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -113,6 +113,14 @@ $urldolibarrmodules = 'https://www.dolistore.com/'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('adminmodules', 'globaladmin')); +// Execution Time +$max_execution_time_for_deploy = (empty($conf->global->MODULE_UPLOAD_MAX_EXECUTION_TIME) ? 300 : $conf->global->MODULE_UPLOAD_MAX_EXECUTION_TIME); // 5mn if not defined +$max_time = @ini_get("max_execution_time"); +if ($max_time && $max_time < $max_execution_time_for_deploy) { + dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_deploy=".$max_execution_time_for_deploy.". We try to increase it dynamically."); + @ini_set("max_execution_time", $max_execution_time_for_deploy); // This work only if safe mode is off. also web servers has timeout of 300 +} + /* * Actions From 08837c07181349d0ffe63c24a2379b131dc82fc8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2023 16:26:03 +0200 Subject: [PATCH 4/8] Fix typo --- htdocs/langs/en_US/dict.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/dict.lang b/htdocs/langs/en_US/dict.lang index e3b159e50de..bbd536679fe 100644 --- a/htdocs/langs/en_US/dict.lang +++ b/htdocs/langs/en_US/dict.lang @@ -137,7 +137,7 @@ CountryLV=Latvia CountryLB=Lebanon CountryLS=Lesotho CountryLR=Liberia -CountryLY=Libyan +CountryLY=Libya CountryLI=Liechtenstein CountryLT=Lithuania CountryLU=Luxembourg From f5f7ed7ca8fa7593d263f36c4b3d8bdacfb1b20a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2023 18:43:48 +0200 Subject: [PATCH 5/8] Code comment --- htdocs/core/actions_linkedfiles.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index b680a81521c..b599480f583 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -96,7 +96,7 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC) && !emp // Parse $newUrl $newUrlArray = parse_url($link); - // Check URL is external + // Allow external links to svg ? if (!getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS')) { if (!empty($newUrlArray['path']) && preg_match('/\.svg$/i', $newUrlArray['path'])) { $error++; @@ -104,9 +104,9 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC) && !emp setEventMessages($langs->trans('ErrorSVGFilesNotAllowedAsLinksWithout', 'MAIN_ALLOW_SVG_FILES_AS_EXTERNAL_LINKS'), null, 'errors'); } } - // Alow external links to svg ? + // Check URL is external (must refuse local link by default) if (!getDolGlobalString('MAIN_ALLOW_LOCAL_LINKS_AS_EXTERNAL_LINKS')) { - // Test $newUrlAray['host'] to check link is external using isIPAllowed() + // Test $newUrlAray['host'] to check link is external using isIPAllowed() and if not refuse the local link // TODO } From 643d29f289462bf1eb297796602bf4250152c6db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2023 20:17:10 +0200 Subject: [PATCH 6/8] Debug v18 --- htdocs/contrat/card.php | 34 +++++++++++++++++++++----------- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 72b7ebed3ed..0ed49cc8aa6 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1514,7 +1514,7 @@ if ($action == 'create') { // Area with common detail of line print '
'; - print ''; + print '
'; $sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.product_type, cd.description, cd.price_ht, cd.qty,"; $sql .= " cd.tva_tx, cd.vat_src_code, cd.remise_percent, cd.info_bits, cd.subprice, cd.multicurrency_subprice,"; @@ -1534,6 +1534,7 @@ if ($action == 'create') { $objp = $db->fetch_object($result); + // Line title print ''; print ''; print ''; @@ -1578,7 +1579,9 @@ if ($action == 'create') { if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') { $moreparam = 'style="display: none;"'; } + print ''; + // Label if ($objp->fk_product > 0) { $productstatic->id = $objp->fk_product; @@ -1604,7 +1607,7 @@ if ($action == 'create') { $description = ''; // Already added into main visible desc } - echo $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); + print $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 3, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); print ''; } else { @@ -1660,16 +1663,16 @@ if ($action == 'create') { print "\n"; + $colspan = 6; + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { + $colspan++; + } + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + $colspan++; + } + // Dates of service planed and real if ($objp->subprice >= 0) { - $colspan = 6; - - if (isModEnabled('margin') && getDolGlobalString('PRODUCT_USE_UNITS')) { - $colspan = 8; - } elseif (isModEnabled('margin') || getDolGlobalString('PRODUCT_USE_UNITS')) { - $colspan = 7; - } - print ''; print ''; - print ''; + print ''; print "\n"; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 190d6159afb..c3c50bb63f7 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2532,7 +2532,7 @@ img.photorefnoborder { } .tdhrthin { - margin: 0; + margin: 0 !important; padding-bottom: 0 !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 14a1bbb24c4..037bb36e003 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2706,7 +2706,7 @@ img.photorefnoborder { border-bottom: 1px solid var(--colortopbordertitle1) !important; } .tdhrthin { - margin: 0; + margin: 0 !important; padding-bottom: 0 !important; } /* Payment Screen : Pointer cursor in the autofill image */ From 463d24d50c0b9c02a990da77d410afd730d22b46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Aug 2023 11:31:50 +0200 Subject: [PATCH 7/8] Debug v18 --- htdocs/admin/menus/edit.php | 7 ++++++- htdocs/install/mysql/tables/llx_menu.sql | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 288cba1c5b9..d7c5a3bf49b 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -264,6 +264,7 @@ if ($action == 'create') { print dol_get_fiche_head(); + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'.$langs->trans("ServiceNb", $cursorline).''.$langs->trans("VAT").'
'; @@ -1826,8 +1829,17 @@ if ($action == 'create') { if (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') { $moreparam = 'style="display: none;"'; } + + $colspan = 6; + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { + $colspan++; + } + if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { + $colspan++; + } + print '


'; // Id @@ -371,6 +372,7 @@ if ($action == 'create') { print ''; print '
'.$langs->trans('DetailTarget').'
'; + print '
'; print dol_get_fiche_end(); @@ -388,6 +390,7 @@ if ($action == 'create') { print dol_get_fiche_head(); + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; $menu = new Menubase($db); @@ -489,7 +492,8 @@ if ($action == 'create') { print ''; // Target - print ''; print '
'.$langs->trans('Target').'
'.$langs->trans('Target').''; + print ''; @@ -497,6 +501,7 @@ if ($action == 'create') { print ''.$langs->trans('DetailTarget').'
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/install/mysql/tables/llx_menu.sql b/htdocs/install/mysql/tables/llx_menu.sql index 52b576411cb..0561dfdf8e5 100644 --- a/htdocs/install/mysql/tables/llx_menu.sql +++ b/htdocs/install/mysql/tables/llx_menu.sql @@ -36,7 +36,7 @@ CREATE TABLE llx_menu url varchar(255) NOT NULL, -- Relative (or absolute) url to go target varchar(100) NULL, -- Target of Url link titre varchar(255) NOT NULL, -- Key for menu translation - prefix varchar(255) NULL, -- prefix + prefix varchar(255) NULL, -- picto langs varchar(100), -- Lang file to load for translation level smallint, -- Deprecated. Not used. perms text, -- Condition to show enabled or disabled From b47a640f0b7494624c95d6182cbe88679258ee77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Aug 2023 12:37:25 +0200 Subject: [PATCH 8/8] Debug v18 --- htdocs/admin/menus/edit.php | 185 ++++++++++++++---------- htdocs/core/lib/functions.lib.php | 9 +- htdocs/core/menus/standard/eldy.lib.php | 14 +- 3 files changed, 121 insertions(+), 87 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index d7c5a3bf49b..0bbdc36f548 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -71,65 +71,6 @@ if (GETPOST("menu_handler")) { * Actions */ -if ($action == 'update') { - if (!$cancel) { - $leftmenu = ''; $mainmenu = ''; - if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { - $tmp = explode('&', GETPOST('menuIdParent', 'alphanohtml')); - foreach ($tmp as $s) { - if (preg_match('/fk_mainmenu=/', $s)) { - $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); - } - if (preg_match('/fk_leftmenu=/', $s)) { - $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); - } - } - } - - $menu = new Menubase($db); - $result = $menu->fetch(GETPOST('menuId', 'int')); - if ($result > 0) { - $menu->title = (string) GETPOST('titre', 'alphanohtml'); - $menu->leftmenu = (string) GETPOST('leftmenu', 'aZ09'); - $menu->url = (string) GETPOST('url', 'alphanohtml'); - $menu->langs = (string) GETPOST('langs', 'alphanohtml'); - $menu->position = (int) GETPOST('position', 'int'); - $menu->enabled = (string) GETPOST('enabled', 'alphanohtml'); - $menu->perms = (string) GETPOST('perms', 'alphanohtml'); - $menu->target = (string) GETPOST('target', 'alphanohtml'); - $menu->user = (string) GETPOST('user', 'alphanohtml'); - $menu->mainmenu = (string) GETPOST('propertymainmenu', 'alphanohtml'); - if (is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { - $menu->fk_menu = (int) GETPOST('menuIdParent', 'alphanohtml'); - } else { - if (GETPOST('type', 'alphanohtml') == 'top') { - $menu->fk_menu = 0; - } else { - $menu->fk_menu = -1; - } - $menu->fk_mainmenu = $mainmenu; - $menu->fk_leftmenu = $leftmenu; - } - - $result = $menu->update($user); - if ($result > 0) { - setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); - } else { - setEventMessages($menu->error, $menu->errors, 'errors'); - } - } else { - setEventMessages($menu->error, $menu->errors, 'errors'); - } - $action = "edit"; - - header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); - exit; - } else { - header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); - exit; - } -} - if ($action == 'add') { if ($cancel) { header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); @@ -138,8 +79,8 @@ if ($action == 'add') { $leftmenu = ''; $mainmenu = ''; - if (GETPOST('menuId', 'alphanohtml', 3) && !is_numeric(GETPOST('menuId', 'alphanohtml', 3))) { - $tmp = explode('&', GETPOST('menuId', 'alphanohtml', 3)); + if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { + $tmp = explode('&', GETPOST('menuIdParent', 'alphanohtml')); foreach ($tmp as $s) { if (preg_match('/fk_mainmenu=/', $s)) { $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); @@ -173,12 +114,12 @@ if ($action == 'add') { $action = 'create'; $error++; } - if (!$error && GETPOST('menuId', 'alphanohtml', 3) && GETPOST('type') == 'top') { + if (!$error && GETPOST('menuIdParent', 'alphanohtml') && GETPOST('type') == 'top') { setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors'); $action = 'create'; $error++; } - if (!$error && !GETPOST('menuId', 'alphanohtml', 3) && GETPOST('type') == 'left') { + if (!$error && !GETPOST('menuIdParent', 'alphanohtml') && GETPOST('type') == 'left') { setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); $action = 'create'; $error++; @@ -189,6 +130,7 @@ if ($action == 'add') { $menu->menu_handler = preg_replace('/_menu$/', '', GETPOST('menu_handler', 'aZ09')); $menu->type = (string) GETPOST('type', 'alphanohtml'); $menu->title = (string) GETPOST('titre', 'alphanohtml'); + $menu->prefix = (string) GETPOST('picto', 'restricthtmlallowclass'); $menu->url = (string) GETPOST('url', 'alphanohtml'); $menu->langs = (string) GETPOST('langs', 'alphanohtml'); $menu->position = (int) GETPOST('position', 'int'); @@ -197,8 +139,8 @@ if ($action == 'add') { $menu->target = (string) GETPOST('target', 'alphanohtml'); $menu->user = (string) GETPOST('user', 'alphanohtml'); $menu->mainmenu = (string) GETPOST('propertymainmenu', 'alphanohtml'); - if (is_numeric(GETPOST('menuId', 'alphanohtml', 3))) { - $menu->fk_menu = (int) GETPOST('menuId', 'alphanohtml', 3); + if (is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { + $menu->fk_menu = (int) GETPOST('menuIdParent', 'alphanohtml'); } else { if (GETPOST('type', 'alphanohtml') == 'top') { $menu->fk_menu = 0; @@ -220,6 +162,78 @@ if ($action == 'add') { } } +if ($action == 'update') { + if (!$cancel) { + $leftmenu = ''; $mainmenu = ''; + if (GETPOST('menuIdParent', 'alphanohtml') && !is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { + $tmp = explode('&', GETPOST('menuIdParent', 'alphanohtml')); + foreach ($tmp as $s) { + if (preg_match('/fk_mainmenu=/', $s)) { + $mainmenu = preg_replace('/fk_mainmenu=/', '', $s); + } + if (preg_match('/fk_leftmenu=/', $s)) { + $leftmenu = preg_replace('/fk_leftmenu=/', '', $s); + } + } + } + + $error = 0; + if (!$error && !GETPOST('url')) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors'); + $action = 'create'; + $error++; + } + + if (!$error) { + $menu = new Menubase($db); + $result = $menu->fetch(GETPOST('menuId', 'int')); + if ($result > 0) { + $menu->title = (string) GETPOST('titre', 'alphanohtml'); + $menu->prefix = (string) GETPOST('picto', 'restricthtmlallowclass'); + $menu->leftmenu = (string) GETPOST('leftmenu', 'aZ09'); + $menu->url = (string) GETPOST('url', 'alphanohtml'); + $menu->langs = (string) GETPOST('langs', 'alphanohtml'); + $menu->position = (int) GETPOST('position', 'int'); + $menu->enabled = (string) GETPOST('enabled', 'alphanohtml'); + $menu->perms = (string) GETPOST('perms', 'alphanohtml'); + $menu->target = (string) GETPOST('target', 'alphanohtml'); + $menu->user = (string) GETPOST('user', 'alphanohtml'); + $menu->mainmenu = (string) GETPOST('propertymainmenu', 'alphanohtml'); + if (is_numeric(GETPOST('menuIdParent', 'alphanohtml'))) { + $menu->fk_menu = (int) GETPOST('menuIdParent', 'alphanohtml'); + } else { + if (GETPOST('type', 'alphanohtml') == 'top') { + $menu->fk_menu = 0; + } else { + $menu->fk_menu = -1; + } + $menu->fk_mainmenu = $mainmenu; + $menu->fk_leftmenu = $leftmenu; + } + + $result = $menu->update($user); + if ($result > 0) { + setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); + } else { + setEventMessages($menu->error, $menu->errors, 'errors'); + } + } else { + setEventMessages($menu->error, $menu->errors, 'errors'); + } + + $action = "edit"; + + header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); + exit; + } else { + $action = 'edit'; + } + } else { + header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler); + exit; + } +} + /* @@ -239,14 +253,14 @@ if ($action == 'create') { { if (jQuery("#topleft").val() == \'top\') { - jQuery("#menuId").prop("disabled", true); - jQuery("#menuId").val(\'\'); + jQuery("#menuIdParent").prop("disabled", true); + jQuery("#menuIdParent").val(\'\'); jQuery("#propertymainmenu").removeAttr("disabled"); jQuery("#propertymainmenu").val(\'\'); } if (jQuery("#topleft").val() == \'left\') { - jQuery("#menuId").removeAttr("disabled"); + jQuery("#menuIdParent").removeAttr("disabled"); jQuery("#propertymainmenu").prop("disabled", true); } } @@ -275,7 +289,9 @@ if ($action == 'create') { $parent_level = ''; if (GETPOST('menuId', 'int')) { - $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int'); + $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs"; + $sql .= " FROM ".MAIN_DB_PREFIX."menu as m"; + $sql .= " WHERE m.rowid = ".((int) GETPOST('menuId', 'int')); $res = $db->query($sql); if ($res) { while ($menu = $db->fetch_array($res)) { @@ -331,9 +347,9 @@ if ($action == 'create') { // MenuId Parent print ''.$langs->trans('MenuIdParent').''; if ($parent_rowid) { - print ''.$parent_rowid.''; + print ''.$parent_rowid.''; } else { - print ''; + print ''; } print ''.$langs->trans('DetailMenuIdParent'); print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; @@ -343,17 +359,21 @@ if ($action == 'create') { print ''.$langs->trans('Title').''; print ''.$langs->trans('DetailTitre').''; + // Picto + print ''.$langs->trans('Image').''; + print ''.$langs->trans('Example').': fa-global'; + // URL print ''.$langs->trans('URL').''; - print ''.$langs->trans('DetailUrl').''; + print ''.$langs->trans('DetailUrl').''; // Langs print ''.$langs->trans('LangFile').''; - print ''.$langs->trans('DetailLangs').''; + print ''.$langs->trans('DetailLangs').''; // Position print ''.$langs->trans('Position').''; - print ''.$langs->trans('DetailPosition').''; + print ''.$langs->trans('DetailPosition').''; // Enabled print ''.$langs->trans('Enabled').''; @@ -383,7 +403,8 @@ if ($action == 'create') { print load_fiche_titre($langs->trans("ModifMenu"), '', 'title_setup'); print '
'; - print '
'; + print ''; + print ''; print ''; print ''; print ''; @@ -434,7 +455,7 @@ if ($action == 'create') { } else {*/ - print 'mainmenu).'">'; + print 'mainmenu).'">'; //} print ''; print $langs->trans("Example").': mytopmenukey'; @@ -451,7 +472,7 @@ if ($action == 'create') { if ($menu->fk_leftmenu) { $valtouse .= '&fk_leftmenu='.$menu->fk_leftmenu; } - print ''; + print ''; print ''.$langs->trans('DetailMenuIdParent'); print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; print ''; @@ -463,9 +484,13 @@ if ($action == 'create') { print ''.$langs->trans('Title').''; print ''.$langs->trans('DetailTitre').''; - // Url + // URL print ''.$langs->trans('URL').''; - print ''.$langs->trans('DetailUrl').''; + print ''.$langs->trans('DetailUrl').''; + + // Picto + print ''.$langs->trans('Image').''; + print ''.$langs->trans('Example').': fa-global'; // Langs print ''.$langs->trans('LangFile').''; @@ -473,7 +498,7 @@ if ($action == 'create') { // Position print ''.$langs->trans('Position').''; - print ''.$langs->trans('DetailPosition').''; + print ''.$langs->trans('DetailPosition').''; // Enabled print ''.$langs->trans('Enabled').''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5b47c3d31b6..5e1af04dc5f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -955,8 +955,6 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = */ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options = null) { - global $conf; - // TODO : use class "Validate" to perform tests (and add missing tests) if needed for factorize // Check is done after replacement switch ($check) { @@ -1044,8 +1042,9 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options case 'nohtml': // No html $out = dol_string_nohtmltag($out, 0); break; - case 'restricthtml': // Recommended for most html textarea case 'restricthtmlnolink': + case 'restricthtml': // Recommended for most html textarea + case 'restricthtmlallowclass': case 'restricthtmlallowunvalid': $out = dol_htmlwithnojs($out, 1, $check); break; @@ -7356,7 +7355,7 @@ function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false) * * @param string $stringtoencode String to encode * @param int $nouseofiframesandbox Allow use of option MAIN_SECURITY_USE_SANDBOX_FOR_HTMLWITHNOJS for html sanitizing - * @param string $check 'restricthtmlnolink' or 'restricthtml' or 'restricthtmlallowunvalid' + * @param string $check 'restricthtmlnolink' or 'restricthtml' or 'restricthtmlallowclass' or 'restricthtmlallowunvalid' * @return string HTML sanitized */ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = 'restricthtml') @@ -7415,7 +7414,7 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' $out = preg_replace('/&#x?[0-9]+/i', '', $out); // For example if we have javascript with an entities without the ; to hide the 'a' of 'javascript'. // Keep only some html tags and remove also some 'javascript:' strings - $out = dol_string_onlythesehtmltags($out, 0, 1, 1); + $out = dol_string_onlythesehtmltags($out, 0, ($check == 'restricthtmlallowclass' ? 0 : 1), 1); // We should also exclude non expected HTML attributes and clean content of some attributes (keep only alt=, title=...). if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5e586cecd99..0194c45b457 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -986,7 +986,14 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } else { print ''; } - print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '').$menu_array[$i]['titre']; + if (!empty($menu_array[$i]['prefix'])) { + if (preg_match('/^fa-[a-zA-Z0-9-_]+$/', $menu_array[$i]['prefix'])) { + print ''; + } else { + print $menu_array[$i]['prefix']; + } + } + print $menu_array[$i]['titre']; if ($shorturlwithoutparam) { print ''; } else { @@ -997,7 +1004,10 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } elseif ($showmenu) { // Not enabled but visible (so greyed) print ''."\n"; $lastlevel0 = 'greyed';