-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Plugin version: 3.2.6
GLPI version: 11.x
Priority: Low
File: src/HolidayCount.php
Summary
The holiday balance table (glpi_plugin_activity_holidaycounts) does not have an entities_id column. In a GLPI multi-entity environment, all users share the same balance pool regardless of entity, which can lead to:
- User A in entity "Paris" seeing or consuming balance intended for entity "Lyon".
- HR managers of one entity being able to see balances from all other entities.
- Incorrect balance calculations when a user belongs to multiple entities.
Proposed fix
Step 1 — Add migration to add entities_id
Create install/sql/update-3.3.0.sql:
ALTER TABLE `glpi_plugin_activity_holidaycounts`
ADD `entities_id` int(11) NOT NULL DEFAULT '0' AFTER `users_id`,
ADD `is_recursive` tinyint(1) NOT NULL DEFAULT '0' AFTER `entities_id`,
ADD INDEX `entities_id` (`entities_id`);
-- Populate existing rows with the user's default entity
UPDATE `glpi_plugin_activity_holidaycounts` hc
INNER JOIN `glpi_users` u ON u.id = hc.users_id
SET hc.entities_id = u.entities_id;Step 2 — Update HolidayCount class
// src/HolidayCount.php
class HolidayCount extends CommonDBTM
{
// Enable entity management
public $maybeRecursive = true;
// GLPI will now automatically filter by active entity
public static function getCondition(): array
{
return getEntitiesRestrictCriteria('glpi_plugin_activity_holidaycounts', '', '', true);
}
}Step 3 — Pass entity when creating balance records
// Wherever HolidayCount::add() is called
$holidayCount->add([
'users_id' => $usersId,
'entities_id' => Session::getActiveEntity(),
// ... other fields
]);Notes
- The migration sets
entities_idfrom the user's default entity for backward compatibility. - This is a non-breaking change for single-entity installations.
- Administrators managing multiple entities will need to review existing balances after migration.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels