From 4437506ef9786a50cee889257043e61e0e64a44f Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 15 Sep 2022 13:53:52 +0200 Subject: [PATCH 01/24] Fix : datetime extrafield behaviour --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e51409ef81b..8bcf9250bd4 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2090,7 +2090,7 @@ class ExtraFields // values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc. $value_key = array( 'start' => dol_mktime(GETPOST($dateparamname_start . 'hour', 'int'), GETPOST($dateparamname_start . 'min', 'int'), GETPOST($dateparamname_start . 'sec', 'int'), GETPOST($dateparamname_start . 'month', 'int'), GETPOST($dateparamname_start . 'day', 'int'), GETPOST($dateparamname_start . 'year', 'int'), 'tzuserrel'), - 'end' => dol_mktime(GETPOST($dateparamname_end . 'hour', 'int'), GETPOST($dateparamname_start . 'min', 'int'), GETPOST($dateparamname_start . 'sec', 'int'), GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int'), 'tzuserrel') + 'end' => dol_mktime(GETPOST($dateparamname_end . 'hour', 'int') !='-1' ? GETPOST($dateparamname_end . 'hour', 'int') : '23', GETPOST($dateparamname_end . 'min', 'int') !='-1' ? GETPOST($dateparamname_end . 'min', 'int') : '59', GETPOST($dateparamname_end . 'sec', 'int') !='-1' ? GETPOST($dateparamname_end . 'sec', 'int') : '59', GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int'), 'tzuserrel') ); } elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) { // Clean parameters From 9b515862097a4baef7fe6487b5fecec750b092c8 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 15 Sep 2022 14:13:27 +0200 Subject: [PATCH 02/24] fix style error --- htdocs/core/class/extrafields.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 8bcf9250bd4..d5336616d09 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2088,9 +2088,12 @@ class ExtraFields $dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end'; if (GETPOSTISSET($dateparamname_start . 'year') && GETPOSTISSET($dateparamname_end . 'year')) { // values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc. + $dateparamname_end_hour = GETPOST($dateparamname_end . 'hour', 'int') !='-1' ? GETPOST($dateparamname_end . 'hour', 'int') : '23'; + $dateparamname_end_min = GETPOST($dateparamname_end . 'min', 'int') !='-1' ? GETPOST($dateparamname_end . 'min', 'int') : '59'; + $dateparamname_end_sec = GETPOST($dateparamname_end . 'sec', 'int') !='-1' ? GETPOST($dateparamname_end . 'sec', 'int') : '59'; $value_key = array( 'start' => dol_mktime(GETPOST($dateparamname_start . 'hour', 'int'), GETPOST($dateparamname_start . 'min', 'int'), GETPOST($dateparamname_start . 'sec', 'int'), GETPOST($dateparamname_start . 'month', 'int'), GETPOST($dateparamname_start . 'day', 'int'), GETPOST($dateparamname_start . 'year', 'int'), 'tzuserrel'), - 'end' => dol_mktime(GETPOST($dateparamname_end . 'hour', 'int') !='-1' ? GETPOST($dateparamname_end . 'hour', 'int') : '23', GETPOST($dateparamname_end . 'min', 'int') !='-1' ? GETPOST($dateparamname_end . 'min', 'int') : '59', GETPOST($dateparamname_end . 'sec', 'int') !='-1' ? GETPOST($dateparamname_end . 'sec', 'int') : '59', GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int'), 'tzuserrel') + 'end' => dol_mktime($dateparamname_end_hour, $dateparamname_end_min, $dateparamname_end_sec, GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int'), 'tzuserrel') ); } elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) { // Clean parameters From 00d162c23506fcea62f97cd704eaa1ca740d26cd Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Wed, 7 Sep 2022 00:34:22 +0200 Subject: [PATCH 03/24] Update myobject_list.php Better code now --- htdocs/modulebuilder/template/myobject_list.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 1227ad8253a..0f83371d676 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -456,6 +456,10 @@ foreach ($search as $key => $val) { $param .= '&search_'.$key.'[]='.urlencode($skey); } } + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } From 8864285496e6bb45c816896579026f21c269fb3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Sep 2022 18:53:13 +0200 Subject: [PATCH 04/24] Fix css of menu disabled --- htdocs/theme/eldy/global.inc.php | 5 +++++ htdocs/theme/md/style.css.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index fc4fafc60af..f0208223cf4 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2503,6 +2503,11 @@ a.tmenudisabled:link, a.tmenudisabled:visited, a.tmenudisabled:hover, a.tmenudis text-decoration: none; cursor: not-allowed; } +span.mainmenuaspan.tmenudisabled { + color: var(--colortextbackhmenu); + opacity: 0.5; + cursor: not-allowed; +} a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { padding: 0px 2px 0px 2px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 7521172121f..3357a2f8c7a 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2547,6 +2547,11 @@ a.tmenudisabled:link, a.tmenudisabled:visited, a.tmenudisabled:hover, a.tmenudis text-decoration: none; cursor: not-allowed; } +span.mainmenuaspan.tmenudisabled { + color: var(--colortextbackhmenu); + opacity: 0.5; + cursor: not-allowed; +} a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { font-weight: normal; From 313addec74cda8481ac48c6e984e23905e81adeb Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Tue, 27 Sep 2022 09:21:28 +0200 Subject: [PATCH 05/24] FIX - php V8 get number doc saphir --- htdocs/core/modules/propale/mod_propale_saphir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index af7579fb142..72ca13f3a4c 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -144,7 +144,7 @@ class mod_propale_saphir extends ModeleNumRefPropales // Get entities $entity = getEntity('proposalnumber', 1, $propal); - $date = $propal->date; + $date = isset($propal->date)?$propal->date:dol_now(); $numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity); From 0b586eb0cf1c695a3a504422937aed55f8daf14a Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 27 Sep 2022 11:36:51 +0200 Subject: [PATCH 06/24] Fix: Loss of the purchase price no reception --- htdocs/fourn/commande/dispatch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 9a8ab1fa7ef..cf9d1ed847b 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -6,7 +6,7 @@ * Copyright (C) 2010-2021 Juanjo Menent * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry - * Copyright (C) 2017-2020 Ferran Marcet + * Copyright (C) 2017-2022 Ferran Marcet * Copyright (C) 2018 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel * @@ -981,7 +981,7 @@ if ($id > 0 || !empty($ref)) { if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { // Price print ''; - print ''; + print ''; print ''; // Discount From 52b12ee47dbefc9143e6b6b4539f17c982ce27fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Sep 2022 14:12:37 +0200 Subject: [PATCH 07/24] Trans --- htdocs/commande/list.php | 3 ++- htdocs/langs/en_US/errors.lang | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9a0851afc8d..2e2dbc97946 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1293,7 +1293,8 @@ if ($resql) { print ''; if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) { print $form->selectyesno('validate_invoices', 0, 1, 1); - print ' ('.$langs->trans("AutoValidationNotPossibleWhenStockIsDecreasedOnInvoiceValidation").')'; + $langs->load("errors"); + print ' ('.$langs->trans("WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal").')'; } else { print $form->selectyesno('validate_invoices', 0, 1); } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 50bc7931fd2..7cf67f10af8 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -326,6 +326,7 @@ WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connec WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here. WarningPaypalPaymentNotCompatibleWithStrict=The value 'Strict' makes the online payment features not working correctly. Use 'Lax' instead. WarningThemeForcedTo=Warning, theme has been forced to %s by hidden constant MAIN_FORCETHEME +WarningAutoValNotPossibleWhenStockIsDecreasedOnInvoiceVal=Automatic validation is disabled when option to decrease stock is set on "Invoice validation". # Validate RequireValidValue = Value not valid From e119fef9642c8318dc94ec8f3322e28a2556bd89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Sep 2022 14:26:09 +0200 Subject: [PATCH 08/24] Fix reposition --- htdocs/admin/ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index ef488943a4b..421399a81bc 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -263,7 +263,7 @@ print '
'; */ if (function_exists("ldap_connect")) { if (!empty($conf->global->LDAP_SERVER_HOST)) { - print ''.$langs->trans("LDAPTestConnect").'

