From e38066920706268e69cfab1425ed0412ee323db1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 7 Oct 2023 08:10:13 +0200 Subject: [PATCH 1/4] FIX avoid warning + CSRF --- htdocs/admin/ticket_public.php | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index a640370dc7b..195bd6d58b5 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -153,7 +153,7 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { } // For compatibility when javascript is not enabled - if ($conf->global->MAIN_FEATURES_LEVEL >= 2 && empty($conf->use_javascript_ajax)) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2 && empty($conf->use_javascript_ajax)) { $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { @@ -164,7 +164,7 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { } elseif (preg_match('/set_(.*)/', $action, $reg)) { $code = $reg[1]; $value = GETPOSTISSET($code) ? GETPOST($code, 'int') : 1; - if ($code == 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS' && $conf->global->MAIN_FEATURES_LEVEL >= 2) { + if ($code == 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS' && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { @@ -240,7 +240,7 @@ $param = ''; print '
'; $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; -if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { +if (!getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) { // Button off, click to enable $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); @@ -252,13 +252,13 @@ if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { $enabledisablehtml .= ''; } print $enabledisablehtml; -print ''; +print ''; print dol_get_fiche_end(); -if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { +if (getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) { print '
'; @@ -299,7 +299,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA_TICKET'); } else { - if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) { + if (getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET'))) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; @@ -346,7 +346,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; */ - /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + /*if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // Show logo for module print '' . $langs->trans("TicketsShowModuleLogo") . ''; @@ -355,7 +355,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO); + print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, getDolGlobalInt('TICKET_SHOW_MODULE_LOGO')); } print ''; print ''; @@ -367,11 +367,11 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Show logo for company print ''.$langs->trans("TicketsShowCompanyLogo").''; print ''; - if ($conf->use_javascript_ajax) { + if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); + print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO')); } print ''; print ''; @@ -382,10 +382,14 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Show progression print ''.$langs->trans("TicketsShowProgression").''; print ''; - if (!getDolGlobalInt('TICKET_SHOW_PROGRESSION')) { - print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; + if (!empty($conf->use_javascript_ajax)) { + print ajax_constantonoff('TICKET_SHOW_PROGRESSION'); } else { - print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; + if (!getDolGlobalInt('TICKET_SHOW_PROGRESSION')) { + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; + } else { + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; + } } print ''; print ''; @@ -394,14 +398,14 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; // Also send to main email address - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { print ''.$langs->trans("TicketsEmailAlsoSendToMainAddress").''; print ''; - if ($conf->use_javascript_ajax) { + if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, getDolGlobalInt('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS')); } print ''; print ''; @@ -410,12 +414,12 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; } - if (!$conf->use_javascript_ajax) { + if (empty($conf->use_javascript_ajax)) { print ''; print ''; } - if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { + if (!getDolGlobalInt('FCKEDITOR_ENABLE_MAIL')) { print ''; print '
'.$langs->trans("TicketCkEditorEmailNotActivated").'
'; print "\n"; @@ -483,7 +487,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); + print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, getDolGlobalInt('TICKET_DISABLE_CUSTOMER_MAILS')); } print ''; print ''; From c419b0c1b1fe4e7687b1c06493ea6f9a16777d86 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 7 Oct 2023 08:16:06 +0200 Subject: [PATCH 2/4] FIX syntax error --- htdocs/admin/ticket_public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 195bd6d58b5..1048d8e7735 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -299,7 +299,7 @@ if (getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) { if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA_TICKET'); } else { - if (getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET'))) { + if (getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET')) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; From d6b39dc2274e836c2e8231fbb0f360035d732f28 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 7 Oct 2023 08:30:07 +0200 Subject: [PATCH 3/4] FIX avoid warnings --- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- htdocs/ticket/class/actions_ticket.class.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index fcc7b12b1d2..2e0fb66127e 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -60,7 +60,7 @@ if ($reshook < 0) { //var_dump($extrafields->attributes[$object->table_element]); -if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label'])) { +if (empty($reshook) && !empty($object->table_element) && isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label'])) { $lastseparatorkeyfound = ''; $extrafields_collapse_num = ''; $extrafields_collapse_num_old = ''; diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index e399df59197..cc0a02dd294 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; /** From 5e0efcf7ce6440f86879dd135d2392cbe4103ae0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Oct 2023 18:45:49 +0200 Subject: [PATCH 4/4] Update ticket_public.php --- htdocs/admin/ticket_public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 1048d8e7735..35bd0b35f8b 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -299,7 +299,7 @@ if (getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) { if (!empty($conf->use_javascript_ajax)) { print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA_TICKET'); } else { - if (getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET')) { + if (!getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET')) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').'';