]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14018 fixed searching when date order selected; merged from MODOLE_19_STABLE
authorskodak <skodak>
Wed, 16 Apr 2008 15:08:03 +0000 (15:08 +0000)
committerskodak <skodak>
Wed, 16 Apr 2008 15:08:03 +0000 (15:08 +0000)
mod/data/view.php

index ffdf8a9e8c7dd6a063881d9a00f6a410a208c6da..fefc0130da87c0eea54b444c29441720a49ee209 100755 (executable)
         }
 
     /// Find the field we are sorting on
-        if ($sort == DATA_FIRSTNAME or $sort == DATA_LASTNAME) {
+        if ($sort == DATA_FIRSTNAME or $sort == DATA_LASTNAME or empty($sort)) {
 
-            if ($sort ==  DATA_LASTNAME) {
+            if ($sort == DATA_LASTNAME) {
                 $ordering = "u.lastname $order, u.firstname $order";
-            } else {
+            } else if ($sort == DATA_LASTNAME) {
                 $ordering = "u.firstname $order, u.lastname $order";
+            } else {
+                $ordering = "r.timecreated $order";
             }
 
             $what = ' DISTINCT r.id, r.approved, r.timecreated, r.timemodified, r.userid, u.firstname, u.lastname';
                 $searchselect = ' ';
             }
 
-        } else if ($sort and $sortfield = data_get_field_from_id($sort, $data)) {
+        } else if ($sort > 0 and $sortfield = data_get_field_from_id($sort, $data)) {
 
             $sortcontent = $sortfield->get_sort_field();
             $sortcontentfull = $sortfield->get_sort_sql('c.'.$sortcontent);