Skip to content

Commit

Permalink
Remove noAUTO=1 from notification links
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B authored Jun 19, 2024
1 parent 37179dc commit 682d988
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
9 changes: 4 additions & 5 deletions src/NotificationTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand Down
16 changes: 8 additions & 8 deletions tests/functional/NotificationEventAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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' => [
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testRaise()
'body_html' => null,
'body_text' => <<<TEXT
URL : {$GLPI_URI}/index.php?redirect=ticket_{$ticket->getID()}&#38;noAUTO=1
URL : {$GLPI_URI}/index.php?redirect=ticket_{$ticket->getID()}
Ticket: Description
Expand Down Expand Up @@ -222,7 +222,7 @@ public function testRaise()
];
$this->array($data)->isIdenticalTo($expected);

//reset
//reset
$CFG_GLPI['use_notifications'] = 0;
$CFG_GLPI['notifications_ajax'] = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/NotificationTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/NotificationTargetSavedSearch_Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 682d988

Please sign in to comment.