Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Pages rendered with Twig templates instead of PHP `echo`
- Make the plugin compatible with the Content Security Policy

### Fixed

- Alerts of a child entity are displayed on the central page, the helpdesk, the service catalog and above the ticket list

## [1.15.1] - 2026-11-05

### Added
Expand Down
6 changes: 3 additions & 3 deletions inc/alert.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public static function findAllToNotify($params = [])
$p['show_hidden_alerts'] = false;
$p['show_only_helpdesk_alerts'] = false;
$p['show_only_service_catalog_alerts'] = false;
$p['entities_id'] = false;
$p['entities_id'] = '';
foreach ($params as $key => $value) {
$p[$key] = $value;
}
Expand Down Expand Up @@ -543,7 +543,7 @@ public static function displayAlerts($params = [], ?string $wrapper = null)
$p['show_hidden_alerts'] = false;
$p['show_only_helpdesk_alerts'] = false;
$p['show_only_service_catalog_alerts'] = false;
$p['entities_id'] = false;
$p['entities_id'] = '';
foreach ($params as $key => $value) {
$p[$key] = $value;
}
Expand Down Expand Up @@ -744,7 +744,7 @@ public static function preItemForm($params = [])
) {
$item = $params['item'];
$itemtype = get_class($item);
$entities_id = $params['item']->fields['entities_id'] ?? false; // false to use current entity
$entities_id = $params['item']->fields['entities_id'] ?? ''; // '' to use current entities
self::displayAlerts(['show_only_helpdesk_alerts' => true,
'show_hidden_alerts' => false,
'entities_id' => $entities_id,
Expand Down
25 changes: 25 additions & 0 deletions tests/units/PluginNewsAlertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,31 @@ public function testAlertPreviewDisplaysWhetherYouCanEditOrNot(): void
$this->assertStringNotContainsString('disabled', $matches[0]);
}

public function testFindAllToNotifyUsesActiveChildEntityByDefault(): void
{
$this->login('glpi');

$alert = $this->createItem(PluginNewsAlert::class, [
'name' => 'Child entity alert',
'message' => 'Alert in a child entity',
'type' => 1,
'size' => 'medium',
'icon' => 'settings',
'is_displayed_onlogin' => 0,
'is_displayed_oncentral' => 1,
'is_displayed_onhelpdesk' => 1,
'is_displayed_onservicecatalog' => 1,
'is_active' => 1,
'is_recursive' => 0,
'entities_id' => getItemByTypeName('Entity', '_test_child_1', true),
]);

$this->setEntity('_test_child_1', false);

$alerts_ids = array_column(PluginNewsAlert::findAllToNotify(['show_only_central_alerts' => true]) ?: [], 'id');
$this->assertContains($alert->getID(), $alerts_ids);
}

public function testUpgradeTurnsColoredCustomAlertsIntoImportantOnes(): void
{
/** @var \DBmysql $DB */
Expand Down