Skip to content

Commit 75276f1

Browse files
committed
fix(issue): restrict list of issues
if the user is not member of any group, the generated WHERE clause incluses everything
1 parent cfdf940 commit 75276f1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

hook.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,22 @@ function plugin_formcreator_addDefaultWhere($itemtype) {
151151
} else {
152152
$condition .= "`glpi_plugin_formcreator_issues`.`users_id_validator` = '$currentUser'";
153153
}
154+
154155
// condition where current user is a member of a validator group of the issue
155156
$groupList = [];
156157
foreach (Group_User::getUserGroups($currentUser) as $group) {
157158
$groupList[] = $group['id'];
158159
}
159-
$groupList = implode("', '", $groupList);
160-
if (Plugin::isPluginActive('advform')) {
161-
$complexJoinId = Search::computeComplexJoinID(Search::getOptions($itemtype)[9]['joinparams']);
162-
$condition .= " OR `glpi_groups_$complexJoinId`.`id` IN ('$groupList')";
163-
} else {
164-
$condition .= " OR `glpi_plugin_formcreator_issues`.`groups_id_validator` IN ('$groupList')";
160+
if (count($groupList) > 0) {
161+
$groupList = implode("', '", $groupList);
162+
if (Plugin::isPluginActive('advform')) {
163+
$complexJoinId = Search::computeComplexJoinID(Search::getOptions($itemtype)[9]['joinparams']);
164+
$condition .= " OR `glpi_groups_$complexJoinId`.`id` IN ('$groupList')";
165+
} else {
166+
$condition .= " OR `glpi_plugin_formcreator_issues`.`groups_id_validator` IN ('$groupList')";
167+
}
165168
}
169+
166170
// condition where current user is a validator of a issue of type ticket
167171
$complexJoinId = Search::computeComplexJoinID(Search::getOptions($itemtype)[11]['joinparams']);
168172
$condition .= " OR `glpi_users_users_id_validate_$complexJoinId`.`id` = '$currentUser'";

0 commit comments

Comments
 (0)