Permalink
Browse files

Some checks are now done. SC#18.

  • Loading branch information...
1 parent 4a01c21 commit 01988ca33f68ed37e8939d901ea88aaafdbb187a stronk7 committed Dec 15, 2004
Showing with 13 additions and 3 deletions.
  1. +11 −1 mod/glossary/lib.php
  2. +1 −1 mod/glossary/print.php
  3. +1 −1 mod/glossary/view.php
View
12 mod/glossary/lib.php
@@ -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 @@ function glossary_update_instance($glossary) {
$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);
View
2 mod/glossary/print.php
@@ -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;
View
2 mod/glossary/view.php
@@ -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;

0 comments on commit 01988ca

Please sign in to comment.