From 682d988d083e818183a84fef067f81f7d8d2cf57 Mon Sep 17 00:00:00 2001 From: Romain B <8530352+Rom1-B@users.noreply.github.com> Date: Wed, 19 Jun 2024 08:09:55 +0200 Subject: [PATCH] Remove `noAUTO=1` from notification links --- src/NotificationTarget.php | 9 ++++----- tests/functional/NotificationEventAjax.php | 16 ++++++++-------- tests/functional/NotificationTarget.php | 6 +++--- .../NotificationTargetSavedSearch_Alert.php | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/NotificationTarget.php b/src/NotificationTarget.php index 8b08e187069..685eb5d49d1 100644 --- a/src/NotificationTarget.php +++ b/src/NotificationTarget.php @@ -701,14 +701,13 @@ public function formatURL($usertype, $redirect) switch ($usertype) { case self::EXTERNAL_USER: + case self::GLPI_USER: return $CFG_GLPI["url_base"] . "/index.php?redirect=$redirect"; - case self::ANONYMOUS_USER: - // No URL + // case self::ANONYMOUS_USER: + default: + // No URL return ''; - - case self::GLPI_USER: - return $CFG_GLPI["url_base"] . "/index.php?redirect=$redirect&noAUTO=1"; } } diff --git a/tests/functional/NotificationEventAjax.php b/tests/functional/NotificationEventAjax.php index dd2ba93d3c9..ee830719f0c 100644 --- a/tests/functional/NotificationEventAjax.php +++ b/tests/functional/NotificationEventAjax.php @@ -87,7 +87,7 @@ public function testRaise() { global $CFG_GLPI, $DB; - //enable notifications + //enable notifications $CFG_GLPI['use_notifications'] = 1; $CFG_GLPI['notifications_ajax'] = 1; @@ -104,13 +104,13 @@ public function testRaise() ]) )->isGreaterThan(0); - //event has been raised; it is in the queue! + //event has been raised; it is in the queue! $queue = getAllDataFromTable('glpi_queuednotifications'); - //no ajax notification configured per default + //no ajax notification configured per default $this->array($queue)->hasSize(0); - //add an ajax notification on tickets creation + //add an ajax notification on tickets creation $iterator = $DB->request([ 'FROM' => \Notification::getTable(), 'WHERE' => [ @@ -145,10 +145,10 @@ public function testRaise() ]) )->isGreaterThan(0); - //event has been raised; it is in the queue! + //event has been raised; it is in the queue! $queue = getAllDataFromTable('glpi_queuednotifications'); - //no ajax notification configured per default + //no ajax notification configured per default $this->array($queue)->hasSize(1); $GLPI_URI = GLPI_URI; @@ -182,7 +182,7 @@ public function testRaise() 'body_html' => null, 'body_text' => <<getID()}&noAUTO=1 + URL : {$GLPI_URI}/index.php?redirect=ticket_{$ticket->getID()} Ticket: Description @@ -222,7 +222,7 @@ public function testRaise() ]; $this->array($data)->isIdenticalTo($expected); - //reset + //reset $CFG_GLPI['use_notifications'] = 0; $CFG_GLPI['notifications_ajax'] = 0; } diff --git a/tests/functional/NotificationTarget.php b/tests/functional/NotificationTarget.php index 9c84979aac1..8cd8f49153f 100644 --- a/tests/functional/NotificationTarget.php +++ b/tests/functional/NotificationTarget.php @@ -398,16 +398,16 @@ protected function testFormatUrlProvider(): iterable 'expected' => '', ]; - // GLPI user, `noAUTO=1` parameter added + // GLPI user, no `noAUTO=1` parameter yield [ 'usertype' => \NotificationTarget::GLPI_USER, 'redirect' => 'Ticket_24', - 'expected' => $CFG_GLPI['url_base'] . '/index.php?redirect=Ticket_24&noAUTO=1', + 'expected' => $CFG_GLPI['url_base'] . '/index.php?redirect=Ticket_24', ]; yield [ 'usertype' => \NotificationTarget::GLPI_USER, 'redirect' => '/front/test.php?param=test&value=foo bar', - 'expected' => $CFG_GLPI['url_base'] . '/index.php?redirect=%2Ffront%2Ftest.php%3Fparam%3Dtest%26value%3Dfoo%20bar&noAUTO=1', + 'expected' => $CFG_GLPI['url_base'] . '/index.php?redirect=%2Ffront%2Ftest.php%3Fparam%3Dtest%26value%3Dfoo%20bar', ]; // External user, no `noAUTO` parameter diff --git a/tests/functional/NotificationTargetSavedSearch_Alert.php b/tests/functional/NotificationTargetSavedSearch_Alert.php index 6f43941e2da..decbbb8b36c 100644 --- a/tests/functional/NotificationTargetSavedSearch_Alert.php +++ b/tests/functional/NotificationTargetSavedSearch_Alert.php @@ -90,6 +90,6 @@ public function testAddDataForTemplate() global $CFG_GLPI; $expected_redirect = '%2Ffront%2Fsavedsearch.php%3Faction%3Dload%26id%3D' . $saved_searches_id; $this->string($target->data['##savedsearch.url##']) - ->isEqualTo($CFG_GLPI['url_base'] . '/index.php?redirect=' . $expected_redirect . '&noAUTO=1'); + ->isEqualTo($CFG_GLPI['url_base'] . '/index.php?redirect=' . $expected_redirect); } }