rating MDL-21657 switched from putting permissions in constants to using literal...
authorAndrew Davis <andrew@affinitysoftware.net>
Thu, 18 Mar 2010 08:59:10 +0000 (08:59 +0000)
committerAndrew Davis <andrew@affinitysoftware.net>
Thu, 18 Mar 2010 08:59:10 +0000 (08:59 +0000)
rating/index.php
rating/lib.php
rating/rate.php

index 96ffa75..20dae50 100644 (file)
@@ -40,10 +40,10 @@ if ($sort !== 0) {
 }
 $PAGE->set_url($url);
 
-if ( !has_capability(RATING_VIEW,$context) ) {
+if ( !has_capability('moodle/rating:view',$context) ) {
     print_error('noviewrate', 'rating');
 }
-if ( !has_capability(RATING_VIEW,$context) and $USER->id != $item->userid) {
+if ( !has_capability('moodle/rating:viewall',$context) and $USER->id != $item->userid) {
     print_error('noviewanyrate', 'rating');
 }
 
index e405ae7..1815794 100644 (file)
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-define('RATING_VIEW','moodle/rating:view');
-define('RATING_VIEW_ALL','moodle/rating:viewall');
-define('RATING_RATE','moodle/rating:rate');
-
 define('RATING_UNSET_RATING', -999);
 
 //define ('RATING_AGGREGATE_NONE', 0); //no ratings
@@ -282,9 +278,9 @@ class rating implements renderable {
         $settings->returnurl = $returnurl;
 
         $settings->permissions = new stdclass();
-        $settings->permissions->canview = has_capability(RATING_VIEW,$context);
-        $settings->permissions->canviewall = has_capability(RATING_VIEW_ALL,$context);
-        $settings->permissions->canrate = has_capability(RATING_RATE,$context);
+        $settings->permissions->canview = has_capability('moodle/rating:view',$context);
+        $settings->permissions->canviewall = has_capability('moodle/rating:viewall',$context);
+        $settings->permissions->canrate = has_capability('moodle/rating:rate',$context);
 
         $rating = null;
         foreach($items as $item) {
index 66d4526..f0f2aa0 100644 (file)
@@ -48,7 +48,7 @@ if( !isloggedin() && !$returnurl ){ //session has expired and its an ajax reques
 list($context, $course, $cm) = get_context_info_array($contextid);
 require_login($course, false, $cm);
 
-if( !has_capability(RATING_RATE,$context) ) {
+if( !has_capability('moodle/rating:rate',$context) ) {
     if( $returnurl ) { //if its a non-ajax request
         echo $OUTPUT->header();
         echo get_string('ratepermissiondenied', 'ratings');