]> git.mjollnir.org Git - moodle.git/commitdiff
Some checks are now done. SC#18.
authorstronk7 <stronk7>
Wed, 15 Dec 2004 09:03:39 +0000 (09:03 +0000)
committerstronk7 <stronk7>
Wed, 15 Dec 2004 09:03:39 +0000 (09:03 +0000)
Merged from MOODLE_14_STABLE

mod/glossary/lib.php
mod/glossary/print.php
mod/glossary/view.php

index 3c4aab27f56b3c15689c71f8c7b70d6f419914d0..c4bf1a33af12c9d7b5fff559426b597f7e9e6feb 100644 (file)
@@ -75,7 +75,11 @@ function glossary_add_instance($glossary) {
     $glossary->timecreated = time();
     $glossary->timemodified = $glossary->timecreated;
 
-    # May have to add extra stuff in here #
+    //Check displayformat is a valid one
+    $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
+    if (!in_array($glossary->displayformat, $formats)) {
+        error("This format doesn't exist!");
+    }  
 
     return insert_record("glossary", $glossary);
 }
@@ -110,6 +114,12 @@ global $CFG;
         $glossary->assesstimefinish = 0;
     }
 
+    //Check displayformat is a valid one
+    $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
+    if (!in_array($glossary->displayformat, $formats)) {
+        error("This format doesn't exist!");
+    }
+
     $return = update_record("glossary", $glossary);
        if ($return and $glossary->defaultapproval) {
         execute_sql("update {$CFG->prefix}glossary_entries SET approved = 1 where approved != 1 and glossaryid = " . $glossary->id,false);
index 538a099a6843c2b8b89199db1281d984e47e2793..a241253e0138303f0e6d047fcf081d322b77b887 100644 (file)
@@ -44,7 +44,7 @@
 
 /// setting the default values for the display mode of the current glossary
 /// only if the glossary is viewed by the first time
-    if ( $dp = get_record('glossary_formats','name', $glossary->displayformat) ) {
+    if ( $dp = get_record('glossary_formats','name', addslashes($glossary->displayformat)) ) {
         $printpivot = $dp->showgroup;
         if ( $mode == '' and $hook == '' and $show == '') {
             $mode      = $dp->defaultmode;
index 3ce65b107d6ebe087b189c5d43c22233678d93ef..e26f5b10fb252322e2ea70d30ef4dbdef64ecfeb 100644 (file)
@@ -71,7 +71,7 @@
 
 /// setting the default values for the display mode of the current glossary
 /// only if the glossary is viewed by the first time
-    if ( $dp = get_record('glossary_formats','name', $glossary->displayformat) ) {
+    if ( $dp = get_record('glossary_formats','name', addslashes($glossary->displayformat)) ) {
         $printpivot = $dp->showgroup;
         if ( $mode == '' and $hook == '' and $show == '') {
             $mode      = $dp->defaultmode;