Skip to content

Commit

Permalink
rating MDL-21657 switched from putting permissions in constants to us…
Browse files Browse the repository at this point in the history
…ing literal strings
  • Loading branch information
Andrew Davis committed Mar 18, 2010
1 parent 09fa5f0 commit bab7e00
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rating/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
}
$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');
}

Expand Down
10 changes: 3 additions & 7 deletions rating/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
* @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
Expand Down Expand Up @@ -282,9 +278,9 @@ public static function load_ratings($context, $items, $aggregate=RATING_AGGREGAT
$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) {
Expand Down
2 changes: 1 addition & 1 deletion rating/rate.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
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');
Expand Down

0 comments on commit bab7e00

Please sign in to comment.