From f873f9aa6504fd0f17e863e302faaeae611f38e2 Mon Sep 17 00:00:00 2001 From: Jon Bendtsen Date: Mon, 1 Apr 2024 11:35:57 +0200 Subject: [PATCH 01/19] will allow updating 1 task single Complementary Attribute without specifying complementary attributes that we don't want to change. Similar to # 29115 but just for a task --- htdocs/projet/class/api_tasks.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 89907456672..2e4557a44a7 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -462,7 +462,12 @@ class Tasks extends DolibarrApi $this->task->context['caller'] = $request_data['caller']; continue; } - + if ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->task->array_options[$index] = $val; + } + continue; + } $this->task->$field = $value; } From 79bf5211ceab51abe9916b8d3400b468639e232e Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:00:48 +0200 Subject: [PATCH 02/19] Update note.php --- htdocs/contact/note.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 1f7a328e614..12db16e1fb5 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -78,7 +78,7 @@ if (empty($reshook)) { $now = dol_now(); -$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +$title = $langs->trans("Notes"); $form = new Form($db); From 51a767380edaef722bb41edb42a56725a1a235c1 Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:01:47 +0200 Subject: [PATCH 03/19] Update companies.lang --- htdocs/langs/en_US/companies.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index d1ca72b826a..c1d67156417 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -273,6 +273,7 @@ EditContact=Edit contact EditContactAddress=Edit contact/address Contact=Contact/Address Contacts=Contacts/Addresses +ContactsNote=Notes ContactId=Contact id ContactsAddresses=Contacts/Addresses FromContactName=Name: From 84a9878899d2583012825b34095e0e2b8c3270c3 Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:04:55 +0200 Subject: [PATCH 04/19] Update card.php --- htdocs/contact/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 16087378bf2..1e0e14dbbc4 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -574,7 +574,6 @@ if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', get $title = $object->lastname; } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")); llxHeader('', $title, $help_url); From 6480d936b031ef849006a50fa7012bfff23b1681 Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:10:26 +0200 Subject: [PATCH 05/19] Update companies.lang --- htdocs/langs/en_US/companies.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index c1d67156417..1dcb11f97da 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -273,7 +273,8 @@ EditContact=Edit contact EditContactAddress=Edit contact/address Contact=Contact/Address Contacts=Contacts/Addresses -ContactsNote=Notes +ContactsNote=Note +ContactPersonalData=Personal data ContactId=Contact id ContactsAddresses=Contacts/Addresses FromContactName=Name: From 472b3f5e3bbfe40a26f0a0d5aebf56b6e1c1ad55 Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:11:58 +0200 Subject: [PATCH 06/19] Update companies.lang --- htdocs/langs/en_US/companies.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 1dcb11f97da..91cad396d5d 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -275,6 +275,7 @@ Contact=Contact/Address Contacts=Contacts/Addresses ContactsNote=Note ContactPersonalData=Personal data +ContactRelatedItems=Related items ContactId=Contact id ContactsAddresses=Contacts/Addresses FromContactName=Name: From d51fd6343181ce6fc15790f1e036752b0373be72 Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:12:49 +0200 Subject: [PATCH 07/19] Update consumption.php --- htdocs/contact/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 66067b00e6e..142fbaae198 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -111,7 +111,7 @@ $formother = new FormOther($db); $productstatic = new Product($db); $objsoc = new Societe($db); -$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +$title = $langs->trans("ContactsRelatedItems"); $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); From f2a0949c10b2dd69cf0158a7587dfc3a5d0c8ceb Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:16:04 +0200 Subject: [PATCH 08/19] Update companies.lang --- htdocs/langs/en_US/companies.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 91cad396d5d..0fd0d2bd15c 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -276,6 +276,7 @@ Contacts=Contacts/Addresses ContactsNote=Note ContactPersonalData=Personal data ContactRelatedItems=Related items +ContactLinkedFiles=Linked files ContactId=Contact id ContactsAddresses=Contacts/Addresses FromContactName=Name: From b805c69143edb6f49a17b15b4ca0d8199c7f5efb Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:16:55 +0200 Subject: [PATCH 09/19] Update document.php --- htdocs/contact/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index c4b216d2679..efc55ac0e5b 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -110,7 +110,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +$title = $langs->trans("ContactLinkedFiles"); if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { $title = $object->lastname; } From 06cad7c281d756d2c7a96511b93fead19a98ce58 Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:19:02 +0200 Subject: [PATCH 10/19] Update agenda.php --- htdocs/contact/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 2c1a0d2ab99..5ef2652268c 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -144,7 +144,7 @@ if (empty($reshook)) { $form = new Form($db); -$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +$title = $langs->trans("ContactEvents"); if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { $title = $object->lastname; } From e2b1b13ca06348e251d37a136798316297222910 Mon Sep 17 00:00:00 2001 From: Rikard Bosnjakovic Date: Mon, 1 Apr 2024 13:20:11 +0200 Subject: [PATCH 11/19] Update companies.lang --- htdocs/langs/en_US/companies.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 0fd0d2bd15c..9ff82fd3d18 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -277,6 +277,7 @@ ContactsNote=Note ContactPersonalData=Personal data ContactRelatedItems=Related items ContactLinkedFiles=Linked files +ContactEvents=Events/Agenda ContactId=Contact id ContactsAddresses=Contacts/Addresses FromContactName=Name: From e3f1fc36828d9fb30666c1d5e413924325d8dfdf Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 31 Mar 2024 16:06:04 +0200 Subject: [PATCH 12/19] Cope with magic and real properties aliases in _filterObjectProperties --- htdocs/api/class/api.class.php | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 63d504b14cb..2187b988c47 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Laurent Destailleur * Copyright (C) 2020 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -107,16 +108,41 @@ class DolibarrApi */ protected function _filterObjectProperties($object, $properties) { + // phpcs:enable // If properties is empty, we return all properties if (empty($properties)) { return $object; } - // Else we filter properties + + // Copy of exploded array for efficiency + $arr_properties = explode(',', $properties); + $magic_properties = array(); + $real_properties = get_object_vars($object); + + // Unsetting real properties may unset magic properties. + // We keep a copy of the requested magic properties + foreach ($arr_properties as $key) { + if (!array_key_exists($key, $real_properties)) { + // Not a real property, + // check if $key is a magic property (we want to keep '$obj->$key') + if (property_exists($object, $key) && isset($object->$key)) { + $magic_properties[$key] = $object->$key; + } + } + } + + // Filter real properties (may indirectly unset magic properties) foreach (get_object_vars($object) as $key => $value) { - if (!in_array($key, explode(',', $properties))) { + if (!in_array($key, $arr_properties)) { unset($object->$key); } } + + // Restore the magic properties + foreach ($magic_properties as $key => $value) { + $object->$key = $value; + } + return $object; } From 31584659e0ae6fa53011ec1cc14aa273d48364b1 Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 31 Mar 2024 16:12:55 +0200 Subject: [PATCH 13/19] Refactor objCompare # Refactor objCompare: - Move to CommonClassTest; - Report class name for mismatched property; - Cope with dolDeprecated property aliases (test may exclude deprecated name, also exclude new name). --- test/phpunit/CommonClassTest.class.php | 63 ++++++++++++++++++++++++++ test/phpunit/FactureRecTest.php | 35 +------------- test/phpunit/FactureTest.php | 38 ++-------------- test/phpunit/InventoryTest.php | 35 +------------- test/phpunit/UserTest.php | 35 +------------- 5 files changed, 69 insertions(+), 137 deletions(-) diff --git a/test/phpunit/CommonClassTest.class.php b/test/phpunit/CommonClassTest.class.php index 0db9b170871..ee5db8c46d4 100644 --- a/test/phpunit/CommonClassTest.class.php +++ b/test/phpunit/CommonClassTest.class.php @@ -235,6 +235,69 @@ abstract class CommonClassTest extends TestCase } } + + /** + * Call method, even if protected. + * + * @param object $obj Object on which to call method + * @param string $name Method to call + * @param array $args Arguments to provide in method call + * @return mixed Return value + */ + public static function callMethod($obj, $name, array $args = []) + { + $class = new \ReflectionClass($obj); + $method = $class->getMethod($name); + // If PHP is older then 8.1.0 + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + return $method->invokeArgs($obj, $args); + } + + + /** + * Compare all public properties values of 2 objects + * + * @param Object $oA Object operand 1 + * @param Object $oB Object operand 2 + * @param boolean $ignoretype False will not report diff if type of value differs + * @param array $fieldstoignorearray Array of fields to ignore in diff + * @return array Array with differences + */ + public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) + { + $retAr = array(); + + if (get_class($oA) !== get_class($oB)) { + $retAr[] = "Supplied objects are not of same class."; + } else { + $oVarsA = get_object_vars($oA); + $oVarsB = get_object_vars($oB); + $aKeys = array_keys($oVarsA); + if (method_exists($oA, 'deprecatedProperties')) { + // Update exclusions + foreach (self::callMethod($oA, 'deprecatedProperties') as $deprecated => $new) { + if (in_array($deprecated, $fieldstoignorearray)) { + $fieldstoignorearray[] = $new; + } + } + } + foreach ($aKeys as $sKey) { + if (in_array($sKey, $fieldstoignorearray)) { + continue; + } + if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { + $retAr[] = get_class($oA).'::'.$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : json_encode($oVarsA[$sKey])).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : json_encode($oVarsB[$sKey])); + } + if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { + $retAr[] = get_class($oA).'::'.$sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : json_encode($oVarsA[$sKey])).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : json_encode($oVarsB[$sKey])); + } + } + } + return $retAr; + } + /** * Map deprecated module names to new module names */ diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index 2644c4fe084..801a6656131 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2024 MDW * * 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 @@ -117,38 +118,4 @@ class FactureRecTest extends CommonClassTest $localobject->note_private = 'New note'; //$localobject->note='New note after update'; } - - /** - * Compare all public properties values of 2 objects - * - * @param Object $oA Object operand 1 - * @param Object $oB Object operand 2 - * @param boolean $ignoretype False will not report diff if type of value differs - * @param array $fieldstoignorearray Array of fields to ignore in diff - * @return array Array with differences - */ - public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) - { - $retAr = array(); - - if (get_class($oA) !== get_class($oB)) { - $retAr[] = "Supplied objects are not of same class."; - } else { - $oVarsA = get_object_vars($oA); - $oVarsB = get_object_vars($oB); - $aKeys = array_keys($oVarsA); - foreach ($aKeys as $sKey) { - if (in_array($sKey, $fieldstoignorearray)) { - continue; - } - if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - } - } - return $retAr; - } } diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index e2f9fa5f68c..2fc0bb6d67d 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2018 Frédéric France * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2024 MDW * * 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 @@ -155,7 +156,7 @@ class FactureTest extends CommonClassTest $this->assertLessThan($result, 0); - // Test everything are still same than specimen + // Test everything is still the same as specimen $newlocalobject = new Facture($db); $newlocalobject->initAsSpecimen(); $this->changeProperties($newlocalobject); @@ -168,6 +169,7 @@ class FactureTest extends CommonClassTest $localobject, $newlocalobject, true, + // Not comparing: array( 'newref','oldref','id','lines','client','thirdparty','brouillon','user_creation_id','date_creation','date_validation','datem','date_modification', 'ref','statut','status','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement', @@ -281,38 +283,4 @@ class FactureTest extends CommonClassTest $localobject->note_private = 'New note'; //$localobject->note='New note after update'; } - - /** - * Compare all public properties values of 2 objects - * - * @param Object $oA Object operand 1 - * @param Object $oB Object operand 2 - * @param boolean $ignoretype False will not report diff if type of value differs - * @param array $fieldstoignorearray Array of fields to ignore in diff - * @return array Array with differences - */ - public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) - { - $retAr = array(); - - if (get_class($oA) !== get_class($oB)) { - $retAr[] = "Supplied objects are not of same class."; - } else { - $oVarsA = get_object_vars($oA); - $oVarsB = get_object_vars($oB); - $aKeys = array_keys($oVarsA); - foreach ($aKeys as $sKey) { - if (in_array($sKey, $fieldstoignorearray)) { - continue; - } - if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - } - } - return $retAr; - } } diff --git a/test/phpunit/InventoryTest.php b/test/phpunit/InventoryTest.php index 2d9808e12ce..7761608d1a6 100644 --- a/test/phpunit/InventoryTest.php +++ b/test/phpunit/InventoryTest.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010 Laurent Destailleur * Copyright (C) 2018 Frédéric France * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2024 MDW * * 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 @@ -267,38 +268,4 @@ class InventoryTest extends CommonClassTest return $result; } - - /** - * Compare all public properties values of 2 objects - * - * @param Object $oA Object operand 1 - * @param Object $oB Object operand 2 - * @param boolean $ignoretype False will not report diff if type of value differs - * @param array $fieldstoignorearray Array of fields to ignore in diff - * @return array Array with differences - */ - public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) - { - $retAr = array(); - - if (get_class($oA) !== get_class($oB)) { - $retAr[] = "Supplied objects are not of same class."; - } else { - $oVarsA = get_object_vars($oA); - $oVarsB = get_object_vars($oB); - $aKeys = array_keys($oVarsA); - foreach ($aKeys as $sKey) { - if (in_array($sKey, $fieldstoignorearray)) { - continue; - } - if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - } - } - return $retAr; - } } diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 877d258d60b..d5328982f3a 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -1,6 +1,7 @@ * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2024 MDW * * 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 @@ -403,38 +404,4 @@ class UserTest extends CommonClassTest { $localobject->note_private = 'New note after update'; } - - /** - * Compare all public properties values of 2 objects - * - * @param Object $oA Object operand 1 - * @param Object $oB Object operand 2 - * @param boolean $ignoretype False will not report diff if type of value differs - * @param array $fieldstoignorearray Array of fields to ignore in diff - * @return array Array with differences - */ - public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) - { - $retAr = array(); - - if (get_class($oA) !== get_class($oB)) { - $retAr[] = "Supplied objects are not of same class."; - } else { - $oVarsA = get_object_vars($oA); - $oVarsB = get_object_vars($oB); - $aKeys = array_keys($oVarsA); - foreach ($aKeys as $sKey) { - if (in_array($sKey, $fieldstoignorearray)) { - continue; - } - if (! $ignoretype && ($oVarsA[$sKey] !== $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - if ($ignoretype && ($oVarsA[$sKey] != $oVarsB[$sKey])) { - $retAr[] = $sKey.' : '.(is_object($oVarsA[$sKey]) ? get_class($oVarsA[$sKey]) : $oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey]) ? get_class($oVarsB[$sKey]) : $oVarsB[$sKey]); - } - } - } - return $retAr; - } } From 146b73526933fb3ec0f6d47cbe7b38fdb628b5fd Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 31 Mar 2024 16:22:53 +0200 Subject: [PATCH 14/19] New: dol_get_object_properties to get real and magic props # New: dol_get_object_properties to get real and magic props This method will get an array with real and magic properties from an object (if $properties is provided). --- htdocs/core/lib/functions.lib.php | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3d38aef2dfd..1c5a6bde9b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1367,6 +1367,41 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) return $res; } +/** + * Get properties for an object - including magic properties when requested + * + * Only returns properties that exist + * + * @param object $obj Object to get properties from + * @param string[] $properties Optional list of properties to get. + * When empty, only gets public properties. + * @return array Hash for retrieved values (key=name) + */ +function dol_get_object_properties($obj, $properties = []) +{ + // Get real properties using get_object_vars() if $properties is empty + if (empty($properties)) { + return get_object_vars($obj); + } + + $existingProperties = []; + $realProperties = get_object_vars($obj); + + // Get the real or magic property values + foreach ($properties as $property) { + if (array_key_exists($property, $realProperties)) { + // Real property, add the value + $existingProperties[$property] = $obj->{$property}; + } elseif (property_exists($obj, $property)) { + // Magic property + $existingProperties[$property] = $obj->{$property}; + } + } + + return $existingProperties; +} + + /** * Create a clone of instance of object (new instance with same value for each properties) * With native = 0: Property that are reference are different memory area in the new object (full isolation clone). This means $this->db of new object may not be valid. From bef4242b31869be101f06d18e0e6766ad66f5038 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Apr 2024 13:49:00 +0200 Subject: [PATCH 15/19] Update consumption.php --- htdocs/contact/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 142fbaae198..158229e620a 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -111,7 +111,7 @@ $formother = new FormOther($db); $productstatic = new Product($db); $objsoc = new Societe($db); -$title = $langs->trans("ContactsRelatedItems"); +$title = $langs->trans("ContactRelatedItems"); $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); From 6b54d7f8335ff643b02c8bca3d52332b2de6a624 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Apr 2024 13:49:35 +0200 Subject: [PATCH 16/19] Fix #29098 --- htdocs/contact/perso.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index c5ab1faf862..0661a80b685 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -120,7 +120,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('societe', 'con $now = dol_now(); -$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); +$title = $langs->trans("ContactPersonalData"); if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) { $title = $object->lastname; } From 5b60aada261bf5f10a3b8b8a450b128b5cab4418 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Apr 2024 13:50:28 +0200 Subject: [PATCH 17/19] Update companies.lang --- htdocs/langs/en_US/companies.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 9ff82fd3d18..6483bf4c28e 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -273,7 +273,7 @@ EditContact=Edit contact EditContactAddress=Edit contact/address Contact=Contact/Address Contacts=Contacts/Addresses -ContactsNote=Note +ContactNotes=Notes ContactPersonalData=Personal data ContactRelatedItems=Related items ContactLinkedFiles=Linked files From d75e30ff04da7870b9d0af789c39a4ddfd824b44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Apr 2024 13:50:46 +0200 Subject: [PATCH 18/19] Update note.php --- htdocs/contact/note.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 12db16e1fb5..1f956e94821 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -78,7 +78,7 @@ if (empty($reshook)) { $now = dol_now(); -$title = $langs->trans("Notes"); +$title = $langs->trans("ContactNotes"); $form = new Form($db); From 4b1dba0764b70aecded36a4f4d01339b150c1520 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Apr 2024 14:06:03 +0200 Subject: [PATCH 19/19] Fix replyto and from is not the same. --- htdocs/admin/notification.php | 30 ++++++++++++++++++------------ htdocs/core/class/notify.class.php | 10 +++++----- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 43e29dfb535..b4b5ee09fc6 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -196,28 +196,18 @@ print ''.$langs->trans("Parameter").''; print ''.$langs->trans("Value").''; print "\n"; + print ''; print $langs->trans("NotificationEMailFrom").''; print ''; print img_picto('', 'email', 'class="pictofixedwidth"'); print ''; -if (getDolGlobalString('NOTIFICATION_EMAIL_FROM') && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) { +if (getDolGlobalString('NOTIFICATION_EMAIL_FROM') && !isValidEmail(getDolGlobalString('NOTIFICATION_EMAIL_FROM'))) { print ' '.img_warning($langs->trans("ErrorBadEMail")); } print ''; print ''; -print ''; -print $langs->trans("NotificationDisableConfirmMessageContact").''; -print ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval, getDolGlobalString('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT')); -} -print ''; -print ''; print ''; print $langs->trans("NotificationDisableConfirmMessageUser").''; @@ -231,6 +221,20 @@ if ($conf->use_javascript_ajax) { print ''; print ''; + +print ''; +print $langs->trans("NotificationDisableConfirmMessageContact").''; +print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval, getDolGlobalString('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT')); +} +print ''; +print ''; + + print ''; print $langs->trans("NotificationDisableConfirmMessageFix").''; print ''; @@ -242,6 +246,8 @@ if ($conf->use_javascript_ajax) { } print ''; print ''; + + print ''; print ''; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index e498e287323..c4b0a371726 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -646,7 +646,7 @@ class Notify if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { $application = getDolGlobalString('MAIN_APPLICATION_TITLE'); } - $replyto = $conf->notification->email_from; + $from = getDolGlobalString('NOTIFICATION_EMAIL_FROM'); $object_type = ''; $link = ''; $num = 0; @@ -945,7 +945,7 @@ class Notify $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string } - $parameters = array('notifcode' => $notifcode, 'sendto' => $sendto, 'replyto' => $replyto, 'file' => $filename_list, 'mimefile' => $mimetype_list, 'filename' => $mimefilename_list, 'outputlangs' => $outputlangs, 'labeltouse' => $labeltouse); + $parameters = array('notifcode' => $notifcode, 'sendto' => $sendto, 'from' => $from, 'file' => $filename_list, 'mimefile' => $mimetype_list, 'filename' => $mimefilename_list, 'outputlangs' => $outputlangs, 'labeltouse' => $labeltouse); if (!isset($action)) { $action = ''; } @@ -968,7 +968,7 @@ class Notify $mailfile = new CMailFile( $subject, $sendto, - $replyto, + $from, $message, $filename_list, $mimetype_list, @@ -1211,7 +1211,7 @@ class Notify } if ($sendto) { - $parameters = array('notifcode' => $notifcode, 'sendto' => $sendto, 'replyto' => $replyto, 'file' => $filename_list, 'mimefile' => $mimetype_list, 'filename' => $mimefilename_list, 'subject' => &$subject, 'message' => &$message); + $parameters = array('notifcode' => $notifcode, 'sendto' => $sendto, 'from' => $from, 'file' => $filename_list, 'mimefile' => $mimetype_list, 'filename' => $mimefilename_list, 'subject' => &$subject, 'message' => &$message); $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { if (!empty($hookmanager->resArray['files'])) { @@ -1229,7 +1229,7 @@ class Notify $mailfile = new CMailFile( $subject, $sendto, - $replyto, + $from, $message, $filename_list, $mimetype_list,