Skip to content
Permalink
Browse files

MDL-47190 Ensure badges cannot be awarded without a role

Signed-off-by: Yuliya Bozhko <yuliya.bozhko@totaralms.com>
  • Loading branch information...
Yuliya Bozhko Sam Hemelryk
Yuliya Bozhko authored and Sam Hemelryk committed Oct 28, 2014
1 parent 6ec47a6 commit 5a56067bb8a94e3f68bc0a75d2ea73d83a6fb3ed
Showing with 13 additions and 0 deletions.
  1. +8 −0 badges/award.php
  2. +5 −0 badges/criteria/award_criteria_manual.php
@@ -78,6 +78,14 @@
// Roles that can award this badge.
$acceptedroles = array_keys($badge->criteria[BADGE_CRITERIA_TYPE_MANUAL]->params);
if (empty($acceptedroles)) {
echo $OUTPUT->header();
$return = html_writer::link(new moodle_url('recipients.php', array('id' => $badge->id)), $strrecipients);
echo $OUTPUT->notification(get_string('notacceptedrole', 'badges', $return));
echo $OUTPUT->footer();
die();
}
if (count($acceptedroles) > 1) {
// If there is more than one role that can award a badge, prompt user to make a selection.
// If it is an admin, include all accepted roles, otherwise only the ones that current user has in this context.
@@ -147,6 +147,11 @@ public function get_details($short = '') {
public function review($userid) {
global $DB;
// Roles should always have a parameter.
if (empty($this->params)) {
return false;
}
$overall = false;
foreach ($this->params as $param) {
$crit = $DB->get_record('badge_manual_award', array('issuerrole' => $param['role'], 'recipientid' => $userid, 'badgeid' => $this->badgeid));

0 comments on commit 5a56067

Please sign in to comment.
You can’t perform that action at this time.