diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 210b2d06c98..aec20384d8a 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -478,6 +478,23 @@ function glossary_get_entries($glossaryid, $entrylist, $pivot = "") { WHERE glossaryid = '$glossaryid' AND id IN ($entrylist)"); } + +function glossary_get_entries_search($concept, $courseid) { + global $CFG; + + $conceptupper = strtoupper(trim($concept)); + + return get_records_sql("SELECT e.*, g.name as glossaryname + FROM {$CFG->prefix}glossary_entries e, + {$CFG->prefix}glossary g + WHERE e.glossaryid = g.id + AND ( (e.casesensitive != 0 and UPPER(concept) = '$conceptupper') + OR (e.casesensitive = 0 and concept = '$concept')) + AND (g.course = '$courseid' OR g.globalglossary = 1) + AND e.usedynalink != 0 + AND g.usedynalink != 0"); +} + function glossary_get_entries_sorted($glossary, $where="", $orderby="", $pivot = "") { global $CFG; if ($where) { diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index d8fe45765f4..e06faa02990 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -12,19 +12,17 @@ } if ($eid) { - $entries[] = get_record("glossary_entries", "id", $eid); + $entry = get_record("glossary_entries", "id", $eid); + $glossary = get_record('glossary','id',$entry->glossaryid); + $entry->glossaryname = $glossary->name; + $entries[] = $entry; } else if ($concept) { - $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g". - " where e.glossaryid = g.id and". - " (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or". - " e.casesensitive = 0 and concept = '$concept') and". - " (g.course = $courseid or g.globalglossary) and". - " e.usedynalink != 0 and g.usedynalink != 0"); + $entries = glossary_get_entries_search($concept, $courseid); } - foreach ($entries as $entry) { - $glossary = get_record('glossary','id',$entry->glossaryid); + foreach ($entries as $key => $entry) { + $entries[$key]->definition .= "
"; } if (!empty($courseid)) { @@ -38,10 +36,10 @@ $CFG->framename = "newwindow"; if ($course->category) { - print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname", + print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), "$course->fullname", "wwwroot/course/view.php?id=$course->id\">$course->shortname -> $strglossaries -> $strsearch", "", "", true, " ", " "); } else { - print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname", + print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), "$course->fullname", "$strglossaries -> $strsearch", "", "", true, " ", " "); }