Skip to content

Commit

Permalink
Gossary: Fix load glossary from base course if not found in session -…
Browse files Browse the repository at this point in the history
… refs BT#22235
  • Loading branch information
christianbeeznest committed Dec 10, 2024
1 parent e11bb25 commit ca83c91
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 ca83c91

Please sign in to comment.