Merge pull request #4912 from christianbeeznest/ofaj-21006-4

Diagnosis: Improve condition of tags in searching - refs BT#21006
pull/4913/head
Nicolas Ducoulombier 1 year ago committed by GitHub
commit 5005a10d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      public/main/inc/lib/api.lib.php
  2. 2
      public/main/inc/lib/extra_field.lib.php
  3. 13
      public/main/inc/lib/sessionmanager.lib.php

@ -3589,7 +3589,7 @@ function api_get_language_id($language)
// We check the language by iscocode
$langInfo = api_get_language_from_iso($language);
if (!empty($langInfo->getId())) {
if (null !== $langInfo && !empty($langInfo->getId())) {
return $langInfo->getId();
}

@ -2913,7 +2913,7 @@ JAVASCRIPT;
$newCounter++;
}
if (!empty($whereTag)) {
$options['where'] .= ' AND ('.implode(' AND ', $whereTag).') ';
$options['where'] .= ' AND ('.implode(' OR ', $whereTag).') ';
}
}
break;

@ -554,6 +554,13 @@ class SessionManager
INNER JOIN $tableCourse c ON (sc.c_id = c.id)";
$language = Database::escape_string($language);
// Get the isoCode to filter course_language
$isoCode = '';
$languageId = api_get_language_id($language);
if (!empty($languageId)) {
$languageInfo = api_get_language_info($languageId);
$isoCode = $languageInfo['isocode'];
}
if ('true' === api_get_setting('language.allow_course_multiple_languages')) {
$tblExtraField = Database::get_main_table(TABLE_EXTRA_FIELD);
$tblExtraFieldValue = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
@ -563,12 +570,12 @@ class SessionManager
if (Database::num_rows($rs) > 0) {
$fieldId = Database::result($rs, 0, 0);
$sqlInjectJoins .= " INNER JOIN $tblExtraFieldValue cfv ON (c.id = cfv.item_id AND cfv.field_id = $fieldId)";
$where .= " AND (c.course_language = '$language' OR cfv.field_value LIKE '%$language%')";
$where .= " AND (c.course_language = '$isoCode' OR cfv.field_value LIKE '%$language%')";
} else {
$where .= " AND c.course_language = '$language' ";
$where .= " AND c.course_language = '$isoCode' ";
}
} else {
$where .= " AND c.course_language = '$language' ";
$where .= " AND c.course_language = '$isoCode' ";
}
}

Loading…
Cancel
Save