MDL-43978 badges: Display error message to guest users viewing "My Badges" page

This commit is contained in:
Yuliya Bozhko 2014-02-05 09:52:32 +13:00
parent 183515da23
commit a2a114bd6a
2 changed files with 8 additions and 3 deletions

View File

@ -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');

View File

@ -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.';