]> git.mjollnir.org Git - moodle.git/commitdiff
Some fixes for postgresql
authorpaca70 <paca70>
Fri, 22 Oct 2004 17:03:37 +0000 (17:03 +0000)
committerpaca70 <paca70>
Fri, 22 Oct 2004 17:03:37 +0000 (17:03 +0000)
mod/glossary/edit.php
mod/glossary/exportentry.php
mod/glossary/import.php
mod/glossary/sql.php

index 94763eb8cba5533155cbf7190b980e6bb592bfbc..e3e958de37e4f1eeee86a84fee5ba574158d477d 100644 (file)
@@ -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;
             }
         }
index 5bca16054759036956c2f3140f7d9b4644a56890..aa21966eca89e998a85d33587923939f35422d76 100644 (file)
             $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;
                 }
index 32fa5ad454b517c0f59dc4737f726b53b296c7a0..8f8a42753ad8ffc88419d76843cc493e4631de4f 100644 (file)
                     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;
index 3f014302134fe44373c4f000ef3aee672a7d9d64..674c486b7cdd0394e03f7feffa5022f749838049 100644 (file)
@@ -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' ) {
         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'";
             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) . "'";
                 }
                 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) . ')';