From 66c34e9cf45b1282f6b2bb77c6dc0d372d062f62 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Tue, 17 Aug 2010 03:42:41 +0000 Subject: [PATCH] rating MDL-23805 reworked the logic around displaying rating aggregates to make it clearer --- lib/outputrenderers.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index c1ef9d2c8e3..67fd19cb31c 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1321,11 +1321,20 @@ class core_renderer extends renderer_base { $ratinghtml = ''; //the string we'll return //permissions check - can they view the aggregate? - if ( ($rating->itemuserid==$USER->id - && $rating->settings->permissions->view && $rating->settings->pluginpermissions->view) - || ($rating->itemuserid!=$USER->id - && $rating->settings->permissions->viewany && $rating->settings->pluginpermissions->viewany) ) { + $canviewaggregate = false; + //if its the current user's item and they have permission to view the aggregate on their own items + if ( $rating->itemuserid==$USER->id && $rating->settings->permissions->view && $rating->settings->pluginpermissions->view) { + $canviewaggregate = true; + } + + //if the item doesnt belong to anyone or its another user's items and they can see the aggregate on items they don't own + //Note that viewany doesnt mean you can see the aggregate or ratings of your own items + if ( (empty($rating->itemuserid) or $rating->itemuserid!=$USER->id) && $rating->settings->permissions->viewany && $rating->settings->pluginpermissions->viewany ) { + $canviewaggregate = true; + } + + if ($canviewaggregate==true) { $aggregatelabel = ''; switch ($rating->settings->aggregationmethod) { case RATING_AGGREGATE_AVERAGE :