Skip to content

Commit

Permalink
fix(category): translation feature of dropdowns not handled
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Sep 25, 2023
1 parent a003593 commit 6287f1b
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions inc/category.class.php
Expand Up @@ -130,18 +130,51 @@ public static function getCategoryTree(): array {
]);
$request = [
'SELECT' => [
'id',
'name',
'comment',
self::getTableField('id'),
"$categoryFk as parent",
'level',
new QueryExpression(
$count1->getQuery() . " + " . $count2->getQuery() . " as items_count"
),
],
'FROM' => $cat_table,
'LEFT JOIN' => [],
'ORDER' => ["level DESC", "name DESC"],
];
$translation_table = DropdownTranslation::getTable();
if (Session::haveTranslations(self::getType(), 'name')) {
$request['LEFT JOIN']["$translation_table as namet"] = [
'FKEY' => [
$cat_table => 'id',
'namet' => 'items_id',
['AND' => [
'namet.language' => $_SESSION['glpilanguage'],
'namet.itemtype' => self::getType(),
'namet.field' => 'name',
]],
],
];
$request['SELECT'][] = 'namet.value as name';
} else {
$request['SELECT'][] = 'name';
$request['SELECT'][] = 'comment';
}
if (Session::haveTranslations(self::getType(), 'comment')) {
$request['LEFT JOIN']["$translation_table as commentt"] = [
'FKEY' => [
$cat_table => 'id',
'commentt' => 'items_id',
['AND' => [
'namet.language' => $_SESSION['glpilanguage'],
'namet.itemtype' => self::getType(),
'namet.field' => 'comment',
]],
],
];
$request['SELECT'][] = 'commentt.value as comment';
} else {
$request['SELECT'][] = 'comment';
}
$result = $DB->request($request);

$categories = [];
Expand Down

0 comments on commit 6287f1b

Please sign in to comment.