]> git.mjollnir.org Git - moodle.git/commitdiff
- Fixed some bugs detected with Jeff's glossary (mostly with dynalink link feature)
authorwillcast <willcast>
Tue, 21 Oct 2003 13:27:48 +0000 (13:27 +0000)
committerwillcast <willcast>
Tue, 21 Oct 2003 13:27:48 +0000 (13:27 +0000)
mod/glossary/dynalink.php
mod/glossary/edit.php
mod/glossary/lib.php
mod/glossary/showentry.php
mod/glossary/view.php

index 952ebdb174716ebdf68a8079ec3c5e3faee2a570..e1ada8ed963d93053c84a418fad80c4b817e3578 100644 (file)
@@ -12,7 +12,7 @@
         $GLOSSARY_CONCEPT_IS_ENTRY = 0;
         $GLOSSARY_CONCEPT_IS_CATEGORY = 1;
 
-        $glossarieslist = get_records_select("glossary", "usedynalink = 1 and course = $courseid","id");
+        $glossarieslist = get_records_select("glossary", "usedynalink != 0 and course = $courseid","id");
         if ( $glossarieslist ) {
             $glossaries = "";
             foreach ( $glossarieslist as $glossary ) {
@@ -20,7 +20,7 @@
             }
             $glossaries=substr($glossaries,0,-1);
 
-            $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink = 1 and approved != 0","glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
+            $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0","glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
             $categories  = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
             if ( $entries and $categories ) {
                 $concepts = array_merge($entries, $categories);
             $regexp = '/' . $invalidprefixs . "(" . $list_of_words_cp . ")" . "|"  . "(" . $list_of_words_cp . ")". $invalidsufixs .  '/is';
             preg_match_all($regexp,$text,$list_of_words);
 
-            foreach (array_unique($list_of_words[0]) as $key=>$value) {
-                $words['<*'.$key.'*>'] = $value;
-            }
-            if ( $words ) {
-                $text = str_replace($words,array_keys($words),$text);
+            if ($list_of_words) {
+                foreach (array_unique($list_of_words[0]) as $key=>$value) {
+                    $words['<*'.$key.'*>'] = $value;
+                }
+                if ( $words ) {
+                    $text = str_replace($words,array_keys($words),$text);
+                }
             }
         }
 
         }
     }
 
-?>
+?>
\ No newline at end of file
index 8c8bec933407db7ce39567134935f0d4da454d06..84152873239c819104fca5e8be8243bdee2030ef 100644 (file)
@@ -110,9 +110,9 @@ if ( $confirm ) {
 
     delete_records("glossary_entries_categories","entryid",$e);
 
-    if ( $categories ) {
+    if ( isset($form->categories) ) {
         $newcategory->entryid = $newentry->id;
-        foreach ($categories as $category) {
+        foreach ($form->categories as $category) {
             if ( $category > 0 ) {
                 $newcategory->categoryid =$category;
                 insert_record("glossary_entries_categories",$newcategory);
index 3ddd5d4810069e1cd26f714a360a6ba98f8c63ce..91dd3a53e075bc6b06169b9e8c1bb2733ca2b323 100644 (file)
@@ -418,8 +418,8 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) {
 
 //    $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
 
-    return get_records_sql("SELECT e.concept, e.definition, e.userid, e.timemodified, e.id, e.format 
-                            FROM $selectsql ORDER BY e.concept ASC $limit");
+    return get_records_sql("SELECT e.* 
+                            FROM $selectsql ORDER BY e.concept ASC");
 }
 
 function glossary_file_area_name($entry) {
index 26d25dfbc6ea43ebd346c34605606c105894b372..9687fad3504659380b09a6fae27fa9753261211b 100644 (file)
@@ -8,10 +8,10 @@
     print_header();
     $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
                                   " where e.glossaryid = g.id and".
-                                      " (e.casesensitive = 1 and ucase(concept) = '" . strtoupper(trim($concept)). "' or".
+                                      " (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or".
                                       " e.casesensitive = 0 and concept = '$concept') and".
                                       " g.course = $courseid and".
-                                      " e.usedynalink = 1 and g.usedynalink = 1");
+                                      " e.usedynalink != 0 and g.usedynalink != 0");
     
     glossary_print_dynaentry($courseid, $entries);
     
index 3c654efb917d1df6eb780e61c3021315e50b6e75..f5b2786b2473aafe01f06cd895f8a907cd2641eb 100644 (file)
                                 } 
                             } 
                         } 
-                        $dumptoscreen = 1;
                     }
+                    $dumptoscreen = 1;
                 } elseif ($l == "SPECIAL" and ord($firstletter) != ord("Ñ") and 
                          (ord($firstletter) < ord("A") or ord($firstletter) > ord("Z"))) {
                     $dumptoscreen = 1;
                                     if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
                                         echo "</center><p>";
                                     }
-                                    $dumptoscreen = 1;
                                 }
                             } 
+                            $dumptoscreen = 1;
     
                             if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
                                 echo "\n</center></td></tr></table></center>";