From 666ab4becbb846c40d2a0ce21c1002e7cc55dca4 Mon Sep 17 00:00:00 2001 From: Yuliya Bozhko Date: Wed, 5 Feb 2014 10:00:50 +1300 Subject: [PATCH 1/2] MDL-43978 badges: Display error message to guest users viewing "My Badges" page --- badges/mybadges.php | 10 +++++++--- lang/en/badges.php | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) 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 767a90093d2..c2f44cecec1 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -217,6 +217,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.'; From 0fc6693dd13e735f635dcc8662cbdc0049d1c4d9 Mon Sep 17 00:00:00 2001 From: Yuliya Bozhko Date: Fri, 7 Feb 2014 09:10:09 +1300 Subject: [PATCH 2/2] MDL-43978 badges: Fix lang string --- lang/en/badges.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/badges.php b/lang/en/badges.php index c2f44cecec1..59da329445a 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -217,7 +217,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:guestuseraccess'] = 'You are currently using guest access. To see badges you need to log in 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.';