From 65edbd5f9f2f832b41597593be3ddd1a8084c08b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2024 15:50:47 +0200 Subject: [PATCH 1/7] FIX better compatibility with some old extrafield syntax filter --- .../html.formadvtargetemailing.class.php | 2 +- htdocs/core/class/commonobject.class.php | 27 +++++++++++++---- htdocs/core/class/extrafields.class.php | 29 ++++++++++++++----- htdocs/core/lib/functions.lib.php | 1 + 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 6a6e00b65ed..01957c93456 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -316,7 +316,7 @@ class FormAdvTargetEmailing extends Form // We have to join on extrafield table if (strpos($InfoFieldList[3], 'extra') !== false) { $sql .= ' as main, '.$this->db->sanitize(MAIN_DB_PREFIX.$InfoFieldList[0]).'_extrafields as extra'; - $sql .= " WHERE extra.fk_object=main.".$this->db->sanitize(empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2]); + $sql .= " WHERE extra.fk_object = main.".$this->db->sanitize(empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2]); $sql .= " AND ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[3], $errorstr, 1); } else { $sql .= " WHERE ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[3], $errorstr, 1); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 651b397cac3..efbb85a5cdc 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7625,6 +7625,14 @@ abstract class CommonObject $InfoFieldList = array_merge($InfoFieldList, explode(':', $tmpafter)); } //var_dump($InfoFieldList); + + // Fix better compatibility with some old extrafield syntax filter "(field=123)" + $reg = array(); + if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; + } + + //var_dump($InfoFieldList); } //$Usf = empty($paramoptions[1]) ? '' :$paramoptions[1]; @@ -7680,8 +7688,8 @@ abstract class CommonObject // We have to join on extrafield table $errstr = ''; if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= " as main, " . $this->db->prefix() . $InfoFieldList[0] . "_extrafields as extra"; - $sqlwhere .= " WHERE extra.fk_object = main." . $InfoFieldList[2]; + $sql .= " as main, " . $this->db->sanitize($this->db->prefix() . $InfoFieldList[0]) . "_extrafields as extra"; + $sqlwhere .= " WHERE extra.fk_object = main." . $this->db->sanitize($InfoFieldList[2]); $sqlwhere .= " AND " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); } else { $sqlwhere .= " WHERE " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); @@ -7690,7 +7698,7 @@ abstract class CommonObject $sqlwhere .= ' WHERE 1=1'; } - // Add Usf filter + // Add Usf filter on second line /* if ($Usf) { $errorstr = ''; @@ -7849,6 +7857,13 @@ abstract class CommonObject if ($tmpafter !== '') { $InfoFieldList = array_merge($InfoFieldList, explode(':', $tmpafter)); } + + // Fix better compatibility with some old extrafield syntax filter "(field=123)" + $reg = array(); + if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; + } + //var_dump($InfoFieldList); } @@ -7906,9 +7921,11 @@ abstract class CommonObject } // We have to join on extrafield table + $errstr = ''; if (strpos($InfoFieldList[4], 'extra') !== false) { - $sql .= ' as main, ' . $this->db->prefix() . $InfoFieldList[0] . '_extrafields as extra'; - $sqlwhere .= " WHERE extra.fk_object = main." . $InfoFieldList[2] . " AND " . $InfoFieldList[4]; + $sql .= ' as main, ' . $this->db->sanitize($this->db->prefix() . $InfoFieldList[0]) . '_extrafields as extra'; + $sqlwhere .= " WHERE extra.fk_object = main." . $this->db->sanitize($InfoFieldList[2]); + $sqlwhere .= " AND " . $InfoFieldList[4]; } else { $sqlwhere .= " WHERE " . $InfoFieldList[4]; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 77fae4a7349..2956e1ca130 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1340,7 +1340,7 @@ class ExtraFields // If there is a filter, we extract it by taking all content inside parenthesis. if (! empty($InfoFieldList[4])) { - $pos = 0; + $pos = 0; // $pos will be position of ending filter $parenthesisopen = 0; while (substr($InfoFieldList[4], $pos, 1) !== '' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) != ':')) { if (substr($InfoFieldList[4], $pos, 1) == '(') { @@ -1358,6 +1358,13 @@ class ExtraFields if ($tmpafter !== '') { $InfoFieldList = array_merge($InfoFieldList, explode(':', $tmpafter)); } + + // Fix better compatibility with some old extrafield syntax filter "(field=123)" + $reg = array(); + if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; + } + //var_dump($InfoFieldList); } @@ -1414,14 +1421,15 @@ class ExtraFields } else { $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); } - //We have to join on extrafield table + + // We have to join on extrafield table $errstr = ''; if (strpos($InfoFieldList[4], 'extra.') !== false) { - $sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra'; - $sqlwhere .= " WHERE extra.fk_object = main.".$InfoFieldList[2]." AND ".$InfoFieldList[4]; + $sql .= ' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).'_extrafields as extra'; + $sqlwhere .= " WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]); $sqlwhere .= " AND " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); } else { - $sqlwhere .= " AND " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); + $sqlwhere .= " WHERE " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); } } else { $sqlwhere .= ' WHERE 1=1'; @@ -1575,6 +1583,13 @@ class ExtraFields if ($tmpafter !== '') { $InfoFieldList = array_merge($InfoFieldList, explode(':', $tmpafter)); } + + // Fix better compatibility with some old extrafield syntax filter "(field=123)" + $reg = array(); + if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; + } + //var_dump($InfoFieldList); } @@ -1683,8 +1698,8 @@ class ExtraFields // We have to join on extrafield table $errstr = ''; if (strpos($InfoFieldList[4], 'extra.') !== false) { - $sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra'; - $sqlwhere .= " WHERE extra.fk_object = main.".$InfoFieldList[2]; + $sql .= ' as main, '.$this->db->sanitize($this->db->prefix().$InfoFieldList[0]).'_extrafields as extra'; + $sqlwhere .= " WHERE extra.fk_object = main.".$this->db->sanitize($InfoFieldList[2]); $sqlwhere .= " AND " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); } else { $sqlwhere .= " WHERE " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 11fedc5ef0b..494235e1c6b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -13356,6 +13356,7 @@ function forgeSQLFromUniversalSearchCriteria($filter, &$errorstr = '', $noand = if ($noerror) { return '1 = 2'; } else { + dol_syslog("forgeSQLFromUniversalSearchCriteria Filter error - ".$errorstr, LOG_WARNING); return 'Filter error - '.$tmperrorstr; // Bad syntax of the search string, we return an error message or force a SQL not found } } From cd8ddb7a8b8cb45a1ffac386726247e3d015e0d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2024 15:59:13 +0200 Subject: [PATCH 2/7] FIX better compatibility with some old extrafield syntax filter --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/extrafields.class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index efbb85a5cdc..f57c443ad12 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7628,7 +7628,7 @@ abstract class CommonObject // Fix better compatibility with some old extrafield syntax filter "(field=123)" $reg = array(); - if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + if (preg_match('/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; } @@ -7860,7 +7860,7 @@ abstract class CommonObject // Fix better compatibility with some old extrafield syntax filter "(field=123)" $reg = array(); - if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + if (preg_match('/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 2956e1ca130..e2f7e3f8dac 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1361,7 +1361,7 @@ class ExtraFields // Fix better compatibility with some old extrafield syntax filter "(field=123)" $reg = array(); - if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + if (preg_match('/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; } @@ -1586,7 +1586,7 @@ class ExtraFields // Fix better compatibility with some old extrafield syntax filter "(field=123)" $reg = array(); - if (preg_match('/$\(([a-z0-9]+)([=<>]+)(\d+)\)$/i', $InfoFieldList[4], $reg)) { + if (preg_match('/^\(?([a-z0-9]+)([=<>]+)(\d+)\)?$/i', $InfoFieldList[4], $reg)) { $InfoFieldList[4] = '('.$reg[1].':'.$reg[2].':'.$reg[3].')'; } From a72d242231391798575742a1f1c270ffdf475038 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Sep 2024 16:09:59 +0200 Subject: [PATCH 3/7] Doc --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6bb15da4182..bbd341b5d7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,7 @@ NEW: Font param Look and Feel THEME_FONT_FAMILY (#29302) NEW: Param to show main menu logo in color (#29305) NEW: #27048 add form to globally set "VARIANT_ALLOW_STOCK_MOVEMENT_ON_VARIANT_PARENT" variable (#27049) NEW: #29274 Add possibility to have different mail for autocopy for holiday (#29275) -NEW: WebPortal module +NEW: Module WebPortal experimental NEW: Module Bookcal is now experimental (TimeZone not yet supported) NEW: #24031 add option MAIN_GRANDTOTAL_LIST_SHOW to always show grand total to lists (#27247) NEW: #28070 Adding mobile phone to thirdparty From cb3ce12bfc6aa40385d526093c65978841685d1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2024 02:25:45 +0200 Subject: [PATCH 4/7] Debug webportal module Fix #30981 --- htdocs/core/class/html.form.class.php | 18 ++++++++++++ htdocs/public/webportal/css/global.css.php | 4 +++ htdocs/public/webportal/tpl/footer.tpl.php | 12 ++++---- .../public/webportal/webportal.main.inc.php | 22 +++++++++++---- htdocs/webportal/admin/setup.php | 21 ++++++++------ htdocs/webportal/class/controller.class.php | 1 - .../class/html.formlistwebportal.class.php | 28 ++++++++++++++----- .../class/html.formwebportal.class.php | 20 ++++++++----- 8 files changed, 91 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b42da7a7206..641d6ef3400 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2260,9 +2260,27 @@ class Form $textforempty = $show_empty; } $out .= '' . "\n"; + + $outarray[($show_empty < 0 ? $show_empty : -1)] = $textforempty; + $outarray2[($show_empty < 0 ? $show_empty : -1)] = array( + 'id' => ($show_empty < 0 ? $show_empty : -1), + 'label' => $textforempty, + 'labelhtml' => $textforempty, + 'color' => '', + 'picto' => '' + ); } if ($show_every) { $out .= '' . "\n"; + + $outarray[-2] = $textforempty; + $outarray2[-2] = array( + 'id' => -2, + 'label' => '-- ' . $langs->trans("Everybody") . ' --', + 'labelhtml' => '-- ' . $langs->trans("Everybody") . ' --', + 'color' => '', + 'picto' => '' + ); } $userstatic = new User($this->db); diff --git a/htdocs/public/webportal/css/global.css.php b/htdocs/public/webportal/css/global.css.php index 8f88a1e9f77..83bf9c40b3b 100644 --- a/htdocs/public/webportal/css/global.css.php +++ b/htdocs/public/webportal/css/global.css.php @@ -112,6 +112,10 @@ ul.menu-entries-alt { display: none; } +.maxwidthdate { + max-width: 110px; +} + @media (max-width: 576px) { ul.brand li.brand { padding-left: 0px; diff --git a/htdocs/public/webportal/tpl/footer.tpl.php b/htdocs/public/webportal/tpl/footer.tpl.php index bc45805cf3d..820af7f8218 100644 --- a/htdocs/public/webportal/tpl/footer.tpl.php +++ b/htdocs/public/webportal/tpl/footer.tpl.php @@ -25,7 +25,7 @@ $useJNotify = true; $context->loadEventMessages(); // alert success if (!empty($context->eventMessages['mesgs'])) { - $htmlSuccess = ''; if ($useJNotify) { $jsSuccess = ' jQuery.jnotify("' . dol_escape_js($htmlSuccess) . '", @@ -45,7 +45,7 @@ if (!empty($context->eventMessages['mesgs'])) { } // alert warning if (!empty($context->eventMessages['warnings'])) { - $htmlWarning = ''; if ($useJNotify) { $jsWarning .= 'jQuery.jnotify("' . dol_escape_js($htmlWarning) . '", "warning", true);'; } } // alert error if (!empty($context->eventMessages['errors'])) { - $htmlError = ''; if ($useJNotify) { $jsError .= 'jQuery.jnotify("' . dol_escape_js($htmlError) . '", "error", true );'; } diff --git a/htdocs/public/webportal/webportal.main.inc.php b/htdocs/public/webportal/webportal.main.inc.php index de198b4a494..85d304b6762 100644 --- a/htdocs/public/webportal/webportal.main.inc.php +++ b/htdocs/public/webportal/webportal.main.inc.php @@ -127,6 +127,7 @@ if (!defined('WEBPORTAL_NOREQUIRETRAN') || (!defined('WEBPORTAL_NOLOGIN') && !em if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->accessNeedLoggedUser)) { $admin_error_messages = array(); $webportal_logged_thirdparty_account_id = isset($_SESSION["webportal_logged_thirdparty_account_id"]) && $_SESSION["webportal_logged_thirdparty_account_id"] > 0 ? $_SESSION["webportal_logged_thirdparty_account_id"] : 0; + if (empty($webportal_logged_thirdparty_account_id)) { // It is not already authenticated and it requests the login / password $langs->loadLangs(array("other", "help", "admin")); @@ -193,6 +194,7 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access // We are already into an authenticated session $websiteaccount = new SocieteAccount($db); $result = $websiteaccount->fetch($webportal_logged_thirdparty_account_id); + if ($result <= 0) { $error++; @@ -208,12 +210,22 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access if (!$error) { $user_id = getDolGlobalInt('WEBPORTAL_USER_LOGGED'); - $result = $logged_user->fetch($user_id); - if ($result <= 0) { + + if ($user_id <= 0) { $error++; - $error_msg = $langs->transnoentitiesnoconv('WebPortalErrorFetchLoggedUser', $user_id); - dol_syslog($error_msg, LOG_ERR); - $context->setEventMessage($error_msg, 'errors'); + $error_msg = $langs->transnoentitiesnoconv('WebPortalSetupNotComplete', $user_id); + dol_syslog($error_msg, LOG_WARNING); + $context->setEventMessages($error_msg, null, 'errors'); + } + + if (!$error) { + $result = $logged_user->fetch($user_id); + if ($result <= 0) { + $error++; + $error_msg = $langs->transnoentitiesnoconv('WebPortalErrorFetchLoggedUser', $user_id); + dol_syslog($error_msg, LOG_ERR); + $context->setEventMessages($error_msg, null, 'errors'); + } } if (!$error) { diff --git a/htdocs/webportal/admin/setup.php b/htdocs/webportal/admin/setup.php index b5d02d8065d..8cb68dedde8 100644 --- a/htdocs/webportal/admin/setup.php +++ b/htdocs/webportal/admin/setup.php @@ -62,6 +62,18 @@ if (!class_exists('FormSetup')) { $formSetup = new FormSetup($db); +// Add logged user +//$formSetup->newItem('WEBPORTAL_USER_LOGGED2')->setAsSelectUser(); +// only enabled users +$userList = $formSetup->form->select_dolusers(getDolGlobalInt('WEBPORTAL_USER_LOGGED'), 'WEBPORTAL_USER_LOGGED', 1, null, 0, '', '', '0', 0, 0, '', 0, '', '', 1, 2); + +$item = $formSetup->newItem('WEBPORTAL_USER_LOGGED'); +$item->setAsSelect($userList); +$item->picto = 'user'; +$item->helpText = $langs->transnoentities('WebPortalUserLoggedHelp'); +// TODO Add a property mandatory to set style to "fieldrequired" and to add a check in submit + + // root url // @var FormSetupItem $item @@ -115,15 +127,6 @@ if (isModEnabled('member')) { $item->helpText = $langs->transnoentities('WebPortalMemberCardAccessHelp'); } -// Add logged user -//$formSetup->newItem('WEBPORTAL_USER_LOGGED2')->setAsSelectUser(); -// only enabled users -$userList = $formSetup->form->select_dolusers(getDolGlobalInt('WEBPORTAL_USER_LOGGED'), 'WEBPORTAL_USER_LOGGED', 0, null, 0, '', '', '0', 0, 0, '', 0, '', '', 1, 1); - -$item = $formSetup->newItem('WEBPORTAL_USER_LOGGED'); -$item->setAsSelect($userList); -$item->picto = 'user'; -$item->helpText = $langs->transnoentities('WebPortalUserLoggedHelp'); $setupnotempty += count($formSetup->items); diff --git a/htdocs/webportal/class/controller.class.php b/htdocs/webportal/class/controller.class.php index ddc3ae103df..b81ee646ca1 100644 --- a/htdocs/webportal/class/controller.class.php +++ b/htdocs/webportal/class/controller.class.php @@ -27,7 +27,6 @@ */ class Controller { - /** * if this controller need logged user or not * @var bool diff --git a/htdocs/webportal/class/html.formlistwebportal.class.php b/htdocs/webportal/class/html.formlistwebportal.class.php index 8dee9bb347b..3457eff8e24 100644 --- a/htdocs/webportal/class/html.formlistwebportal.class.php +++ b/htdocs/webportal/class/html.formlistwebportal.class.php @@ -48,7 +48,7 @@ class FormListWebPortal public $db; /** - * @var Form Instance of the Form + * @var FormWebPortal Instance of the Form */ public $form; @@ -158,6 +158,7 @@ class FormListWebPortal $search[$key] = GETPOST('search_' . $key, 'alpha'); } if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + /* Fix: this is not compatible with multilangage date format, replaced with dolibarr method $postDateStart = GETPOST('search_' . $key . '_dtstart', 'alphanohtml'); $postDateEnd = GETPOST('search_' . $key . '_dtend', 'alphanohtml'); // extract date YYYY-MM-DD for year, month and day @@ -175,6 +176,13 @@ class FormListWebPortal $dateEndDay = (int) $dateEndArr[2]; $search[$key . '_dtend'] = dol_mktime(23, 59, 59, $dateEndMonth, $dateEndDay, $dateEndYear); } + */ + $search[$key . '_dtstartmonth'] = GETPOSTINT('search_' . $key . '_dtstartmonth'); + $search[$key . '_dtstartday'] = GETPOSTINT('search_' . $key . '_dtstartday'); + $search[$key . '_dtstartyear'] = GETPOSTINT('search_' . $key . '_dtstartyear'); + $search[$key . '_dtendmonth'] = GETPOSTINT('search_' . $key . '_dtendmonth'); + $search[$key . '_dtendday'] = GETPOSTINT('search_' . $key . '_dtendday'); + $search[$key . '_dtendyear'] = GETPOSTINT('search_' . $key . '_dtendyear'); } } $this->search = $search; @@ -224,8 +232,14 @@ class FormListWebPortal foreach ($object->fields as $key => $val) { $search[$key] = ''; if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key . '_dtstart'] = ''; - $search[$key . '_dtend'] = ''; + //$search[$key . '_dtstart'] = ''; + //$search[$key . '_dtend'] = ''; + $search[$key . '_dtstartmonth'] = ''; + $search[$key . '_dtendmonth'] = ''; + $search[$key . '_dtstartday'] = ''; + $search[$key . '_dtendday'] = ''; + $search[$key . '_dtstartyear'] = ''; + $search[$key . '_dtendyear'] = ''; } } $this->search = $search; @@ -484,13 +498,13 @@ class FormListWebPortal if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { $html .= $this->form->selectarray('search_' . $key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', ''); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $postDateStart = GETPOST('search_' . $key . '_dtstart', 'alphanohtml'); - $postDateEnd = GETPOST('search_' . $key . '_dtend', 'alphanohtml'); + $postDateStart = dol_mktime(0, 0, 0, $search[$key . '_dtstartmonth'], $search[$key . '_dtstartday'], $search[$key . '_dtstartyear']); + $postDateEnd = dol_mktime(0, 0, 0, $search[$key . '_dtendmonth'], $search[$key . '_dtendday'], $search[$key . '_dtendyear']); - $html .= '
'; + $html .= '
'; $html .= $this->form->inputDate('search_' . $key . '_dtstart', $postDateStart ? $postDateStart : '', $langs->trans('From')); $html .= '
'; - $html .= '
'; + $html .= '
'; $html .= $this->form->inputDate('search_' . $key . '_dtend', $postDateEnd ? $postDateEnd : '', $langs->trans('to')); $html .= '
'; } else { diff --git a/htdocs/webportal/class/html.formwebportal.class.php b/htdocs/webportal/class/html.formwebportal.class.php index ab98fecb7a8..59cc07a8f40 100644 --- a/htdocs/webportal/class/html.formwebportal.class.php +++ b/htdocs/webportal/class/html.formwebportal.class.php @@ -93,18 +93,21 @@ class FormWebPortal extends Form /** * Input for date * - * @param string $name Name of html input - * @param string $value [=''] Value of input (format : YYYY-MM-DD) - * @param string $placeholder [=''] Placeholder for input (keep empty for no label) - * @param string $id [=''] Id - * @param string $morecss [=''] Class - * @param string $moreparam [=''] Add attributes (checked, required, etc) - * @return string Html for input date + * @param string $name Name of html input + * @param string|int $value [=''] Value of input (format : YYYY-MM-DD) + * @param string $placeholder [=''] Placeholder for input (keep empty for no label) + * @param string $id [=''] Id + * @param string $morecss [=''] Class + * @param string $moreparam [=''] Add attributes (checked, required, etc) + * @return string Html for input date */ public function inputDate($name, $value = '', $placeholder = '', $id = '', $morecss = '', $moreparam = '') { $out = ''; + // Disabled: Use of native browser date input field as it is not compliant with multilanguagedate format, + // nor with timezone management. + /* $out .= 'selectDate($value === '' ? -1 : $value, $name, 0, 0, 0, "", 1, 0, 0, ''); return $out; } From 8b5d80c930d9a7b054145346bfddbcb6083503de Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Tue, 17 Sep 2024 02:31:43 +0200 Subject: [PATCH 5/7] FIX member must be found to search the linked partnership (WebPortal) (#30977) --- htdocs/public/webportal/webportal.main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/webportal/webportal.main.inc.php b/htdocs/public/webportal/webportal.main.inc.php index 85d304b6762..2ee4778aad6 100644 --- a/htdocs/public/webportal/webportal.main.inc.php +++ b/htdocs/public/webportal/webportal.main.inc.php @@ -255,7 +255,7 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access $context->setEventMessage($error_msg, 'errors'); } - if (!$error) { + if (!$error && $logged_member->id > 0) { // get partnership $logged_partnership = new WebPortalPartnership($db); // @phan-suppress-next-line PhanPluginSuspiciousParamPosition From ee76404ecfc6da76824394ef30477ba85a73c20c Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Tue, 17 Sep 2024 02:34:05 +0200 Subject: [PATCH 6/7] FIX param id in website account list from third-party card (#30975) --- htdocs/societe/website.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 21bdeab9e85..21549f3f185 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -327,7 +327,7 @@ llxHeader('', $title); $arrayofselected = is_array($toselect) ? $toselect : array(); -$param = ''; +$param = 'id='.$object->id; if (!empty($mode)) { $param .= '&mode='.urlencode($mode); } From 721250edc835eb9b29e2bf20e5ee1d8ff4d916c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Sep 2024 02:46:39 +0200 Subject: [PATCH 7/7] Fix type hint --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 494235e1c6b..8af20ea8e24 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10124,7 +10124,7 @@ function dol_osencode($str) * Store also Code-Id into a cache to speed up next request on same table and key. * * @param DoliDB $db Database handler - * @param string $key Code or Id to get Id or Code + * @param string|int $key Code (string) or Id (int) to get Id or Code * @param string $tablename Table name without prefix * @param string $fieldkey Field to search the key into * @param string $fieldid Field to get