Skip to content

Commit

Permalink
Merge pull request #5962 from christianbeeznest/Ifa-22235
Browse files Browse the repository at this point in the history
Gossary: Fix load glossary from base course if not found in session - refs BT#22235
  • Loading branch information
NicoDucou authored Dec 11, 2024
2 parents a52de43 + ca83c91 commit 02fae33
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions main/inc/lib/glossary.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public static function get_glossary_term_by_glossary_name($name)
$table = Database::get_course_table(TABLE_GLOSSARY);
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$sessionCondition = api_get_session_condition($session_id);

$glossaryName = Security::remove_XSS($name);
$glossaryName = api_convert_encoding($glossaryName, 'UTF-8', 'UTF-8');
$glossaryName = trim($glossaryName);
Expand All @@ -95,16 +93,31 @@ public static function get_glossary_term_by_glossary_name($name)
}

$sql = "SELECT * FROM $table
WHERE
c_id = $course_id AND
(
name LIKE '".Database::escape_string($glossaryName)."'
OR
name LIKE '".Database::escape_string($parsed)."'
)
$sessionCondition
LIMIT 1
";
WHERE
c_id = $course_id AND
(
name LIKE '".Database::escape_string($glossaryName)."' OR
name LIKE '".Database::escape_string($parsed)."'
) AND
session_id = $session_id
LIMIT 1";

$rs = Database::query($sql);

if (Database::num_rows($rs) > 0) {
return Database::fetch_array($rs, 'ASSOC');
}

$sql = "SELECT * FROM $table
WHERE
c_id = $course_id AND
(
name LIKE '".Database::escape_string($glossaryName)."' OR
name LIKE '".Database::escape_string($parsed)."'
) AND
session_id IS NULL
LIMIT 1";

$rs = Database::query($sql);

if (Database::num_rows($rs) > 0) {
Expand Down

0 comments on commit 02fae33

Please sign in to comment.