'; + print ''.$langs->trans("LDAPTestConnect").'

'; } if ($action == 'test') { From cea781a711caac5d96ff33c1e15a6414f4a41443 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Sep 2022 16:21:55 +0200 Subject: [PATCH 09/24] FIX CSRF + lost value of constant after use save button --- htdocs/admin/ticket_public.php | 67 +++++++++++++++++----------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index a0df28a8f84..622a8aaf927 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -150,44 +150,45 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { $error++; $errors[] = $db->lasterror(); } +} elseif (preg_match('/set_(.*)/', $action, $reg)) { + $code = $reg[1]; + $value = GETPOSTISSET($code) ? GETPOST($code, 'int') : 1; - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if ($code == 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS' && $conf->global->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)) { $error++; $errors[] = $db->lasterror(); } - } -} elseif (preg_match('/set_(.*)/', $action, $reg)) { - $code = $reg[1]; - $value = GETPOSTISSET($code) ? GETPOST($code, 'int') : 1; - $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - $errors[] = $db->lasterror(); - } + } else { + $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } - if (!$error) { - if ($code == 'TICKET_EMAIL_MUST_EXISTS') { - $res = dolibarr_del_const($db, 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST', $conf->entity); - if (!($res > 0)) { - $error++; - $errors[] = $db->lasterror(); - } - } elseif ($code == 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST') { - $res = dolibarr_del_const($db, 'TICKET_EMAIL_MUST_EXISTS', $conf->entity); - if (!($res > 0)) { - $error++; - $errors[] = $db->lasterror(); - } + if (!$error) { + if ($code == 'TICKET_EMAIL_MUST_EXISTS') { + $res = dolibarr_del_const($db, 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } + } elseif ($code == 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST') { + $res = dolibarr_del_const($db, 'TICKET_EMAIL_MUST_EXISTS', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } - // enable captcha by default - // TODO Add a visible option in this setup page for this - $res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA_TICKET', 1, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - $errors[] = $db->lasterror(); + // enable captcha by default + // TODO Add a visible option in this setup page for this + $res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA_TICKET', 1, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + $errors[] = $db->lasterror(); + } } } } @@ -276,9 +277,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''.$langs->trans("TicketsEmailMustExist").''; print ''; if (empty(getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS'))) { - print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; } else { - print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; } print ''; print ''; @@ -290,9 +291,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''.$langs->trans("TicketCreateThirdPartyWithContactIfNotExist").''; print ''; if (empty(getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST'))) { - print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; + print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; } else { - print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; + print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; } print ''; print ''; From d4ad93a94d9309f996663b8de24d6367c3594572 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Sep 2022 16:33:54 +0200 Subject: [PATCH 10/24] TODO Add a visible option for captcha for ticket --- htdocs/core/class/html.formticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 341c21e06f0..281bf927944 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -426,7 +426,7 @@ class FormTicket $doleditor->Create(); print ''; - if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) { + if ($public && (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) || !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET))) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; print ''; print ''; From d532ad1c8e9589884b5f1b074dff122fdff935a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Sep 2022 16:53:15 +0200 Subject: [PATCH 11/24] Fix test ldap --- htdocs/core/class/ldap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 689fbe6845e..83e3adeda93 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -1060,7 +1060,7 @@ class Ldap //print_r($info); for ($i = 0; $i < $info["count"]; $i++) { - $recordid = $this->convToOutputCharset($info[$i][$useridentifier][0], $this->ldapcharset); + $recordid = $this->convToOutputCharset($info[$i][strtolower($useridentifier)][0], $this->ldapcharset); if ($recordid) { //print "Found record with key $useridentifier=".$recordid."
\n"; $fulllist[$recordid][$useridentifier] = $recordid; From aafecb6d2bd69c946baa96bf302275dce1bb1c1f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Sep 2022 17:08:08 +0200 Subject: [PATCH 12/24] FIX missing the management of a constant in the Ticket config --- htdocs/admin/ticket_public.php | 32 +++++++++++++++------ htdocs/core/class/html.formticket.class.php | 2 +- htdocs/core/modules/modTicket.class.php | 3 +- htdocs/langs/en_US/ticket.lang | 2 ++ htdocs/public/ticket/create_ticket.php | 2 +- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 622a8aaf927..4a6d405df03 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -181,14 +181,6 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { $error++; $errors[] = $db->lasterror(); } - - // enable captcha by default - // TODO Add a visible option in this setup page for this - $res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA_TICKET', 1, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - $errors[] = $db->lasterror(); - } } } } @@ -273,6 +265,30 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print ''; print ''; + // Enable Captcha code + print ''; + print ''.$langs->trans("TicketUseCaptchaCode").''; + print ''; + if (function_exists("imagecreatefrompng")) { + if (!empty($conf->use_javascript_ajax)) { + print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA_TICKET'); + } else { + if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } + } + } else { + $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); + print $desc; + } + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUseCaptchaCodeHelp"), 1, 'help'); + print ''; + print ''; + // Check if email exists print ''.$langs->trans("TicketsEmailMustExist").''; print ''; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 281bf927944..b5ba0b0208e 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -426,7 +426,7 @@ class FormTicket $doleditor->Create(); print ''; - if ($public && (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) || !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET))) { + if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; print ''; print ''; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 13967fc4096..18f0d368cfd 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -117,7 +117,8 @@ class modTicket extends DolibarrModules 9 => array('TICKET_NOTIFICATION_EMAIL_FROM', 'chaine', getDolGlobalString('MAIN_MAIL_EMAIL_FROM'), 'Email to use by default as sender for messages sent from Dolibarr', 0), 10 => array('TICKET_MESSAGE_MAIL_INTRO', 'chaine', $langs->trans('TicketMessageMailIntroText'), 'Introduction text of ticket replies sent from Dolibarr', 0), 11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $default_signature, 'Signature to use by default for messages sent from Dolibarr', 0), - 12 => array('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER', 'chaine', "1", 'Disable the rendering of headers in tickets', 0) + 12 => array('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER', 'chaine', "1", 'Disable the rendering of headers in tickets', 0), + 13 => array('MAIN_SECURITY_ENABLECAPTCHA_TICKET', 'chaine', getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET'), 'Enable captcha code by default', 0) ); diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 3e252e407e4..1fe2e5b8a6e 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -149,6 +149,8 @@ TicketsAutoNotifyCloseHelp=When closing a ticket, you will be proposed to send a TicketWrongContact=Provided contact is not part of current ticket contacts. Email not sent. TicketChooseProductCategory=Product category for ticket support TicketChooseProductCategoryHelp=Select the product category of ticket support. This will be used to automatically link a contract to a ticket. +TicketUseCaptchaCode=Use graphical code (CAPTCHA) when creating a ticket +TicketUseCaptchaCodeHelp=Adds CAPTCHA verification when creating a new ticket. # # Index & list page diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 669c5e8d512..9ea689ec76c 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -218,7 +218,7 @@ if (empty($reshook)) { } // Check Captcha code if is enabled - if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) || !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) { + if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) { $sessionkey = 'dol_antispam_value'; $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml')))); if (!$ok) { From 50fe00ecd81116c5764163a3a74d2955645c36ef Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Sep 2022 17:40:56 +0200 Subject: [PATCH 13/24] FIX compatibility if javascript not actived --- htdocs/admin/ticket.php | 57 ++++++++++++++++++++++++---------- htdocs/admin/ticket_public.php | 18 +++++++---- 2 files changed, 53 insertions(+), 22 deletions(-) diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 99d1b34749f..28c9656d84d 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -81,6 +81,27 @@ if ($action == 'updateMask') { dolibarr_del_const($db, 'TICKET_ADDON_PDF', $conf->entity); } } +} 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) { + $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)) { + $error++; + } + } else { + $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + } +} elseif (preg_match('/del_(.*)/', $action, $reg)) { + $code = $reg[1]; + $res = dolibarr_del_const($db, $code, $conf->entity); + if (!($res > 0)) { + $error++; + } } elseif ($action == 'setdoc') { // Set default model if (dolibarr_set_const($db, "TICKET_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { @@ -100,16 +121,25 @@ if ($action == 'updateMask') { dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity); } elseif ($action == 'setvarworkflow') { - $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } + // For compatibility when javascript is not enabled + if (empty($conf->use_javascript_ajax)) { + $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } - $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; + $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } } $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); @@ -137,12 +167,6 @@ if ($action == 'updateMask') { if (!($res > 0)) { $error++; } - - $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) { - $error++; - } } elseif ($action == 'setvar') { include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; @@ -191,7 +215,8 @@ if ($action == 'updateMask') { $error++; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + // For compatibility when javascript is not enabled + if ($conf->global->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)) { diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 4a6d405df03..c4b12852071 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -150,24 +150,30 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { $error++; $errors[] = $db->lasterror(); } -} 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) { + // For compatibility when javascript is not enabled + if ($conf->global->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)) { $error++; $errors[] = $db->lasterror(); } + } +} 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) { + $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)) { + $error++; + } } else { $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; - $errors[] = $db->lasterror(); } - if (!$error) { if ($code == 'TICKET_EMAIL_MUST_EXISTS') { $res = dolibarr_del_const($db, 'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST', $conf->entity); From b4881e629b03e71faf6012fe8a55ae0eca939ced Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Sep 2022 19:21:29 +0200 Subject: [PATCH 14/24] FIX missing error message if image size too large --- htdocs/admin/company.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index c72976f829e..f3fc12c8ae4 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -107,7 +107,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) $dirforimage = $conf->mycompany->dir_output.'/logos/'; $arrayofimages = array('logo', 'logo_squarred'); - + //var_dump($_FILES); exit; foreach ($arrayofimages as $varforimage) { if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. $langs->load("errors"); @@ -115,7 +115,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) break; } - if ($_FILES[$varforimage]["tmp_name"]) { + // Remove to check file size to large + /*if ($_FILES[$varforimage]["tmp_name"]) {*/ $reg = array(); if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { $original_file = $reg[1]; @@ -165,6 +166,9 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) $langs->load("errors"); $tmparray = explode(':', $result); setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); + } elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) { + $error++; + setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors'); } else { $error++; setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); @@ -175,7 +179,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); } } - } + /*}*/ } dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); From 310f95f17351c009d560dae189c4dffcc5421f01 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 27 Sep 2022 17:31:22 +0000 Subject: [PATCH 15/24] Fixing style errors. --- htdocs/admin/company.php | 96 ++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index f3fc12c8ae4..4f4af520df7 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -118,67 +118,67 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) // Remove to check file size to large /*if ($_FILES[$varforimage]["tmp_name"]) {*/ $reg = array(); - if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { - $original_file = $reg[1]; + if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { + $original_file = $reg[1]; - $isimage = image_format_supported($original_file); - if ($isimage >= 0) { - dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); - if (!is_dir($dirforimage)) { - dol_mkdir($dirforimage); + $isimage = image_format_supported($original_file); + if ($isimage >= 0) { + dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); + if (!is_dir($dirforimage)) { + dol_mkdir($dirforimage); + } + $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); + if ($result > 0) { + $constant = "MAIN_INFO_SOCIETE_LOGO"; + if ($varforimage == 'logo_squarred') { + $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; } - $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); - if ($result > 0) { - $constant = "MAIN_INFO_SOCIETE_LOGO"; - if ($varforimage == 'logo_squarred') { - $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; - } - dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity); - // Create thumbs of logo (Note that PDF use original file and not thumbs) - if ($isimage > 0) { - // Create thumbs - //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... + // Create thumbs of logo (Note that PDF use original file and not thumbs) + if ($isimage > 0) { + // Create thumbs + //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... - // Create small thumb, Used on logon for example - $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); - if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) { - $imgThumbSmall = $reg[1]; // Save only basename - dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); - } else { - dol_syslog($imgThumbSmall); - } - - // Create mini thumb, Used on menu or for setup page for example - $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality); - if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) { - $imgThumbMini = $reg[1]; // Save only basename - dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); - } else { - dol_syslog($imgThumbMini); - } + // Create small thumb, Used on logon for example + $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) { + $imgThumbSmall = $reg[1]; // Save only basename + dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); } else { - dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING); + dol_syslog($imgThumbSmall); + } + + // Create mini thumb, Used on menu or for setup page for example + $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality); + if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) { + $imgThumbMini = $reg[1]; // Save only basename + dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); + } else { + dol_syslog($imgThumbMini); } - } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { - $error++; - $langs->load("errors"); - $tmparray = explode(':', $result); - setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); - } elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) { - $error++; - setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors'); } else { - $error++; - setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING); } - } else { + } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); + $tmparray = explode(':', $result); + setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors'); + } elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) { + $error++; + setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors'); + } else { + $error++; + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } + } else { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); } + } /*}*/ } From 8c5cb7ce34c977083b849e1b532577c0ebb222c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Sep 2022 22:00:04 +0200 Subject: [PATCH 16/24] FIX Duplicate in list when filtering on categories --- .../knowledgerecord_list.php | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index f9d9c47f103..5ff747620aa 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -246,9 +246,6 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } -if (!empty($searchCategoryKnowledgemanagementList) || !empty($catid)) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_knowledgemanagement as ck ON t.rowid = ck.fk_knowledgemanagement"; // We'll need this table joined to the select in order to filter by categ -} // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -287,29 +284,29 @@ foreach ($search as $key => $val) { } } } -//Search for tag/category -$searchCategoryKnowledgemanagementSqlList = array(); -if ($searchCategoryKnowledgemanagementOperator == 1) { + +// Search for tag/category ($searchCategoryKnowledgemanagementList is an array of ID) +if (!empty($searchCategoryKnowledgemanagementList)) { + $searchCategoryKnowledgemanagementSqlList = array(); + $listofcategoryid = ''; foreach ($searchCategoryKnowledgemanagementList as $searchCategoryKnowledgemanagement) { if (intval($searchCategoryKnowledgemanagement) == -2) { - $searchCategoryKnowledgemanagementSqlList[] = "ck.fk_categorie IS NULL"; + $searchCategoryKnowledgemanagementSqlList[] = "NOT EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement)"; } elseif (intval($searchCategoryKnowledgemanagement) > 0) { - $searchCategoryKnowledgemanagementSqlList[] = "ck.fk_categorie = ".$db->escape($searchCategoryKnowledgemanagement); + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryKnowledgemanagement); } } - if (!empty($searchCategoryKnowledgemanagementSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryKnowledgemanagementSqlList).")"; + if ($listofcategoryid) { + $searchCategoryKnowledgemanagementSqlList[] = " EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } -} else { - foreach ($searchCategoryKnowledgemanagementList as $searchCategoryKnowledgemanagement) { - if (intval($searchCategoryKnowledgemanagement) == -2) { - $searchCategoryKnowledgemanagementSqlList[] = "ck.fk_categorie IS NULL"; - } elseif (intval($searchCategoryKnowledgemanagement) > 0) { - $searchCategoryKnowledgemanagementSqlList[] = "t.rowid IN (SELECT fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement WHERE fk_categorie = ".((int) $searchCategoryKnowledgemanagement).")"; + if ($searchCategoryKnowledgemanagementOperator == 1) { + if (!empty($searchCategoryKnowledgemanagementSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryKnowledgemanagementSqlList).")"; + } + } else { + if (!empty($searchCategoryKnowledgemanagementSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryKnowledgemanagementSqlList).")"; } - } - if (!empty($searchCategoryKnowledgemanagementSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryKnowledgemanagementSqlList).")"; } } From 09b3311d45155b9ee3e24bc09a75a15eaaaf6fed Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 28 Sep 2022 08:16:50 +0200 Subject: [PATCH 17/24] fix: Download Accoutancy file result to Expired Token --- htdocs/compta/accounting-files.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 3942e7cb6dd..99e6430a1e5 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -614,7 +614,7 @@ if (!empty($date_start) && !empty($date_stop)) { echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel'); - print ' Date: Wed, 28 Sep 2022 09:25:22 +0200 Subject: [PATCH 18/24] php V7 --- htdocs/core/modules/propale/mod_propale_saphir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 72ca13f3a4c..39a9c9e6195 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -144,7 +144,7 @@ class mod_propale_saphir extends ModeleNumRefPropales // Get entities $entity = getEntity('proposalnumber', 1, $propal); - $date = isset($propal->date)?$propal->date:dol_now(); + $date = $propal->date ?? dol_now(); $numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity); From 8aa7087fe8115aa04ad05ba92c699319513642b8 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 28 Sep 2022 11:07:36 +0200 Subject: [PATCH 19/24] Fix: Not correctly link the contract to the ticket. --- .../interface_20_modWorkflow_WorkflowManager.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index cc6a1168c32..884790c990e 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010 Regis Houssin * Copyright (C) 2011-2017 Laurent Destailleur * Copyright (C) 2014 Marcos García + * Copyright (C) 2022 Ferran Marcet * * 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 @@ -445,8 +446,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers if (is_array($list) && !empty($list)) { $number_contracts_found = count($list); if ($number_contracts_found == 1) { - $contractid = $list[0]->id; - $object->setContract($contractid); + foreach ($list as $linked_contract) { + $object->setContract($linked_contract->id); + } break; } elseif ($number_contracts_found > 1) { foreach ($list as $linked_contract) { From e63432379c690d1811dcf1801fe70bfe4073aa4c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Sep 2022 14:23:28 +0200 Subject: [PATCH 20/24] Doc --- htdocs/public/onlinesign/newonlinesign.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index e99d072d701..5a0031dbcae 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -169,7 +169,7 @@ if ($action == 'confirm_refusepropal' && $confirm == 'yes') { $message = 'refused'; setEventMessages("PropalRefused", null, 'warnings'); if (method_exists($object, 'call_trigger')) { - //customer is not a user !?! so could we use same user as validation ? + // Online customer is not a user, so we use the use that validates the documents $user = new User($db); $user->fetch($object->user_valid_id); $result = $object->call_trigger('PROPAL_CLOSE_REFUSED', $user); From a16755b5c138bc6e0b300df799e8e02c2e71dc06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Sep 2022 15:47:39 +0200 Subject: [PATCH 21/24] Fix label of name of company in import profile --- htdocs/core/modules/modSociete.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 7f7624b167f..2cbab7967e8 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -464,7 +464,7 @@ class modSociete extends DolibarrModules 'extra' => MAIN_DB_PREFIX.'societe_extrafields' ); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array(//field order as per structure of table llx_societe - 's.nom' => "Name*", + 's.nom' => "ThirdPartyName*", 's.name_alias' => "AliasNameShort", 's.parent' => "ParentCompany", 's.status' => "Status*", @@ -685,7 +685,7 @@ class modSociete extends DolibarrModules 's.accountancy_code_buy' => '607', ); $this->import_updatekeys_array[$r] = array( - 's.nom' => 'Name', + 's.nom' => 'ThirdPartyName', 's.zip' => 'Zip', 's.email' => 'Email', 's.code_client' => 'CustomerCode', From 3e9e17c746ef6a5ce092d603e6e891a459285c6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Sep 2022 16:55:51 +0200 Subject: [PATCH 22/24] Debug tooltip of import tool --- htdocs/core/modules/modSociete.class.php | 6 +++--- htdocs/imports/import.php | 13 +++++++------ htdocs/langs/en_US/exports.lang | 4 ++-- htdocs/langs/fr_FR/exports.lang | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 2cbab7967e8..906b5644f89 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -724,7 +724,7 @@ class modSociete extends DolibarrModules $i++; } - // Import list of contacts/additional addresses and attributes + // Import list of contacts/addresses of thirparties and attributes $r++; $this->import_code[$r] = $this->rights_class.'_'.$r; $this->import_label[$r] = 'ImportDataset_company_2'; @@ -767,7 +767,7 @@ class modSociete extends DolibarrModules } } // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { // This can fail when class is used on an old database (during a migration for example) while ($obj = $this->db->fetch_object($resql)) { @@ -794,7 +794,7 @@ class modSociete extends DolibarrModules 'classfile' => '/core/class/cstate.class.php', 'class' => 'Cstate', 'method' => 'fetch', - 'dict' => 'DictionaryStateCode' + 'dict' => 'DictionaryCanton' ), 's.fk_pays' => array( 'rule' => 'fetchidfromcodeid', diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 8916041520d..dfe2d0b9d49 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1110,7 +1110,7 @@ if ($step == 4 && $datatoimport) { $height = '32px'; //needs px for css height attribute below $i = 0; $mandatoryfieldshavesource = true; - $more = ""; + //var_dump($fieldstarget); //var_dump($optionsall); //exit; @@ -1176,10 +1176,10 @@ if ($step == 4 && $datatoimport) { $filecolumntoshow = num2Alpha($i); } else { if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromref') { - $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'
'; + $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $langs->transnoentitiesnoconv($entitylang)).'
'; } if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromcodeid') { - $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'
'; + $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$tmpcode]['dict'])).'
'; } } // Source required @@ -1191,9 +1191,9 @@ if ($step == 4 && $datatoimport) { } } else { if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromref') { - $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.str_replace('"', '', $example).')' : '').'
'; } elseif ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromcodeid') { - $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$tmpcode]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.str_replace('"', '', $example).')' : '').'
'; } elseif ($example) { $htmltext .= $langs->trans("SourceExample").': '.str_replace('"', '', $example).'
'; } @@ -1203,7 +1203,8 @@ if ($step == 4 && $datatoimport) { $htmltext .= $langs->trans("FormatControlRule").': '.str_replace('"', '', $objimport->array_import_regex[0][$tmpcode]).'
'; } - $htmltext .= $langs->trans("Table")."->".$langs->trans("Field").':   '.$tablename."->".preg_replace('/^.*\./', '', $tmpcode).""; + //var_dump($htmltext); + $htmltext .= $langs->trans("InformationOnTargetTables").':   '.$tablename."->".preg_replace('/^.*\./', '', $tmpcode).""; $labelhtml = $label.' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 1); diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index c4c629c9a87..090af7c6a11 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -95,8 +95,8 @@ NbOfLinesOK=Number of lines with no errors and no warnings: %s. NbOfLinesImported=Number of lines successfully imported: %s. DataComeFromNoWhere=Value to insert comes from nowhere in source file. DataComeFromFileFieldNb=Value to insert comes from column %s in source file. -DataComeFromIdFoundFromRef=Value that comes from column %s of source file will be used to find the id of the parent object to use (so the object %s that has the ref. from source file must exist in the database). -DataComeFromIdFoundFromCodeId=Code that comes from column %s of source file will be used to find the id of the parent object to use (so the code from source file must exist in the dictionary %s). Note that if you know the id, you can also use it in the source file instead of the code. Import should work in both cases. +DataComeFromIdFoundFromRef=The value that comes from the source file will be used to find the id of the parent object to use (so the object %s that has the ref. from source file must exist in the database). +DataComeFromIdFoundFromCodeId=The value of code that comes from source file will be used to find the id of the parent object to use (so the code from source file must exist in the dictionary %s). Note that if you know the id, you can also use it in the source file instead of the code. Import should work in both cases. DataIsInsertedInto=Data coming from source file will be inserted into the following field: DataIDSourceIsInsertedInto=The id of the parent object, that was found using the data in the source file, will be inserted into the following field: DataCodeIDSourceIsInsertedInto=The id of the parent line, that was found from code, will be inserted into the following field: diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 6460fa7e5b1..665173fd58e 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -95,8 +95,8 @@ NbOfLinesOK=Nombre de lignes sans erreur ni avertissement : %s. NbOfLinesImported=Nombre de lignes importées avec succès : %s. DataComeFromNoWhere=La valeur à insérer n'est issue d'aucun champ du fichier source. DataComeFromFileFieldNb=La valeur à insérer provient de la colonne %s dans le fichier source. -DataComeFromIdFoundFromRef=La valeur provenant de la colonne %s du fichier source sera utilisée pour trouver l'identifiant de l'objet parent à utiliser (donc l'objet %s qui a la référence du fichier source doit exister dans la base de données). -DataComeFromIdFoundFromCodeId=Le code provenant de la colonne %s du fichier source sera utilisé pour trouver l'id de l'objet parent à utiliser (donc le code du fichier source doit exister dans le dictionnaire %s ). Notez que si vous connaissez l'identifiant, vous pouvez également l'utiliser dans le fichier source à la place du code. L'importation devrait fonctionner dans les deux cas. +DataComeFromIdFoundFromRef=La valeur provenant du fichier source sera utilisée pour trouver l'identifiant de l'objet parent à utiliser (donc l'objet %s qui a la référence du fichier source doit exister dans la base de données). +DataComeFromIdFoundFromCodeId=Le valeur du code provenant du fichier source sera utilisé pour trouver l'id de l'objet parent à utiliser (donc le code du fichier source doit exister dans le dictionnaire %s ). Notez que si vous connaissez l'identifiant, vous pouvez également l'utiliser dans le fichier source à la place du code. L'importation devrait fonctionner dans les deux cas. DataIsInsertedInto=La donnée issue du fichier source sera insérée dans le champ suivant: DataIDSourceIsInsertedInto=L'identifiant de l'objet père, retrouvé à partir de la donnée dans le fichier source, sera inséré dans le champ suivant : DataCodeIDSourceIsInsertedInto=L'identifiant de la ligne père, retrouvé à partir du code, sera inséré dans le champ suivant : From 1bb1c2eb3e275176e9ed1a1fd551e4223bc63fcc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Sep 2022 19:45:14 +0200 Subject: [PATCH 23/24] Fix test inverted on SOCIETE_DISABLE_PARENTCOMPANY --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index f55f1c37867..8b54c66ad58 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -3144,7 +3144,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Subsidiaries list - if (!empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY) && empty($conf->global->SOCIETE_DISABLE_SHOW_SUBSIDIARIES)) { + if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY) && empty($conf->global->SOCIETE_DISABLE_SHOW_SUBSIDIARIES)) { $result = show_subsidiaries($conf, $langs, $db, $object); } From dd4d73fd69ca073b50af039bea470dcde5da4856 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 28 Sep 2022 20:29:50 +0200 Subject: [PATCH 24/24] Update mod_propale_saphir.php --- htdocs/core/modules/propale/mod_propale_saphir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 39a9c9e6195..3e6ec1507e5 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -144,7 +144,7 @@ class mod_propale_saphir extends ModeleNumRefPropales // Get entities $entity = getEntity('proposalnumber', 1, $propal); - $date = $propal->date ?? dol_now(); + $date = empty($propal->date) ? dol_now() : $propal->date; $numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity);