Skip to content

Commit 000a7c2

Browse files
LainowRom1-B
andauthored
Fix Bypass filtering on the groups assignment option (#291)
* Fix Bypass filtering on the groups assignment option * Update changelog * Fix unit test * Change by * Fix php warning * Update hook.php Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com> --------- Co-authored-by: Romain B. <8530352+Rom1-B@users.noreply.github.com>
1 parent 8f63910 commit 000a7c2

5 files changed

Lines changed: 19 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616
- Fixed assignment of requester group to ticket
1717
- Ensure plugin works seamlessly in external contexts (e.g., from plugins)
1818
- Fixed `Close cloned tickets at the same time` option
19+
- Fixed `Bypass filtering on the groups assignment` option
1920
- Rename the option **"Don't change"** to **"Default (not managed by plugin)"** for the **"Ticket status after an escalation"** setting to reduce ambiguity.
2021

2122
## [2.9.10] - 2024-11-27

hook.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ function plugin_escalade_install()
382382
$migration->migrationOneTable('glpi_plugin_escalade_configs');
383383
}
384384

385+
//Update to 2.9.10
386+
// change fields name
387+
if ($DB->fieldExists('glpi_plugin_escalade_users', 'use_filter_assign_group')) {
388+
$migration->changeField('glpi_plugin_escalade_users', 'use_filter_assign_group', 'bypass_filter_assign_group', 'bool');
389+
$migration->migrationOneTable('glpi_plugin_escalade_users');
390+
}
391+
385392
return true;
386393
}
387394

inc/config.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static function loadInSession()
374374
$user = new PluginEscaladeUser();
375375
if ($user->getFromDBByCrit(['users_id' => $_SESSION['glpiID']])) {
376376
//if a bypass is defined for user
377-
if ($user->fields['use_filter_assign_group']) {
377+
if ($user->fields['bypass_filter_assign_group']) {
378378
$config->fields['use_filter_assign_group'] = 0;
379379
}
380380
}

inc/ticket.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,10 +1116,13 @@ public function showForm($ID, $options = [])
11161116
$PluginEscaladeGroup_Group = new PluginEscaladeGroup_Group();
11171117
$groups_id_filtered = array_keys($PluginEscaladeGroup_Group->getGroups($tickets_id));
11181118
$groups_id_filtered = empty($groups_id_filtered) ? [-1] : $groups_id_filtered;
1119+
1120+
$user_config = new PluginEscaladeUser();
1121+
$user_config->getFromDBByCrit(['users_id' => Session::getLoginUserID()]);
11191122
$condition = [
11201123
'is_assign' => 1
11211124
];
1122-
if ($config->fields['use_filter_assign_group']) {
1125+
if ($config->fields['use_filter_assign_group'] && !$user_config->fields['bypass_filter_assign_group']) {
11231126
$condition['id'] = $groups_id_filtered;
11241127
}
11251128
TemplateRenderer::getInstance()->display('@escalade/escalade_form.html.twig', [

inc/user.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class PluginEscaladeUser extends CommonDBTM
3838
public static function showMassiveActionsSubForm(MassiveAction $ma)
3939
{
4040
switch ($ma->getAction()) {
41-
case "use_filter_assign_group":
42-
Dropdown::showYesNo("use_filter_assign_group", 0, -1, [
41+
case "bypass_filter_assign_group":
42+
Dropdown::showYesNo("bypass_filter_assign_group", 0, -1, [
4343
'width' => '100%',
4444
]);
4545
echo "<br><br><input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" .
@@ -57,13 +57,13 @@ public static function showMassiveActionsSubForm(MassiveAction $ma)
5757
public static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
5858
{
5959
switch ($ma->getAction()) {
60-
case "use_filter_assign_group":
60+
case "bypass_filter_assign_group":
6161
$escalade_user = new self();
6262
$input = $ma->getInput();
6363

6464
foreach ($ids as $id) {
6565
if ($escalade_user->getFromDBByCrit(['users_id' => $id])) {
66-
$escalade_user->fields['use_filter_assign_group'] = $input['use_filter_assign_group'];
66+
$escalade_user->fields['bypass_filter_assign_group'] = $input['bypass_filter_assign_group'];
6767
if ($escalade_user->update($escalade_user->fields)) {
6868
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
6969
} else {
@@ -126,7 +126,7 @@ public function showForm($ID, array $options = [])
126126
$is_exist = $this->getFromDBByCrit(['users_id' => $ID]);
127127

128128
if (! $is_exist) { //"Security"
129-
$this->fields["use_filter_assign_group"] = 0;
129+
$this->fields["bypass_filter_assign_group"] = 0;
130130
}
131131

132132
echo "<form action='" . $this->getFormURL() . "' method='post'>";
@@ -138,7 +138,7 @@ public function showForm($ID, array $options = [])
138138
echo "<td><label>";
139139
echo __("Bypass filtering on the groups assignment", "escalade");
140140
echo "&nbsp;";
141-
Dropdown::showYesNo("use_filter_assign_group", $this->fields["use_filter_assign_group"], -1, [
141+
Dropdown::showYesNo("bypass_filter_assign_group", $this->fields["bypass_filter_assign_group"], -1, [
142142
'width' => '100%',
143143
'rand' => $rand,
144144
]);

0 commit comments

Comments
 (0)