Skip to content

Commit

Permalink
fix(dropdownfield): useless duplicate conditions for tickets
Browse files Browse the repository at this point in the history
internal ref 32345
  • Loading branch information
btry committed Apr 23, 2024
1 parent 9ac92f0 commit d81a43e
Showing 1 changed file with 0 additions and 29 deletions.
29 changes: 0 additions & 29 deletions inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,40 +227,11 @@ public function buildParams($rand = null) {
if (Session::haveRight("ticket", Ticket::READALL)) {
break;
}
$currentUser = Session::getLoginUserID();
if (!Session::haveRight(Ticket::$rightname, Ticket::READMY) && !Session::haveRight(Ticket::$rightname, Ticket::READGROUP)) {
// No right to view any ticket, then force the dropdown to be empty
$dparams_cond_crit['OR'] = new QueryExpression('0=1');
break;
}
$tickets_filter = ['users_id_recipient' => $currentUser];

if (Session::haveRight(Ticket::$rightname, Ticket::READMY)) {
$requestersObserversQuery = new QuerySubQuery([
'SELECT' => 'tickets_id',
'FROM' => Ticket_User::getTable(),
'WHERE' => [
'users_id' => $currentUser,
'type' => [CommonITILActor::REQUESTER, CommonITILActor::OBSERVER]
],
]);
$tickets_filter[] = [
Ticket::getTableField('id') => $requestersObserversQuery,
];
}

if (Session::haveRight(Ticket::$rightname, Ticket::READGROUP) && count($_SESSION['glpigroups']) > '0') {
$requestersObserversGroupsQuery = new QuerySubQuery([
'SELECT' => 'tickets_id',
'FROM' => Group_Ticket::getTable(),
'WHERE' => [
'type' => [CommonITILActor::REQUESTER, CommonITILActor::OBSERVER],
'groups_id' => $_SESSION['glpigroups'],
],
]);
$tickets_filter[] = [Ticket::getTableField('id') => $requestersObserversGroupsQuery];
}
$dparams_cond_crit['OR'] = $tickets_filter;
break;

default:
Expand Down

0 comments on commit d81a43e

Please sign in to comment.