rating MDL-21657 added aliasing and unaliasing of the fields returned by user_picture...
authorAndrew Davis <andrew@affinitysoftware.net>
Thu, 18 Mar 2010 08:12:13 +0000 (08:12 +0000)
committerAndrew Davis <andrew@affinitysoftware.net>
Thu, 18 Mar 2010 08:12:13 +0000 (08:12 +0000)
rating/index.php
rating/lib.php

index f9b88c7..412ae8c 100644 (file)
@@ -78,7 +78,13 @@ if (!$ratings) {
     echo "<th class=\"header\" scope=\"col\" style=\"width:100%\"><a href=\"report.php?id=$itemid&amp;sort=rating\">$strrating</a></th>";
     echo "<th class=\"header\" scope=\"col\"><a href=\"report.php?id=$itemid&amp;sort=time\">$strtime</a></th>";
     echo "</tr>";
+    $user = null;
     foreach ($ratings as $rating) {
+        //undo the aliasing necessary for user_picture::fields
+        $user = clone($rating);//could get away with just overwriting rating->id and not cloning
+        //the rating object as we don't use rating->id again. That just seems like a bad idea.
+        $user->id = $user->uid;
+        
         echo '<tr class="ratingitemheader">';
         echo "<td>";
         if($course && $course->id) {
index ac368ec..e405ae7 100644 (file)
@@ -183,7 +183,7 @@ class rating implements renderable {
     public static function load_ratings_for_item($context, $itemid, $sort) {
         global $DB;
 
-        $userfields = user_picture::fields('u');
+        $userfields = user_picture::fields('u','uid');
         $sql = "SELECT r.id, r.rating, r.itemid, r.userid, r.timemodified,
                     $userfields
                 FROM {rating} r