Skip to content

Commit

Permalink
fix(faq): visibility (#3118)
Browse files Browse the repository at this point in the history
Compatibility update for GLPI 10.0.7
  • Loading branch information
Rom1-B authored May 12, 2023
1 parent 0a08eb7 commit 252ef20
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion inc/category.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ public static function getCategoryTree(): array {
$form_table = PluginFormcreatorForm::getTable();
$table_fp = PluginFormcreatorForm_Profile::getTable();

if (version_compare(GLPI_VERSION, '10.0.6') > 0) {
$knowbase_category = KnowbaseItemCategory::SEEALL;
} else {
$knowbase_category = 0;
}

$query_faqs = KnowbaseItem::getListRequest([
'faq' => '1',
'contains' => '',
'knowbaseitemcategories_id' => 0,
'knowbaseitemcategories_id' => $knowbase_category,
]);
// GLPI 9.5 returns an array
$subQuery = new DBMysqlIterator($DB);
Expand Down
10 changes: 7 additions & 3 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -820,16 +820,20 @@ public static function getFormList(int $rootCategory = 0, string $keywords = '',
'faq' => '1',
'contains' => $keywords
];
$params['knowbaseitemcategories_id'] = 0;
if (version_compare(GLPI_VERSION, '10.0.6') > 0) {
$params['knowbaseitemcategories_id'] = KnowbaseItemCategory::SEEALL;
} else {
$params['knowbaseitemcategories_id'] = 0;
}
if (count($selectedCategories) > 0) {
$iterator = $DB->request($table_cat, [
'WHERE' => [
'id' => $selectedCategories
]
]);
$kbcategories = [];
foreach ($iterator as $kbcat) {
$kbcategories[] = $kbcat['knowbaseitemcategories_id'];
foreach ($iterator as $knowbase_category) {
$kbcategories[] = $knowbase_category['knowbaseitemcategories_id'];
}
$params['knowbaseitemcategories_id'] = $kbcategories;
}
Expand Down
6 changes: 5 additions & 1 deletion inc/knowbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ public static function getFaqItems($rootCategory = 0, $keywords = '') {
'faq' => '1',
'contains' => $keywords
];
$params['knowbaseitemcategories_id'] = 0;
if (version_compare(GLPI_VERSION, '10.0.6') > 0) {
$params['knowbaseitemcategories_id'] = KnowbaseItemCategory::SEEALL;
} else {
$params['knowbaseitemcategories_id'] = 0;
}
if (count($selectedCategories) > 0) {
$params['knowbaseitemcategories_id'] = $selectedCategories;
}
Expand Down

0 comments on commit 252ef20

Please sign in to comment.