MDL-47869 tool_monitor: Add sorting on event monitor pages
authorSimey Lameze <simey@moodle.com>
Wed, 5 Nov 2014 05:34:40 +0000 (13:34 +0800)
committerSimey Lameze <simey@moodle.com>
Thu, 6 Nov 2014 06:53:10 +0000 (14:53 +0800)
admin/tool/monitor/classes/output/managesubs/rules.php
admin/tool/monitor/classes/rule_manager.php
admin/tool/monitor/classes/subscription_manager.php

index 7014a35..b298abf 100644 (file)
@@ -214,9 +214,9 @@ class rules extends \table_sql implements \renderable {
         if ($numcourses > COURSE_MAX_COURSES_PER_DROPDOWN) {
             return false;
         }
-
+        $orderby = 'visible DESC, sortorder ASC';
         $options = array(0 => get_string('site'));
-        if ($courses = get_user_capability_course('tool/monitor:subscribe', null, true, 'fullname')) {
+        if ($courses = get_user_capability_course('tool/monitor:subscribe', null, true, 'fullname', $orderby)) {
             foreach ($courses as $course) {
                 $options[$course->id] = format_string($course->fullname, true,
                     array('context' => \context_course::instance($course->id)));
index b0c60e0..c93f76b 100644 (file)
@@ -222,8 +222,9 @@ class rule_manager {
     public static function get_rules_by_courseid($courseid, $limitfrom = 0, $limitto = 0) {
         global $DB;
         $select = "courseid = ? OR courseid = ?";
-        return self::get_instances($DB->get_records_select('tool_monitor_rules', $select, array(0, $courseid), null, '*',
-                $limitfrom, $limitto));
+        $orderby = "courseid DESC, name ASC";
+        return self::get_instances($DB->get_records_select('tool_monitor_rules', $select, array(0, $courseid), $orderby,
+                '*', $limitfrom, $limitto));
     }
 
     /**
index 1ecf565..81fdc37 100644 (file)
@@ -280,7 +280,7 @@ class subscription_manager {
      * @return array list of subscriptions
      */
     public static function get_user_subscriptions($limitfrom = 0, $limitto = 0, $userid = 0,
-                                                             $order = 's.timecreated DESC' ) {
+                                                             $order = 's.courseid ASC, r.name' ) {
         global $DB, $USER;
         if ($userid == 0) {
             $userid = $USER->id;