From 95d5682927d2ab2a90ffd9be6b8e24c14cd0e0dc Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 30 Jul 2006 22:22:22 +0000 Subject: [PATCH] Bug #6170 - Glossary bug: it displays nothing when autolinking to non-ascii text and other minor cleanup; merged from MOODLE_16_STABLE --- mod/glossary/edit.php | 8 ++++---- mod/glossary/exportentry.php | 6 +++--- mod/glossary/import.php | 4 ++-- mod/glossary/lib.php | 9 +++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index aeadee0f9f..6f5b9cfeed 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -31,9 +31,9 @@ if (! $glossary = get_record("glossary", "id", $cm->instance)) { } if ($CFG->dbtype == 'postgres7' ) { - $ucase = 'upper'; + $lcase = 'lower'; } else { - $ucase = 'ucase'; + $lcase = 'lcase'; } if (!$glossary->studentcanpost && !isteacher($glossary->course)) { @@ -132,7 +132,7 @@ if ( $confirm ) { $permissiongranted = 1; if ( !$glossary->allowduplicatedentries ) { - if ($dupentries = get_records("glossary_entries","$ucase(concept)", strtoupper($newentry->concept))) { + if ($dupentries = get_records("glossary_entries","$lcase(concept)", moodle_strtolower($newentry->concept))) { foreach ($dupentries as $curentry) { if ( $glossary->id == $curentry->glossaryid ) { if ( $curentry->id != $e ) { @@ -172,7 +172,7 @@ if ( $confirm ) { $permissiongranted = 1; if ( !$glossary->allowduplicatedentries ) { - if ($dupentries = get_record("glossary_entries","$ucase(concept)", strtoupper($newentry->concept), "glossaryid", $glossary->id)) { + if ($dupentries = get_record("glossary_entries","$lcase(concept)", moodle_strtolower($newentry->concept), "glossaryid", $glossary->id)) { $permissiongranted = 0; } } diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 88e9e0fdb6..6797bd9db5 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -24,9 +24,9 @@ } if ($CFG->dbtype == 'postgres7' ) { - $ucase = 'upper'; + $lcase = 'lower'; } else { - $ucase = 'ucase'; + $lcase = 'lcase'; } if ( !isteacher($cm->course) ) { @@ -63,7 +63,7 @@ } else { if ( ! $mainglossary->allowduplicatedentries ) { - $dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, $ucase.'(concept)',strtoupper(addslashes($entry->concept))); + $dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, $lcase.'(concept)',moodle_strtolower(addslashes($entry->concept))); if ( $dupentry ) { $PermissionGranted = 0; } diff --git a/mod/glossary/import.php b/mod/glossary/import.php index 0285eda2fd..dbd09c1e87 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -227,9 +227,9 @@ $dupentry = get_record("glossary_entries","concept",$newentry->concept,"glossaryid",$glossary->id); } else { if ($CFG->dbtype == 'postgres7') { - $dupentry = get_record("glossary_entries","upper(concept)",strtoupper($newentry->concept),"glossaryid",$glossary->id); + $dupentry = get_record("glossary_entries","lower(concept)",moodle_strtolower($newentry->concept),"glossaryid",$glossary->id); }else { - $dupentry = get_record("glossary_entries","ucase(concept)",strtoupper($newentry->concept),"glossaryid",$glossary->id); + $dupentry = get_record("glossary_entries","lcase(concept)",moodle_strtolower($newentry->concept),"glossaryid",$glossary->id); } } if ($dupentry) { diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 35ee04efa3..39582c9e8f 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -505,7 +505,7 @@ function glossary_get_entries_search($concept, $courseid) { $bypassteacher = 0; //This means YES } - $conceptupper = strtoupper(trim($concept)); + $conceptlower = moodle_strtolower(trim($concept)); return get_records_sql("SELECT e.*, g.name as glossaryname, cm.id as cmid, cm.course as courseid FROM {$CFG->prefix}glossary_entries e, @@ -518,7 +518,7 @@ function glossary_get_entries_search($concept, $courseid) { (cm.course = '$courseid' AND cm.visible = $bypassteacher)) AND g.id = cm.instance AND e.glossaryid = g.id AND - ( (e.casesensitive != 0 AND UPPER(concept) = '$conceptupper') OR + ( (e.casesensitive != 0 AND LOWER(concept) = '$conceptlower') OR (e.casesensitive = 0 and concept = '$concept')) AND (g.course = '$courseid' OR g.globalglossary = 1) AND e.usedynalink != 0 AND @@ -1495,9 +1495,10 @@ global $CFG; } function glossary_sort_entries ( $entry0, $entry1 ) { - if ( strtolower(ltrim($entry0->concept)) < strtolower(ltrim($entry1->concept)) ) { + + if ( moodle_strtolower(ltrim($entry0->concept)) < moodle_strtolower(ltrim($entry1->concept)) ) { return -1; - } elseif ( strtolower(ltrim($entry0->concept)) > strtolower(ltrim($entry1->concept)) ) { + } elseif ( moodle_strtolower(ltrim($entry0->concept)) > moodle_strtolower(ltrim($entry1->concept)) ) { return 1; } else { return 0; -- 2.39.5