From bb7327a012697d5db64914d35cd3921b87a4c64c Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 26 Feb 2025 15:05:25 +0100 Subject: [PATCH 1/6] Fix Bypass filtering on the groups assignment option --- inc/ticket.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 4156c9eb..9aa61849 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -110,7 +110,9 @@ function ($carry, $type) use ($item) { } } - self::removeAssignUsers($item); + if (count($new_groups) > 0) { + self::removeAssignUsers($item); + } return $item; } } @@ -1114,10 +1116,13 @@ public function showForm($ID, $options = []) $PluginEscaladeGroup_Group = new PluginEscaladeGroup_Group(); $groups_id_filtered = array_keys($PluginEscaladeGroup_Group->getGroups($tickets_id)); $groups_id_filtered = empty($groups_id_filtered) ? [-1] : $groups_id_filtered; + + $user_config = new PluginEscaladeUser(); + $user_config->getFromDBByCrit(['users_id' => Session::getLoginUserID()]); $condition = [ 'is_assign' => 1 ]; - if ($config->fields['use_filter_assign_group']) { + if ($config->fields['use_filter_assign_group'] && !$user_config->fields['use_filter_assign_group']) { $condition['id'] = $groups_id_filtered; } TemplateRenderer::getInstance()->display('@escalade/escalade_form.html.twig', [ From 32a42f35e1c54bb0e01fbdd17bce0dfd3d602b51 Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 26 Feb 2025 15:12:07 +0100 Subject: [PATCH 2/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b473d4d6..90d58bfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed assignment of requester group to ticket - Ensure plugin works seamlessly in external contexts (e.g., from plugins) - Fixed `Close cloned tickets at the same time` option +- Fixed `Bypass filtering on the groups assignment` option ## [2.9.10] - 2024-11-27 From ea97747fbc3053413ac631e87d9850d35cd25500 Mon Sep 17 00:00:00 2001 From: Lainow Date: Wed, 26 Feb 2025 15:33:39 +0100 Subject: [PATCH 3/6] Fix unit test --- inc/ticket.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 9aa61849..81868f73 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -110,9 +110,7 @@ function ($carry, $type) use ($item) { } } - if (count($new_groups) > 0) { - self::removeAssignUsers($item); - } + self::removeAssignUsers($item); return $item; } } From 04d812b02ae9c4dbac559dce6cb4a538a20f87e6 Mon Sep 17 00:00:00 2001 From: Lainow Date: Mon, 3 Mar 2025 14:19:40 +0100 Subject: [PATCH 4/6] Change by --- hook.php | 7 +++++++ inc/ticket.class.php | 2 +- inc/user.class.php | 12 ++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hook.php b/hook.php index 6913df1a..fa64342a 100644 --- a/hook.php +++ b/hook.php @@ -382,6 +382,13 @@ function plugin_escalade_install() $migration->migrationOneTable('glpi_plugin_escalade_configs'); } + //Update to 2.9.10 + // change fields name + if ($DB->fieldExists('glpi_plugin_escalade_users', 'use_filter_assign_group')) { + $migration->changeField('glpi_plugin_escalade_users', 'use_filter_assign_group', 'bypass_filter_assign_group', "TINYINT NOT NULL DEFAULT '0'"); + $migration->migrationOneTable('glpi_plugin_escalade_users'); + } + return true; } diff --git a/inc/ticket.class.php b/inc/ticket.class.php index 4b7523fb..14781907 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -1122,7 +1122,7 @@ public function showForm($ID, $options = []) $condition = [ 'is_assign' => 1 ]; - if ($config->fields['use_filter_assign_group'] && !$user_config->fields['use_filter_assign_group']) { + if ($config->fields['use_filter_assign_group'] && !$user_config->fields['bypass_filter_assign_group']) { $condition['id'] = $groups_id_filtered; } TemplateRenderer::getInstance()->display('@escalade/escalade_form.html.twig', [ diff --git a/inc/user.class.php b/inc/user.class.php index 9d73938a..31fa319b 100644 --- a/inc/user.class.php +++ b/inc/user.class.php @@ -38,8 +38,8 @@ class PluginEscaladeUser extends CommonDBTM public static function showMassiveActionsSubForm(MassiveAction $ma) { switch ($ma->getAction()) { - case "use_filter_assign_group": - Dropdown::showYesNo("use_filter_assign_group", 0, -1, [ + case "bypass_filter_assign_group": + Dropdown::showYesNo("bypass_filter_assign_group", 0, -1, [ 'width' => '100%', ]); echo "

getAction()) { - case "use_filter_assign_group": + case "bypass_filter_assign_group": $escalade_user = new self(); $input = $ma->getInput(); foreach ($ids as $id) { if ($escalade_user->getFromDBByCrit(['users_id' => $id])) { - $escalade_user->fields['use_filter_assign_group'] = $input['use_filter_assign_group']; + $escalade_user->fields['bypass_filter_assign_group'] = $input['bypass_filter_assign_group']; if ($escalade_user->update($escalade_user->fields)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { @@ -126,7 +126,7 @@ public function showForm($ID, array $options = []) $is_exist = $this->getFromDBByCrit(['users_id' => $ID]); if (! $is_exist) { //"Security" - $this->fields["use_filter_assign_group"] = 0; + $this->fields["bypass_filter_assign_group"] = 0; } echo "
"; @@ -138,7 +138,7 @@ public function showForm($ID, array $options = []) echo "