MDL-62209 tool_dataprivacy: Sort requests by ascending status
authorJun Pataleta <jun@moodle.com>
Thu, 26 Apr 2018 04:17:24 +0000 (12:17 +0800)
committerJun Pataleta <jun@moodle.com>
Thu, 26 Apr 2018 04:17:24 +0000 (12:17 +0800)
Sort requests by ascending status and request date so that the DPO
can go through the list in a FIFO fashion

admin/tool/dataprivacy/classes/api.php

index 9ec5f45..09583b2 100644 (file)
@@ -220,6 +220,7 @@ class api {
     public static function get_data_requests($userid = 0) {
         global $USER;
         $results = [];
+        $sort = 'status ASC, timemodified ASC';
         if ($userid) {
             // Get the data requests for the user or data requests made by the user.
             $select = "userid = :userid OR requestedby = :requestedby";
@@ -227,11 +228,11 @@ class api {
                 'userid' => $userid,
                 'requestedby' => $userid
             ];
-            $results = data_request::get_records_select($select, $params, 'status DESC, timemodified DESC');
+            $results = data_request::get_records_select($select, $params, $sort);
         } else {
             // If the current user is one of the site's Data Protection Officers, then fetch all data requests.
             if (self::is_site_dpo($USER->id)) {
-                $results = data_request::get_records(null, 'status DESC, timemodified DESC', '');
+                $results = data_request::get_records(null, $sort, '');
             }
         }