Skip to content
Permalink
Browse files

MDL-39209 badges: Fix course badges page access and navigation when c…

…ourse badges are disabled
  • Loading branch information...
Yuliya Bozhko
Yuliya Bozhko committed Apr 29, 2013
1 parent cf5a329 commit 85d7399e2041a07eeecb60097637a43f660f3d73
Showing with 40 additions and 11 deletions.
  1. +14 −10 badges/backpack.js
  2. +3 −0 badges/criteria.php
  3. +3 −0 badges/edit.php
  4. +4 −0 badges/index.php
  5. +4 −0 badges/newbadge.php
  6. +3 −0 badges/overview.php
  7. +3 −0 badges/recipients.php
  8. +4 −0 badges/view.php
  9. +1 −0 lang/en/badges.php
  10. +1 −1 lib/navigationlib.php
@@ -10,19 +10,23 @@ function addtobackpack(event, args) {
*/
function check_site_access() {
var add = Y.one('#check_connection');

var callback = {
success: function(o) {
var data = Y.JSON.parse(o.responseText);
if (data.code == 'http-unreachable') {
add.setHTML(data.response);
add.removeClass('hide');
method: "GET",
on: {
success: function(id, o, args) {
var data = Y.JSON.parse(o.responseText);
if (data.code == 'http-unreachable') {
add.setHTML(data.response);
add.removeClass('hide');
}
},
failure: function(o) { }
}
},
failure: function(o) { }
};
};

YUI().use('yui2-connection', function (Y) {
Y.YUI2.util.Connect.asyncRequest('GET', 'ajax.php', callback, null);
Y.use('io-base', function(Y) {
Y.io('ajax.php', callback);
});

return false;
@@ -41,6 +41,9 @@
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
if ($badge->type == BADGE_TYPE_COURSE) {
if (empty($CFG->badges_allowcoursebadges)) {
print_error('coursebadgesdisabled', 'badges');
}
require_login($badge->courseid);
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
}
@@ -44,6 +44,9 @@
require_capability('moodle/badges:configuredetails', $context);
if ($badge->type == BADGE_TYPE_COURSE) {
if (empty($CFG->badges_allowcoursebadges)) {
print_error('coursebadgesdisabled', 'badges');
}
require_login($badge->courseid);
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
}
@@ -56,6 +56,10 @@
print_error('badgesdisabled', 'badges');
}
if (empty($CFG->badges_allowcoursebadges) && ($type == BADGE_TYPE_COURSE)) {
print_error('coursebadgesdisabled', 'badges');
}
$err = '';
$urlparams = array('sort' => $sortby, 'dir' => $sorthow, 'page' => $page);
@@ -37,6 +37,10 @@
print_error('badgesdisabled', 'badges');
}
if (empty($CFG->badges_allowcoursebadges) && ($type == BADGE_TYPE_COURSE)) {
print_error('coursebadgesdisabled', 'badges');
}
$title = get_string('create', 'badges');
if (($type == BADGE_TYPE_COURSE) && ($course = $DB->get_record('course', array('id' => $courseid)))) {
@@ -41,6 +41,9 @@
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
if ($badge->type == BADGE_TYPE_COURSE) {
if (empty($CFG->badges_allowcoursebadges)) {
print_error('coursebadgesdisabled', 'badges');
}
require_login($badge->courseid);
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
}
@@ -56,6 +56,9 @@
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
if ($badge->type == BADGE_TYPE_COURSE) {
if (empty($CFG->badges_allowcoursebadges)) {
print_error('coursebadgesdisabled', 'badges');
}
require_login($badge->courseid);
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
}
@@ -39,6 +39,10 @@
print_error('badgesdisabled', 'badges');
}
if (empty($CFG->badges_allowcoursebadges) && $courseid != 0) {
print_error('coursebadgesdisabled', 'badges');
}
if (!in_array($sortby, array('name', 'dateissued'))) {
$sortby = 'name';
}
@@ -131,6 +131,7 @@
$string['contact'] = 'Contact';
$string['contact_help'] = 'An email address associated with the badge issuer.';
$string['copyof'] = 'Copy of {$a}';
$string['coursebadgesdisabled'] = 'Course badges are not enabled on this site.';
$string['coursecompletion'] = 'Learners must complete this course. ';
$string['coursebadges'] = 'Badges';
$string['create'] = 'New badge';
@@ -2498,7 +2498,7 @@ public function add_front_page_course_essentials(navigation_node $coursenode, st
}
//Badges
if (!empty($CFG->enablebadges) && has_capability('moodle/badges:viewbadges', $this->page->context)) {
if (!empty($CFG->enablebadges) && !empty($CFG->badges_allowcoursebadges) && has_capability('moodle/badges:viewbadges', $this->page->context)) {
$url = new moodle_url($CFG->wwwroot . '/badges/view.php', array('type' => 1));
$coursenode->add(get_string('sitebadges', 'badges'), $url, navigation_node::TYPE_CUSTOM);
}

0 comments on commit 85d7399

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