Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Apr 25, 2024
1 parent 5de3eab commit 3d44435
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/Features/AssignableItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,30 @@ public static function getAssignableVisiblityCriteria()
global $DB;

if (Session::haveRight(static::$rightname, READ)) {
return [];
}
if (Session::haveRight(static::$rightname, READ_ASSIGNED)) {
$condition = [new QueryExpression('1')];
} elseif (Session::haveRight(static::$rightname, READ_ASSIGNED)) {
$item_table = static::getTable();
$relation_table = Group_Item::getTable();

$condition = [
'OR' => [
$item_table . '.users_id_tech' => $_SESSION['glpiID'],
$item_table . '.id' => new QuerySubQuery([
'SELECT' => $relation_table . '.items_id',
'FROM' => $relation_table,
'WHERE' => [
'itemtype' => static::class,
'groups_id' => $_SESSION['glpigroups'],
'type' => Group_Item::GROUP_TYPE_TECH,
]
]),
]
$item_table . '.users_id_tech' => $_SESSION['glpiID'],
];
if (count($_SESSION['glpigroups']) > 0) {
$condition = [
'OR' => [
$condition,
$item_table . '.id' => new QuerySubQuery([
'SELECT' => $relation_table . '.items_id',
'FROM' => $relation_table,
'WHERE' => [
'itemtype' => static::class,
'groups_id' => $_SESSION['glpigroups'],
'type' => Group_Item::GROUP_TYPE_TECH,
]
]),
]
];
}
} else {
$condition = [new QueryExpression('0')];
}
Expand Down

0 comments on commit 3d44435

Please sign in to comment.