Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- First step towards Tom Murdock's suggestions on a global search fea…

…ture (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).
  • Loading branch information...
commit c80828fe8fe3483a271fd6933dd2eee92d8882ee 1 parent d33986d
authored December 03, 2003

Showing 1 changed file with 23 additions and 7 deletions. Show diff stats Hide diff stats

  1. 30  mod/glossary/lib.php
30  mod/glossary/lib.php
@@ -700,13 +700,24 @@ function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$mode="
700 700
     return $return;
701 701
 }
702 702
 
703  
-function glossary_search_entries($searchterms, $glossary, $includedefinition) {
704  
-/// Returns a list of entries found using an array of search terms
705  
-/// eg   word  +word -word
706  
-///
  703
+function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL) {
  704
+// It returns all entries from all glossaries that matches the specified criteria 
  705
+//    within a given $course. It performs an $extended search if necessary.
  706
+// It restrict the search to only one $glossary if the $glossary parameter is set.
707 707
 
708 708
     global $CFG;
709  
-
  709
+    if ( !$glossary ) {
  710
+        if ( $glossaries = get_records("glossary", "course", $course->id) ) {
  711
+            $glos = "";
  712
+            foreach ( $glossaries as $glossary ) {
  713
+                $glos .= "$glossary->id,";
  714
+            }
  715
+            $glos = substr($ents,0,-1);
  716
+        }
  717
+    } else {
  718
+        $glos = $glossary->id;
  719
+    }
  720
+    
710 721
     if (!isteacher($glossary->course)) {
711 722
         $glossarymodule = get_record("modules", "name", "glossary");
712 723
         $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) {
756 767
         }
757 768
     }
758 769
 
759  
-    if ( !$includedefinition ) {
  770
+    if ( !$extended ) {
760 771
         $definitionsearch = "0";
761 772
     }
762 773
 
@@ -764,12 +775,17 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) {
764 775
                   {$CFG->prefix}glossary g $onlyvisibletable
765 776
              WHERE ($conceptsearch OR $definitionsearch)
766 777
                AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible
767  
-               AND g.id = $glossary->id AND e.approved != 0";
  778
+               AND g.id IN ($glos) AND e.approved != 0";
768 779
 
769 780
     return get_records_sql("SELECT e.* 
770 781
                             FROM $selectsql ORDER BY e.concept ASC");
771 782
 }
772 783
 
  784
+function glossary_search_entries($searchterms, $glossary, $extended) {
  785
+    $course = get_record("course","id",$glossary->course);
  786
+    return glossary_search($course,$searchterms,$extended,$glossary);
  787
+}
  788
+
773 789
 function glossary_file_area_name($entry) {
774 790
     global $CFG;
775 791
 //  Creates a directory file name, suitable for make_upload_directory()

0 notes on commit c80828f

Please sign in to comment.
Something went wrong with that request. Please try again.