]> git.mjollnir.org Git - moodle.git/commitdiff
Now search function look into aliases too.
authorstronk7 <stronk7>
Sat, 11 Dec 2004 00:54:37 +0000 (00:54 +0000)
committerstronk7 <stronk7>
Sat, 11 Dec 2004 00:54:37 +0000 (00:54 +0000)
Bug 2242
(http://moodle.org/bugs/bug.php?op=show&bugid=2242)

Merged from MOODLE_14_STABLE

mod/glossary/sql.php

index 8ad7ea961b84abd24b9d14caafe781297db9f0ed..d576088e830458c766cf46c58ae22df8aab56256 100644 (file)
 
         switch ( $mode ) {
         case 'search': 
+            //First, look in aliases (bug 2242)
+            $idaliases = '';
+            $listaliases = array();
+            $recaliases = get_records_sql ("SELECT al.id, al.entryid
+                                              FROM {$CFG->prefix}glossary_alias al,
+                                                   {$CFG->prefix}glossary_entries ge
+                                              WHERE (ge.glossaryid = '$glossary->id' OR 
+                                                     ge.sourceglossaryid = '$glossary->id') AND
+                                                    (ge.approved != 0 $userid) AND
+                                                    ge.id = al.entryid AND
+                                                    al.alias $LIKE '%$hook%'");
+            if ($recaliases) {
+                foreach ($recaliases as $recalias) {
+                    $listaliases[] = $recalias->entryid;
+                }
+                $idaliases = implode (',',$listaliases);
+            }
             $printpivot = 0;
             $where = "AND ( ge.concept $LIKE '%$hook%'";
+            //Include aliases in resultset (if any)
+            if (!empty($idaliases)) {
+                $where .= " OR ge.id IN ($idaliases)";
+            }
             if ( $fullsearch ) {
-                $where .= "OR ge.definition $LIKE '%$hook%')";
+                $where .= " OR ge.definition $LIKE '%$hook%')";
             } else {
                 $where .= ")";
             }