diff --git a/badges/mybadges.php b/badges/mybadges.php index d944e736beb..4fee85d916d 100644 --- a/badges/mybadges.php +++ b/badges/mybadges.php @@ -42,7 +42,14 @@ if (empty($CFG->enablebadges)) { print_error('badgesdisabled', 'badges'); } +$url = new moodle_url('/badges/mybadges.php'); +$PAGE->set_url($url); + if (isguestuser()) { + $PAGE->set_context(context_system::instance()); + echo $OUTPUT->header(); + echo $OUTPUT->box(get_string('error:guestuseraccess', 'badges'), 'notifyproblem'); + echo $OUTPUT->footer(); die(); } @@ -80,9 +87,6 @@ if ($hide) { $context = context_user::instance($USER->id); require_capability('moodle/badges:manageownbadges', $context); -$url = new moodle_url('/badges/mybadges.php'); - -$PAGE->set_url($url); $PAGE->set_context($context); $title = get_string('mybadges', 'badges'); diff --git a/lang/en/badges.php b/lang/en/badges.php index 9ad8f9ed1ac..e0c2bff64d0 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -223,6 +223,7 @@ $string['error:connectionunknownreason'] = 'The connection was unsuccessful but $string['error:clone'] = 'Cannot clone the badge.'; $string['error:duplicatename'] = 'Badge with such name already exists in the system.'; $string['error:externalbadgedoesntexist'] = 'Badge not found'; +$string['error:guestuseraccess'] = 'You are currently using guest access. To see badges you need to login with your user account.'; $string['error:invalidbadgeurl'] = 'Invalid badge issuer URL format.'; $string['error:invalidcriteriatype'] = 'Invalid criteria type.'; $string['error:invalidexpiredate'] = 'Expiry date has to be in the future.';