From: paca70 Date: Fri, 22 Oct 2004 17:03:37 +0000 (+0000) Subject: Some fixes for postgresql X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=67db6177de3254ce2aa59557422039a18a9eccad;p=moodle.git Some fixes for postgresql --- diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 94763eb8cb..e3e958de37 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -33,6 +33,12 @@ if (! $glossary = get_record("glossary", "id", $cm->instance)) { error("Course module is incorrect"); } +if ($CFG->dbtype == 'postgres7' ) { + $ucase = 'upper'; +} else { + $ucase = 'ucase'; +} + if (!$glossary->studentcanpost && !isteacher($glossary->course)) { error("You can't add/edit entries to this glossary!"); } @@ -115,7 +121,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","$ucase(concept)", strtoupper($newentry->concept))) { foreach ($dupentries as $curentry) { if ( $glossary->id == $curentry->glossaryid ) { if ( $curentry->id != $e ) { @@ -153,7 +159,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","$ucase(concept)", strtoupper($newentry->concept), "glossaryid", $glossary->id)) { $permissiongranted = 0; } } diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 5bca160547..aa21966eca 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -24,6 +24,12 @@ $PermissionGranted = 0; } } + + if ($CFG->dbtype == 'postgres7' ) { + $ucase = 'upper'; + } else { + $ucase = 'ucase'; + } if ( !isteacher($cm->course) ) { $PermissionGranted = 0; @@ -59,7 +65,7 @@ } else { if ( ! $mainglossary->allowduplicatedentries ) { - $dupentry = get_record("glossary_entries","glossaryid", $mainglossary->id, "UCASE(concept)",strtoupper($entry->concept)); + $dupentry = get_record("glossary_entries","glossaryid", $mainglossary->id, "$ucase(concept)",strtoupper($entry->concept)); if ( $dupentry ) { $PermissionGranted = 0; } diff --git a/mod/glossary/import.php b/mod/glossary/import.php index 32fa5ad454..8f8a42753a 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -222,7 +222,11 @@ if ( $newentry->casesensitive ) { $dupentry = get_record("glossary_entries","concept",$newentry->concept,"glossaryid",$glossary->id); } else { - $dupentry = get_record("glossary_entries","ucase(concept)",strtoupper($newentry->concept),"glossaryid",$glossary->id); + if ($CFG->dbtype == 'postgres7') { + $dupentry = get_record("glossary_entries","upper(concept)",strtoupper($newentry->concept),"glossaryid",$glossary->id); + }else { + $dupentry = get_record("glossary_entries","ucase(concept)",strtoupper($newentry->concept),"glossaryid",$glossary->id); + } } if ($dupentry) { $permissiongranted = 0; diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index 3f01430213..674c486b7c 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -94,7 +94,7 @@ } else { $usernamefield = "u.lastname || ' ' || u.firstname"; } - $where = "AND substr(ucase($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'"; + $where = "AND substr(upper($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'"; break; case 'mysql': if ( $sqlsortkey == 'FIRSTNAME' ) { @@ -129,7 +129,7 @@ if ($hook != 'ALL' and $hook != 'SPECIAL') { switch ($CFG->dbtype) { case 'postgres7': - $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; + $where = 'AND substr(upper(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; break; case 'mysql': $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'"; @@ -189,7 +189,7 @@ if ($hook != 'ALL' and $hook != 'SPECIAL') { switch ($CFG->dbtype) { case 'postgres7': - $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; + $where = 'AND substr(upper(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; break; case 'mysql': $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '" . strtoupper($hook) . "'"; @@ -208,7 +208,7 @@ } switch ($CFG->dbtype) { case 'postgres7': - $where = 'AND substr(ucase(concept),1,1) NOT IN (' . strtoupper($sqlalphabet) . ')'; + $where = 'AND substr(upper(concept),1,1) NOT IN (' . strtoupper($sqlalphabet) . ')'; break; case 'mysql': $where = 'AND left(ucase(concept),1) NOT IN (' . strtoupper($sqlalphabet) . ')';