Skip to content

Commit da15995

Browse files
authored
fix gestion right install uninstall (#609)
* gestion right * CHANGELOG * correctif
1 parent 4f7d9ee commit da15995

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Fix crash when injection model has no mandatory fields defined
1313
- Fix models created on parent entities can't be used on child entites
1414
- Fix responsible group injection payload normalization so group remains visible in GLPI after import
15+
- Fix plugin rights initialization and cleanup
1516

1617
## [2.15.4] - 2026-03-16
1718

hook.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ function plugin_datainjection_install()
114114

115115
if (!is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) {
116116
@ mkdir(PLUGIN_DATAINJECTION_UPLOAD_DIR);
117-
118-
PluginDatainjectionProfile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]);
119117
}
118+
119+
PluginDatainjectionProfile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]);
120+
121+
// Force reload of session profile rights
122+
Session::reloadCurrentProfile();
120123
break;
121124

122125
case 1:
@@ -199,6 +202,12 @@ function plugin_datainjection_uninstall()
199202
}
200203
}
201204

205+
// Remove plugin rights from all profiles
206+
$profileRight = new ProfileRight();
207+
foreach (PluginDatainjectionProfile::getAllRights() as $right) {
208+
$profileRight->deleteByCriteria(['name' => $right['field']]);
209+
}
210+
202211
if (is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) {
203212
Toolbox::deleteDir(PLUGIN_DATAINJECTION_UPLOAD_DIR);
204213
}

inc/profile.class.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,13 @@ public static function createFirstAccess($profiles_id)
126126
{
127127

128128
include_once Plugin::getPhpDir('datainjection') . "/inc/profile.class.php";
129-
foreach (self::getAllRights() as $right) {
130-
self::addDefaultProfileInfos(
131-
$profiles_id,
132-
['plugin_datainjection_model' => ALLSTANDARDRIGHT,
133-
'plugin_datainjection_use' => READ,
134-
],
135-
);
136-
}
129+
self::addDefaultProfileInfos(
130+
$profiles_id,
131+
[
132+
'plugin_datainjection_model' => ALLSTANDARDRIGHT,
133+
'plugin_datainjection_use' => READ,
134+
],
135+
);
137136
}
138137

139138
public static function migrateProfiles()

0 commit comments

Comments
 (0)