From ac9425c9938cb6202f8cecbcfef3b01a9d908960 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sun, 14 Sep 2014 20:49:16 +0800 Subject: [PATCH] MDL-47238 core_user: added an error message if guests access user profiles and they aren't allowed to --- lang/en/error.php | 1 + user/profile.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lang/en/error.php b/lang/en/error.php index 7bef32afe7a..82b3a01b9fc 100644 --- a/lang/en/error.php +++ b/lang/en/error.php @@ -262,6 +262,7 @@ $string['groupnotaddedtogroupingerror'] = 'Group "{$a->groupname}" not added to $string['groupingnotaddederror'] = 'Grouping "{$a}" not added'; $string['groupunknown'] = 'Group {$a} not associated to specified course'; $string['groupusernotmember'] = 'User is not member of this group.'; +$string['guestcantaccessprofiles'] = 'Guests cannot access user profiles. Log in with a full user account to continue.'; $string['guestnocomment'] = 'Guests are not allowed to post comments!'; $string['guestnoeditprofile'] = 'The guest user cannot edit their profile'; $string['guestnoeditprofileother'] = 'The guest user profile cannot be edited'; diff --git a/user/profile.php b/user/profile.php index 8b1bb5c8801..03db81f808f 100644 --- a/user/profile.php +++ b/user/profile.php @@ -49,7 +49,14 @@ if (!empty($CFG->forceloginforprofiles)) { require_login(); if (isguestuser()) { $SESSION->wantsurl = $PAGE->url->out(false); - redirect(get_login_url()); + + $PAGE->set_context(context_system::instance()); + echo $OUTPUT->header(); + echo $OUTPUT->confirm(get_string('guestcantaccessprofiles', 'error'), + get_login_url(), + $CFG->wwwroot); + echo $OUTPUT->footer(); + die; } } else if (!empty($CFG->forcelogin)) { require_login();