MDL-32888 Grader report: use SESSION object and DB functions
authorMelissa Aitkin <melissa.aitkin@latrobe.edu.au>
Tue, 20 Aug 2013 00:27:50 +0000 (10:27 +1000)
committerMelissa Aitkin <melissa.aitkin@latrobe.edu.au>
Thu, 17 Oct 2013 01:58:49 +0000 (12:58 +1100)
grade/report/grader/index.php
grade/report/grader/lib.php
grade/report/lib.php

index a62e808..810338f 100644 (file)
@@ -43,12 +43,12 @@ $toggle_type   = optional_param('toggle_type', 0, PARAM_ALPHANUM);
 $graderreportsifirst  = optional_param('sifirst', NULL, PARAM_ALPHA);
 $graderreportsilast   = optional_param('silast', NULL, PARAM_ALPHA);
 
-// The report object is recreated each time, save search information to USER object for future use.
+// The report object is recreated each time, save search information to SESSION object for future use.
 if (isset($graderreportsifirst)) {
-    $USER->filterfirstname = $graderreportsifirst; 
+    $SESSION->filterfirstname = $graderreportsifirst; 
 }  
 if (isset($graderreportsilast)) {
-    $USER->filtersurname = $graderreportsilast;
+    $SESSION->filtersurname = $graderreportsilast;
 } 
 
 $PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
@@ -153,8 +153,8 @@ echo $report->group_selector;
 
 // User search
 $url = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id));
-$firstinitial = isset($USER->filterfirstname) ? $USER->filterfirstname : '';
-$lastinitial  = isset($USER->filtersurname) ? $USER->filtersurname : '';
+$firstinitial = isset($SESSION->filterfirstname) ? $SESSION->filterfirstname : '';
+$lastinitial  = isset($SESSION->filtersurname) ? $SESSION->filtersurname : '';
 $totalusers = $report->get_numusers(true, false);
 $renderer = $PAGE->get_renderer('core_user');
 echo $renderer->user_search($url, $firstinitial, $lastinitial, $numusers, $totalusers, $report->currentgroupname);
index e5e3ba1..ed967dc 100644 (file)
@@ -158,7 +158,7 @@ class grade_report_grader extends grade_report {
     public function process_data($data) {
         global $DB;
         $warnings = array();
-        
+
         $separategroups = false;
         $mygroups       = array();
         if ($this->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $this->context)) {
index 4360df3..95e456e 100644 (file)
@@ -388,17 +388,17 @@ abstract class grade_report {
     }
 
     public function setup_users() {
-        global $USER;
+        global $SESSION, $DB;
         
         $this->userwheresql = "";
         $this->userwheresql_params = array();
-        if (isset($USER->filterfirstname) && !empty($USER->filterfirstname)) {
-            $this->userwheresql .= ' AND u.firstname ILIKE  :firstname ';
-            $this->userwheresql_params['firstname'] = $USER->filterfirstname.'%';
+        if (isset($SESSION->filterfirstname) && !empty($SESSION->filterfirstname)) {
+            $this->userwheresql .= ' AND '.$DB->sql_like('u.firstname', ':firstname', false, false);
+            $this->userwheresql_params['firstname'] = $SESSION->filterfirstname.'%';
         }
-        if (isset($USER->filtersurname) && !empty($USER->filtersurname)) {
-            $this->userwheresql .= ' AND u.lastname ILIKE  :lastname ';
-            $this->userwheresql_params['lastname'] = $USER->filtersurname.'%';
+        if (isset($SESSION->filtersurname) && !empty($SESSION->filtersurname)) {
+            $this->userwheresql .= ' AND '.$DB->sql_like('u.lastname', ':lastname', false, false);
+            $this->userwheresql_params['lastname'] = $SESSION->filtersurname.'%';
         }
     }