MDL-25418 glossary - fix incorrect LOWER() call also present in glossary import ...
authorEloy Lafuente <stronk7@moodle.org>
Thu, 9 Dec 2010 22:50:23 +0000 (22:50 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Thu, 9 Dec 2010 22:50:23 +0000 (22:50 +0000)
mod/glossary/exportentry.php
mod/glossary/import.php

index e4bff6a..5bc4edc 100644 (file)
@@ -69,7 +69,10 @@ $entryalreadyexist = get_string('entryalreadyexist','glossary');
 $entryexported     = get_string('entryexported','glossary');
 
 if (!$mainglossary->allowduplicatedentries) {
-    if ($DB->get_record('glossary_entries', array('glossaryid'=>$mainglossary->id, 'lower(concept)'=>moodle_strtolower($entry->concept)))) {
+    if ($DB->record_exists_select('glossary_entries',
+            'glossaryid = :glossaryid AND LOWER(concept) = :concept', array(
+                'glossaryid' => $mainglossary->id,
+                'concept'    => moodle_strtolower($entry->concept)))) {
         $PAGE->set_title(format_string($glossary->name));
         $PAGE->set_heading($course->fullname);
         echo $OUTPUT->header();
index 3251306..5b458d4 100644 (file)
@@ -204,9 +204,15 @@ if ($xml = glossary_read_imported_file($result)) {
             if ( !$glossary->allowduplicatedentries ) {
                 // checking if the entry is valid (checking if it is duplicated when should not be)
                 if ( $newentry->casesensitive ) {
-                    $dupentry = $DB->get_record("glossary_entries", array("concept"=>$newentry->concept, "glossaryid"=>$glossary->id));
+                    $dupentry = $DB->record_exists_select('glossary_entries',
+                                    'glossaryid = :glossaryid AND concept = :concept', array(
+                                        'glossaryid' => $glossary->id,
+                                        'concept'    => $newentry->concept));
                 } else {
-                    $dupentry = $DB->get_record("glossary_entries", array("lower(concept)"=>moodle_strtolower($newentry->concept), "glossaryid"=>$glossary->id));
+                    $dupentry = $DB->record_exists_select('glossary_entries',
+                                    'glossaryid = :glossaryid AND LOWER(concept) = :concept', array(
+                                        'glossaryid' => $glossary->id,
+                                        'concept'    => moodle_strtolower($newentry->concept)));
                 }
                 if ($dupentry) {
                     $permissiongranted = 0;