From ec45ca8abe18dd331fb2094186e3f872c7e570e8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 6 Apr 2024 13:28:58 +0200 Subject: [PATCH 1/5] FIX avoid php warnings (#29247) --- .../core/class/commondocgenerator.class.php | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f0ca3deca89..03adbbb6a66 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -747,16 +747,20 @@ abstract class CommonDocGenerator if (isset($line->fk_product) && $line->fk_product > 0) { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($line->fk_product); - foreach ($tmpproduct->array_options as $key => $label) { - $resarray["line_product_".$key] = $label; + if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) { + foreach ($tmpproduct->array_options as $key => $label) { + $resarray["line_product_".$key] = $label; + } } } else { // Set unused placeholders as blank $extrafields->fetch_name_optionals_label("product"); $extralabels = $extrafields->attributes["product"]['label']; - foreach ($extralabels as $key => $label) { - $resarray['line_product_options_'.$key] = ''; + if (!empty($extralabels) && is_array($extralabels)) { + foreach ($extralabels as $key => $label) { + $resarray['line_product_options_'.$key] = ''; + } } } @@ -879,8 +883,11 @@ abstract class CommonDocGenerator if (isset($line->fk_product) && $line->fk_product > 0) { $tmpproduct = new Product($this->db); $tmpproduct->fetch($line->fk_product); - foreach ($tmpproduct->array_options as $key=>$label) - $resarray["line_product_".$key] = $label; + if (!empty($tmpproduct->array_options) && is_array($tmpproduct->array_options)) { + foreach ($tmpproduct->array_options as $key=>$label) { + $resarray["line_product_".$key] = $label; + } + } } return $resarray; @@ -910,13 +917,17 @@ abstract class CommonDocGenerator $array_other['object_'.$key] = $value; } elseif (is_array($value) && $recursive) { $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); - foreach ($tmparray as $key2 => $value2) { - $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + if (!empty($tmparray) && is_array($tmparray)) { + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } elseif (is_object($value) && $recursive) { $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); - foreach ($tmparray as $key2 => $value2) { - $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + if (!empty($tmparray) && is_array($tmparray)) { + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } } @@ -1350,7 +1361,9 @@ abstract class CommonDocGenerator $extrafields = $this->extrafieldsCache; $extrafieldOutputContent = ''; - if (isset($object->array_options[$extrafieldOptionsKey])) $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element, $outputlangs); + if (isset($object->array_options[$extrafieldOptionsKey])) { + $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element, $outputlangs); + } // TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images... like a getName methode ... if ($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link') { From 7213455fd3fd937b651e9f3ca41e5b9ac5b465eb Mon Sep 17 00:00:00 2001 From: Eric <1468823+rycks@users.noreply.github.com> Date: Mon, 8 Apr 2024 23:35:52 +0200 Subject: [PATCH 2/5] on tasks status is statut (#29285) --- htdocs/core/ajax/objectonoff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 0818dc823a4..2d71b29cdbd 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -77,7 +77,7 @@ if (!empty($user->socid)) { // We check permission. // Check is done on $user->rights->element->create or $user->rights->element->subelement->create (because $action = 'set') -if (preg_match('/status$/', $field) || ($field == 'evenunsubscribe' && $object->table_element == 'mailing')) { +if (preg_match('/statu[st]$/', $field) || ($field == 'evenunsubscribe' && $object->table_element == 'mailing')) { restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission); } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products restrictedArea($user, 'produit|service', $object, 'product&product', '', '', 'rowid'); From b133d9386e310e8e5a18c9884a0e8162987e5d4e Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Tue, 9 Apr 2024 02:26:07 +0200 Subject: [PATCH 3/5] Fix #29279 Not admin that can create group have disabled button for group creation (#29286) * Fix #29279 Not admin that can create group have disabled button for group creation * Update eldy.lib.php --------- Co-authored-by: Jon Bendtsen Co-authored-by: Laurent Destailleur Conflicts: htdocs/core/menus/standard/eldy.lib.php --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b603f607e87..f9f9ba4fc79 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1191,7 +1191,7 @@ function get_left_menu_home($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $newmenu->add("/categories/index.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->hasRight('categorie', 'lire'), '', $mainmenu, 'cat'); } $newmenu->add("", $langs->trans("Groups"), 1, ($user->hasRight('user', 'user', 'lire') || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))); - $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight("user", "group_advance", "create") : $user->hasRight("user", "user", "create")) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))); + $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight("user", "group_advance", "create") : $user->hasRight("user", "user", "creer")) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))); $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) ? $user->hasRight('user', 'group_advance', 'read') : $user->hasRight('user', 'user', 'lire')) || $user->admin) && !(isModEnabled('multicompany') && $conf->entity > 1 && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))); } } From 5c3caa3f31986d237ef47e575e3af21e42e03f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Thu, 11 Apr 2024 20:51:50 +0200 Subject: [PATCH 4/5] Fix #29314 (#29315) * Fix #29314 Add method getFullName * Update conferenceorboothattendee.class.php --- .../class/conferenceorboothattendee.class.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index c0a7a713075..d35b2e1b577 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -1121,6 +1121,30 @@ class ConferenceOrBoothAttendee extends CommonObject return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } + + /** + * Return full name ('name+' '+lastname) + * + * @param Translate $langs Language object for translation of civility (used only if option is 1) + * @param int $option 0=No option + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname, 4=Lastname, 5=Lastname if defined else firstname + * @param int $maxlen Maximum length + * @return string String with full name + */ + public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) + { + $lastname = $this->lastname; + $firstname = $this->firstname; + if (empty($lastname)) { + $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : ''))))); + } + + $ret = ''; + + $ret .= dolGetFirstLastname($firstname, $lastname, $nameorder); + + return dol_trunc($ret, $maxlen); + } } From ed6247b640458552cd7b8116f0507b607a03f8e6 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Thu, 11 Apr 2024 22:03:27 +0200 Subject: [PATCH 5/5] 18 fix emailcollector false positive for type="recordjoinpiece" (#29308) * change git ignor * change git ignor * FIX: on email collector operation type : recordjoinpiece, check empty field return false positive * revert changes from origin branch * revert changes from origin branch * revert changes from origin branch * revert changes from origin branch --------- Co-authored-by: moreauf --- htdocs/emailcollector/class/emailcollector.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 22bebcbaa14..2f1cb793199 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2758,7 +2758,7 @@ class EmailCollector extends CommonObject $sql .= ' FROM ' . MAIN_DB_PREFIX . $objectdesc['table'] . ' AS t'; $sql .= ' WHERE '; foreach ($objectdesc['fields'] as $field) { - $sql .= "'" .$this->db->escape($subject) . "' LIKE CONCAT('%', t." . $field . ", '%') OR "; + $sql .= "('" .$this->db->escape($subject) . "' LIKE CONCAT('%', t." . $field . ", '%') AND t." . $field . "<>'') OR "; } $sql = substr($sql, 0, -4);