diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8567c7..839fca2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix crash when injection model has no mandatory fields defined - Fix models created on parent entities can't be used on child entites - Fix responsible group injection payload normalization so group remains visible in GLPI after import +- Fix plugin rights initialization and cleanup ## [2.15.4] - 2026-03-16 diff --git a/hook.php b/hook.php index c3c5a8a0..f14db0df 100644 --- a/hook.php +++ b/hook.php @@ -114,9 +114,12 @@ function plugin_datainjection_install() if (!is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) { @ mkdir(PLUGIN_DATAINJECTION_UPLOAD_DIR); - - PluginDatainjectionProfile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]); } + + PluginDatainjectionProfile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]); + + // Force reload of session profile rights + Session::reloadCurrentProfile(); break; case 1: @@ -199,6 +202,12 @@ function plugin_datainjection_uninstall() } } + // Remove plugin rights from all profiles + $profileRight = new ProfileRight(); + foreach (PluginDatainjectionProfile::getAllRights() as $right) { + $profileRight->deleteByCriteria(['name' => $right['field']]); + } + if (is_dir(PLUGIN_DATAINJECTION_UPLOAD_DIR)) { Toolbox::deleteDir(PLUGIN_DATAINJECTION_UPLOAD_DIR); } diff --git a/inc/profile.class.php b/inc/profile.class.php index ff391055..8ad92d4b 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -126,14 +126,13 @@ public static function createFirstAccess($profiles_id) { include_once Plugin::getPhpDir('datainjection') . "/inc/profile.class.php"; - foreach (self::getAllRights() as $right) { - self::addDefaultProfileInfos( - $profiles_id, - ['plugin_datainjection_model' => ALLSTANDARDRIGHT, - 'plugin_datainjection_use' => READ, - ], - ); - } + self::addDefaultProfileInfos( + $profiles_id, + [ + 'plugin_datainjection_model' => ALLSTANDARDRIGHT, + 'plugin_datainjection_use' => READ, + ], + ); } public static function migrateProfiles()