From e8344f9974c50ee86e974ce3d26a4e4f4bd45137 Mon Sep 17 00:00:00 2001 From: Herafia Date: Tue, 21 Apr 2026 10:59:45 +0200 Subject: [PATCH 1/3] gestion right --- hook.php | 13 +++++++++++-- inc/profile.class.php | 15 +++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hook.php b/hook.php index c3c5a8a0..0a2a129f 100644 --- a/hook.php +++ b/hook.php @@ -114,9 +114,15 @@ 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['glpiactiveprofile'] = array_merge( + $_SESSION['glpiactiveprofile'], + ProfileRight::getProfileRights($_SESSION["glpiactiveprofile"]["id"]) + ); break; case 1: @@ -199,6 +205,9 @@ function plugin_datainjection_uninstall() } } + // Remove plugin rights from all profiles + $DB->doQuery("DELETE FROM `glpi_profilerights` WHERE `name` IN ('plugin_datainjection_model', 'plugin_datainjection_use')"); + 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() From 7cdd680401ed94076ed59cb50cb844b727241527 Mon Sep 17 00:00:00 2001 From: Herafia Date: Tue, 21 Apr 2026 11:03:03 +0200 Subject: [PATCH 2/3] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 9a28bbbc29ca23238c71f7c9281c938fceb25b92 Mon Sep 17 00:00:00 2001 From: Herafia Date: Tue, 21 Apr 2026 12:16:04 +0200 Subject: [PATCH 3/3] correctif --- hook.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hook.php b/hook.php index 0a2a129f..f14db0df 100644 --- a/hook.php +++ b/hook.php @@ -119,10 +119,7 @@ function plugin_datainjection_install() PluginDatainjectionProfile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]); // Force reload of session profile rights - $_SESSION['glpiactiveprofile'] = array_merge( - $_SESSION['glpiactiveprofile'], - ProfileRight::getProfileRights($_SESSION["glpiactiveprofile"]["id"]) - ); + Session::reloadCurrentProfile(); break; case 1: @@ -206,7 +203,10 @@ function plugin_datainjection_uninstall() } // Remove plugin rights from all profiles - $DB->doQuery("DELETE FROM `glpi_profilerights` WHERE `name` IN ('plugin_datainjection_model', 'plugin_datainjection_use')"); + $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);