Skip to content

Commit 535aa82

Browse files
committed
fix(issue): possible SQL error whe naccessing issues from helpdesk
not allowed by the UI, but may be useful someday Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 33775dd commit 535aa82

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hook.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,14 @@ function plugin_formcreator_addDefaultWhere($itemtype) {
146146
$currentUser = Session::getLoginUserID();
147147
// Use default where for Tickets
148148
$condition = Search::addDefaultWhere(Ticket::class);
149-
// Replace references to ticket tables with issues table
150-
$condition = str_replace('`glpi_tickets`', '`glpi_plugin_formcreator_issues`', $condition);
151-
$condition = str_replace('`users_id_recipient`', '`requester_id`', $condition);
149+
if ($condition != '') {
150+
// Replace references to ticket tables with issues table
151+
$condition = str_replace('`glpi_tickets`', '`glpi_plugin_formcreator_issues`', $condition);
152+
$condition = str_replace('`users_id_recipient`', '`requester_id`', $condition);
153+
$condition .= ' OR ';
154+
}
152155
// condition where current user is 1st validator of the issue
153-
$condition .= " OR `glpi_plugin_formcreator_issues`.`users_id_validator` = '$currentUser'";
156+
$condition .= " `glpi_plugin_formcreator_issues`.`users_id_validator` = '$currentUser'";
154157
// condition where current user is a member of 1st validator group of the issue
155158
$groupList = [];
156159
foreach (Group_User::getUserGroups($currentUser) as $group) {

0 commit comments

Comments
 (0)