Skip to content

Commit

Permalink
Now lcase() and ucase() are out from glossary
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Oct 30, 2006
1 parent a91960b commit 0db5683
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
10 changes: 2 additions & 8 deletions mod/glossary/edit.php
Expand Up @@ -32,12 +32,6 @@
error("Course module is incorrect");
}

if ($CFG->dbtype == 'postgres7' ) {
$lcase = 'lower';
} else {
$lcase = 'lcase';
}

if ($e) { // if entry is sepcified
require_capability('mod/glossary:manageentries', $context);
} else { // new entry
Expand Down Expand Up @@ -139,7 +133,7 @@

$permissiongranted = 1;
if ( !$glossary->allowduplicatedentries ) {
if ($dupentries = get_records("glossary_entries","$lcase(concept)", moodle_strtolower($newentry->concept))) {
if ($dupentries = get_records("glossary_entries","lower(concept)", moodle_strtolower($newentry->concept))) {
foreach ($dupentries as $curentry) {
if ( $glossary->id == $curentry->glossaryid ) {
if ( $curentry->id != $e ) {
Expand Down Expand Up @@ -179,7 +173,7 @@

$permissiongranted = 1;
if ( !$glossary->allowduplicatedentries ) {
if ($dupentries = get_record("glossary_entries","$lcase(concept)", moodle_strtolower($newentry->concept), "glossaryid", $glossary->id)) {
if ($dupentries = get_record("glossary_entries","lower(concept)", moodle_strtolower($newentry->concept), "glossaryid", $glossary->id)) {
$permissiongranted = 0;
}
}
Expand Down
8 changes: 1 addition & 7 deletions mod/glossary/exportentry.php
Expand Up @@ -23,12 +23,6 @@
}
}

if ($CFG->dbtype == 'postgres7' ) {
$lcase = 'lower';
} else {
$lcase = 'lcase';
}

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/glossary:export', $context);

Expand Down Expand Up @@ -61,7 +55,7 @@

} else {
if ( ! $mainglossary->allowduplicatedentries ) {
$dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, $lcase.'(concept)',moodle_strtolower(addslashes($entry->concept)));
$dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, 'lower(concept)',moodle_strtolower(addslashes($entry->concept)));
if ( $dupentry ) {
$PermissionGranted = 0;
}
Expand Down
6 changes: 1 addition & 5 deletions mod/glossary/import.php
Expand Up @@ -226,11 +226,7 @@
if ( $newentry->casesensitive ) {
$dupentry = get_record("glossary_entries","concept",$newentry->concept,"glossaryid",$glossary->id);
} else {
if ($CFG->dbtype == 'postgres7') {
$dupentry = get_record("glossary_entries","lower(concept)",moodle_strtolower($newentry->concept),"glossaryid",$glossary->id);
}else {
$dupentry = get_record("glossary_entries","lcase(concept)",moodle_strtolower($newentry->concept),"glossaryid",$glossary->id);
}
$dupentry = get_record("glossary_entries","lower(concept)",moodle_strtolower($newentry->concept),"glossaryid",$glossary->id);
}
if ($dupentry) {
$permissiongranted = 0;
Expand Down
8 changes: 4 additions & 4 deletions mod/glossary/sql.php
Expand Up @@ -95,7 +95,7 @@
} else {
$usernamefield = sql_fullname('u.lastname' , 'u.firsttname');
}
$where = "AND left(ucase($usernamefield)," . $textlib->strlen($hook, current_charset()) . ") = '$hook'";
$where = "AND left(upper($usernamefield)," . $textlib->strlen($hook, current_charset()) . ") = '$hook'";
break;
}
if ( $hook == 'ALL' ) {
Expand All @@ -121,7 +121,7 @@
$where = 'AND substr(upper(concept),1,' . $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
break;
case 'mysql':
$where = 'AND left(ucase(concept),' . $textlib->strlen($hook, current_charset()) . ") = '$hook'";
$where = 'AND left(upper(concept),' . $textlib->strlen($hook, current_charset()) . ") = '$hook'";
break;
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@
$where = 'AND substr(upper(concept),1,' . $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
break;
case 'mysql':
$where = 'AND left(ucase(concept),' . $textlib->strlen($hook, current_charset()) . ") = '" . $textlib->strtoupper($hook, current_charset()) . "'";
$where = 'AND left(upper(concept),' . $textlib->strlen($hook, current_charset()) . ") = '" . $textlib->strtoupper($hook, current_charset()) . "'";
break;
}
}
Expand All @@ -270,7 +270,7 @@
$where = 'AND substr(upper(concept),1,1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
break;
case 'mysql':
$where = 'AND left(ucase(concept),1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
$where = 'AND left(upper(concept),1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
break;
}
}
Expand Down

0 comments on commit 0db5683

Please sign in to comment.