From d7270c56cd2a2d53997da68f3ef74c1795ea0774 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 12 Mar 2024 11:21:37 +0100 Subject: [PATCH 1/5] =?UTF-8?q?N=C2=B07315=20-=20Migrate=20usages=20in=20T?= =?UTF-8?q?wigBase::Controller=20to=20use=20new=20API=20if=20possible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TwigBase/Controller/Controller.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sources/Application/TwigBase/Controller/Controller.php b/sources/Application/TwigBase/Controller/Controller.php index 465eb3c04b..6c10ec86bb 100644 --- a/sources/Application/TwigBase/Controller/Controller.php +++ b/sources/Application/TwigBase/Controller/Controller.php @@ -583,6 +583,7 @@ abstract class Controller extends AbstractController * @api * * @param string $sScript Script path to link + * @since 3.2.0 $sScript must be absolute URI */ public function AddLinkedScript($sScript) { @@ -595,6 +596,7 @@ abstract class Controller extends AbstractController * @api * * @param string $sStylesheet Stylesheet path to link + * @since 3.2.0 $sScript must be absolute URI */ public function AddLinkedStylesheet($sStylesheet) { @@ -769,12 +771,23 @@ abstract class Controller extends AbstractController private function AddLinkedScriptToPage($sLinkedScript) { - $this->m_oPage->add_linked_script($sLinkedScript); + // iTop 3.1 and older compatibility, if not an URI we don't know if its relative to app root or module root + if (strpos($sLinkedScript, "://") === false) { + $this->m_oPage->add_linked_script($sLinkedScript); + return; + } + + $this->m_oPage->LinkScriptFromURI($sLinkedScript); } private function AddLinkedStylesheetToPage($sLinkedStylesheet) { - $this->m_oPage->add_linked_stylesheet($sLinkedStylesheet); + // iTop 3.1 and older compatibility, if not an URI we don't know if its relative to app root or module root + if (strpos($sLinkedStylesheet, "://") === false) { + $this->m_oPage->add_linked_stylesheet($sLinkedStylesheet); + } + + $this->m_oPage->LinkStylesheetFromURI($sLinkedStylesheet); } private function AddStyleToPage($sStyle) From b1e1a6649627f7835d448a205155f0dfda96c7d1 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 12 Mar 2024 11:34:31 +0100 Subject: [PATCH 2/5] =?UTF-8?q?N=C2=B07157=20-=20Remove=20dict=20entries?= =?UTF-8?q?=20for=20advanced=20mode=20in=20notifications=20center?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../en.dictionary.itop.notifications-center.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/dictionaries/ui/pages/notifications-center/en.dictionary.itop.notifications-center.php b/dictionaries/ui/pages/notifications-center/en.dictionary.itop.notifications-center.php index 07e0068372..a6310f10d8 100644 --- a/dictionaries/ui/pages/notifications-center/en.dictionary.itop.notifications-center.php +++ b/dictionaries/ui/pages/notifications-center/en.dictionary.itop.notifications-center.php @@ -20,8 +20,6 @@ Dict::Add('EN US', 'English', 'English', array( 'UI:NotificationsCenter:Page:Title' => 'Notifications center', 'UI:NotificationsCenter:Panel:Title' => 'Notifications center', - 'UI:NotificationsCenter:Panel:SubTitle' => 'Manage your notifications subscriptions. For more granularity, you can also manage individual subscriptions using the advanced mode.', - 'UI:NotificationsCenter:Panel:Advanced:SubTitle' => 'Manage your notifications subscriptions individually. To manage your subscriptions by type, use the standard mode.', 'UI:NotificationsCenter:Panel:Table:Channels' => 'Channels.', 'UI:NotificationsCenter:Unsubscribe:Success' => 'You have been successfully unsubscribed from the selected notifications.', 'UI:NotificationsCenter:Unsubscribe:Error' => 'An error occurred while unsubscribing from the selected notifications.', From 71d9536bc462bdae7b31bad0216baf4547fac0c2 Mon Sep 17 00:00:00 2001 From: vdumas Date: Wed, 21 Feb 2024 08:46:25 +0100 Subject: [PATCH 3/5] =?UTF-8?q?N=C2=B07268=20Method=20SetComputedDate=20fa?= =?UTF-8?q?ils=20on=20Date=20only=20attribute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit b6caa515522703dea91a058e01f18be13edd8340) (cherry picked from commit c8810708efd35f0b331f446f6212cf166ed8322c) --- core/dbobject.class.php | 2 +- .../unitary-tests/core/DBObjectTest.php | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 19a64c5ba3..ea70321cfa 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -4229,7 +4229,7 @@ abstract class DBObject implements iDisplay } } $oDate->modify($sModifier); - $this->Set($sAttCode, $oDate->format('Y-m-d H:i:s')); + $this->Set($sAttCode, $oDate->getTimestamp()); } /** diff --git a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php index 6cf5b26041..5f1fe127ec 100644 --- a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php +++ b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php @@ -539,4 +539,31 @@ class DBObjectTest extends ItopDataTestCase return $oUserWithAllowedOrgs; } + + + /** + * @covers DBObject::SetComputedDate + * @return void + */ + public function testSetComputedDateOnAttributeDate() + { + $oObject = MetaModel::NewObject(\CustomerContract::class, ['name' => 'Test contract', 'org_id' => '3', 'provider_id' => '2']); + $oObject->Set('start_date', time()); + $oObject->SetComputedDate('end_date', "+2 weeks", 'start_date'); + $this->assertTrue(true, 'No fatal error on computing date'); + } + + /** + * @covers DBObject::SetComputedDate + * @return void + */ + public function testSetComputedDateOnAttributeDateTime() + { + $oObject = MetaModel::NewObject(\WorkOrder::class, ['name' => 'Test workorder', 'description' => 'Toto']); + $oObject->Set('start_date', '2024-01-01 09:45:00'); + $oObject->SetComputedDate('end_date', "+2 weeks", 'start_date'); + $this->assertTrue(true, 'No fatal error on computing date'); + $this->assertEquals("2024-01-15 09:45:00", $oObject->Get('end_date'), 'SetComputedDate +2 weeks on a WorkOrder DateTimeAttribute'); + + } } From 2af05a437ef2aaf905c6ce492a66da84c3b25857 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 12 Mar 2024 17:32:56 +0100 Subject: [PATCH 4/5] =?UTF-8?q?N=C2=B04314=20-=20Fix=20Uniqueness=20rules?= =?UTF-8?q?=20not=20working=20with=20Silo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit e8c11f38d2fca454a3b46fe759499affadd034fc) --- core/dbobject.class.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 34aa86437d..ea2233d77c 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2085,16 +2085,18 @@ abstract class DBObject implements iDisplay } /** - * @internal - * - * @param string $sUniquenessRuleId uniqueness rule ID - * @param array $aUniquenessRuleProperties uniqueness rule properties + * @api + * @param array $aUniquenessRuleProperties uniqueness rule properties * + * @param string $sUniquenessRuleId uniqueness rule ID * @return \DBSearch - * @throws \CoreException * @throws \OQLException + * @throws \CoreException + * * @since 2.6.0 N°659 uniqueness constraint - * @api + * @since 2.7.11 3.1.2 3.2.0 N°4314 Fix Uniqueness rules not working with Silo + * + * @internal */ protected function GetSearchForUniquenessRule($sUniquenessRuleId, $aUniquenessRuleProperties) { @@ -2124,8 +2126,10 @@ abstract class DBObject implements iDisplay $oUniquenessQuery->AddConditionForInOperatorUsingParam('finalclass', $aChildClassesWithRuleDisabled, false); } - return $oUniquenessQuery; - } + $oUniquenessQuery->AllowAllData(); + + return $oUniquenessQuery; + } /** * Check integrity rules (before inserting or updating the object) From 2922b22478a8b64023fa222b98a12b6580d86d66 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 12 Mar 2024 17:34:28 +0100 Subject: [PATCH 5/5] \DBObject::GetSearchForUniquenessRule remove wrong `@api` --- core/dbobject.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index ea2233d77c..11cc6e1488 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2085,18 +2085,17 @@ abstract class DBObject implements iDisplay } /** - * @api * @param array $aUniquenessRuleProperties uniqueness rule properties * * @param string $sUniquenessRuleId uniqueness rule ID * @return \DBSearch * @throws \OQLException * @throws \CoreException - * - * @since 2.6.0 N°659 uniqueness constraint - * @since 2.7.11 3.1.2 3.2.0 N°4314 Fix Uniqueness rules not working with Silo * * @internal + * + * @since 2.6.0 N°659 uniqueness constraint + * @since 2.7.11 3.1.2 3.2.0 N°4314 Fix Uniqueness rules not working with Silo */ protected function GetSearchForUniquenessRule($sUniquenessRuleId, $aUniquenessRuleProperties) {