mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
- First step towards Tom Murdock's suggestions on a global search feature (if it is ever implented)...
Added a new funtion: module_search( $course, $searchterms, $extended, $glossary = NULL) It returns all entries that matches the specified criteria in any glossaries within a given $course. It performs an $extended search if necessary. It restrict the search to only one $glossary if specified (currently used by the internal search function of the module).
This commit is contained in:
parent
d33986dbe6
commit
c80828fe8f
1 changed files with 23 additions and 7 deletions
|
@ -700,13 +700,24 @@ function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode="
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function glossary_search_entries($searchterms, $glossary, $includedefinition) {
|
function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL) {
|
||||||
/// Returns a list of entries found using an array of search terms
|
// It returns all entries from all glossaries that matches the specified criteria
|
||||||
/// eg word +word -word
|
// within a given $course. It performs an $extended search if necessary.
|
||||||
///
|
// It restrict the search to only one $glossary if the $glossary parameter is set.
|
||||||
|
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
if ( !$glossary ) {
|
||||||
|
if ( $glossaries = get_records("glossary", "course", $course->id) ) {
|
||||||
|
$glos = "";
|
||||||
|
foreach ( $glossaries as $glossary ) {
|
||||||
|
$glos .= "$glossary->id,";
|
||||||
|
}
|
||||||
|
$glos = substr($ents,0,-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$glos = $glossary->id;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isteacher($glossary->course)) {
|
if (!isteacher($glossary->course)) {
|
||||||
$glossarymodule = get_record("modules", "name", "glossary");
|
$glossarymodule = get_record("modules", "name", "glossary");
|
||||||
$onlyvisible = " AND g.id = cm.instance AND cm.visible = 1 AND cm.module = $glossarymodule->id";
|
$onlyvisible = " AND g.id = cm.instance AND cm.visible = 1 AND cm.module = $glossarymodule->id";
|
||||||
|
@ -756,7 +767,7 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$includedefinition ) {
|
if ( !$extended ) {
|
||||||
$definitionsearch = "0";
|
$definitionsearch = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,12 +775,17 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) {
|
||||||
{$CFG->prefix}glossary g $onlyvisibletable
|
{$CFG->prefix}glossary g $onlyvisibletable
|
||||||
WHERE ($conceptsearch OR $definitionsearch)
|
WHERE ($conceptsearch OR $definitionsearch)
|
||||||
AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible
|
AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible
|
||||||
AND g.id = $glossary->id AND e.approved != 0";
|
AND g.id IN ($glos) AND e.approved != 0";
|
||||||
|
|
||||||
return get_records_sql("SELECT e.*
|
return get_records_sql("SELECT e.*
|
||||||
FROM $selectsql ORDER BY e.concept ASC");
|
FROM $selectsql ORDER BY e.concept ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function glossary_search_entries($searchterms, $glossary, $extended) {
|
||||||
|
$course = get_record("course","id",$glossary->course);
|
||||||
|
return glossary_search($course,$searchterms,$extended,$glossary);
|
||||||
|
}
|
||||||
|
|
||||||
function glossary_file_area_name($entry) {
|
function glossary_file_area_name($entry) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
// Creates a directory file name, suitable for make_upload_directory()
|
// Creates a directory file name, suitable for make_upload_directory()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue