]> git.mjollnir.org Git - moodle.git/commitdiff
Fix a problem with glossary not being able to sort by firstname.
authorstronk7 <stronk7>
Sat, 24 Mar 2007 00:58:43 +0000 (00:58 +0000)
committerstronk7 <stronk7>
Sat, 24 Mar 2007 00:58:43 +0000 (00:58 +0000)
Merged from MOODLE_18_STABLE

mod/glossary/sql.php

index 7f59a5587eb935f8452ada2b91d1521f7f072559..75279803fdb35f613d4016168253ca73a2fefe36 100644 (file)
     $sqlsortkey = NULL;
     $textlib = textlib_get_instance();
 
+/// Calculate the SQL sortkey to be used by the SQL statements later
+    switch ( $sortkey ) {    
+        case "CREATION": 
+            $sqlsortkey = "timecreated";
+            break;
+        case "UPDATE": 
+            $sqlsortkey = "timemodified";
+            break;
+        case "FIRSTNAME": 
+            $sqlsortkey = "firstname";
+            break;
+        case "LASTNAME": 
+            $sqlsortkey = "lastname";
+            break;
+    }
+    $sqlsortorder = $sortorder;
+
 /// Pivot is the field that set the break by groups (category, initial, author name, etc)
 
 /// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter
 /// printpivot indicate if the pivot should be printed or not
 
-    switch ( $sortkey ) {    
-    case "CREATION": 
-        $sqlsortkey = "timecreated";
-    break;
-    
-    case "UPDATE": 
-        $sqlsortkey = "timemodified";
-    break;
-    }
-    $sqlsortorder = $sortorder;
-
     $fullpivot = 1;
 
     $userid = '';
@@ -80,7 +86,7 @@
 
         $where = '';
 
-        if ( $sqlsortkey == 'FIRSTNAME' ) {
+        if ( $sqlsortkey == 'firstname' ) {
             $usernamefield = sql_fullname('u.firstname' , 'u.lastname');
         } else {
             $usernamefield = sql_fullname('u.lastname' , 'u.firstname');