Skip to content

Commit 6287f1b

Browse files
committed
fix(category): translation feature of dropdowns not handled
1 parent a003593 commit 6287f1b

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

inc/category.class.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,51 @@ public static function getCategoryTree(): array {
130130
]);
131131
$request = [
132132
'SELECT' => [
133-
'id',
134-
'name',
135-
'comment',
133+
self::getTableField('id'),
136134
"$categoryFk as parent",
137135
'level',
138136
new QueryExpression(
139137
$count1->getQuery() . " + " . $count2->getQuery() . " as items_count"
140138
),
141139
],
142140
'FROM' => $cat_table,
141+
'LEFT JOIN' => [],
143142
'ORDER' => ["level DESC", "name DESC"],
144143
];
144+
$translation_table = DropdownTranslation::getTable();
145+
if (Session::haveTranslations(self::getType(), 'name')) {
146+
$request['LEFT JOIN']["$translation_table as namet"] = [
147+
'FKEY' => [
148+
$cat_table => 'id',
149+
'namet' => 'items_id',
150+
['AND' => [
151+
'namet.language' => $_SESSION['glpilanguage'],
152+
'namet.itemtype' => self::getType(),
153+
'namet.field' => 'name',
154+
]],
155+
],
156+
];
157+
$request['SELECT'][] = 'namet.value as name';
158+
} else {
159+
$request['SELECT'][] = 'name';
160+
$request['SELECT'][] = 'comment';
161+
}
162+
if (Session::haveTranslations(self::getType(), 'comment')) {
163+
$request['LEFT JOIN']["$translation_table as commentt"] = [
164+
'FKEY' => [
165+
$cat_table => 'id',
166+
'commentt' => 'items_id',
167+
['AND' => [
168+
'namet.language' => $_SESSION['glpilanguage'],
169+
'namet.itemtype' => self::getType(),
170+
'namet.field' => 'comment',
171+
]],
172+
],
173+
];
174+
$request['SELECT'][] = 'commentt.value as comment';
175+
} else {
176+
$request['SELECT'][] = 'comment';
177+
}
145178
$result = $DB->request($request);
146179

147180
$categories = [];

0 commit comments

Comments
 (0)