Skip to content
Snippets Groups Projects
Commit de353049 authored by Kathrin Osswald's avatar Kathrin Osswald Committed by Alexander Bias
Browse files

Improved the feature showhintcourseguestaccess to not be shown in some edge cases.

parent dc8a1e0a
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ Changes ...@@ -6,6 +6,7 @@ Changes
### Unreleased ### Unreleased
* 2018-12-19 - Improved the feature showhintcourseguestaccess to not be shown in some edge cases.
* 2018-12-18 - Adding 'both' option for 'Switch to role…' menu fixes - Many thanks to Luca Bösch (lucaboesch) for his proposal and main work on this! * 2018-12-18 - Adding 'both' option for 'Switch to role…' menu fixes - Many thanks to Luca Bösch (lucaboesch) for his proposal and main work on this!
* 2018-12-17 - Setting to change the breakpoint for smaller screens. * 2018-12-17 - Setting to change the breakpoint for smaller screens.
......
...@@ -213,10 +213,14 @@ class core_renderer extends \theme_boost\output\core_renderer { ...@@ -213,10 +213,14 @@ class core_renderer extends \theme_boost\output\core_renderer {
// MODIFICATION START: // MODIFICATION START:
// If the setting showhintcourseguestaccess is set, a hint for users that view the course with guest access is shown. // If the setting showhintcourseguestaccess is set, a hint for users that view the course with guest access is shown.
// We also check that the user did not switch the role. This is a special case for roles that can fully access the course
// without being enrolled. A role switch would show the guest access hint additionally in that case and this is not
// intended.
if (get_config('theme_boost_campus', 'showhintcourseguestaccess') == 'yes' if (get_config('theme_boost_campus', 'showhintcourseguestaccess') == 'yes'
&& is_guest(\context_course::instance($COURSE->id), $USER->id) && is_guest(\context_course::instance($COURSE->id), $USER->id)
&& $PAGE->has_set_url() && $PAGE->has_set_url()
&& $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) { && $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)
&& !is_role_switched($COURSE->id)) {
$html .= html_writer::start_tag('div', array('class' => 'course-guestaccess-infobox alert alert-warning')); $html .= html_writer::start_tag('div', array('class' => 'course-guestaccess-infobox alert alert-warning'));
$html .= html_writer::tag('i', null, array('class' => 'fa fa-exclamation-circle fa-3x fa-pull-left')); $html .= html_writer::tag('i', null, array('class' => 'fa fa-exclamation-circle fa-3x fa-pull-left'));
$html .= get_string('showhintcourseguestaccessgeneral', 'theme_boost_campus', $html .= get_string('showhintcourseguestaccessgeneral', 'theme_boost_campus',
...@@ -229,14 +233,12 @@ class core_renderer extends \theme_boost\output\core_renderer { ...@@ -229,14 +233,12 @@ class core_renderer extends \theme_boost\output\core_renderer {
// MODIFICATION START. // MODIFICATION START.
// Only use this if setting 'showswitchedroleincourse' is active. // Only use this if setting 'showswitchedroleincourse' is active.
if (get_config('theme_boost_campus', 'showswitchedroleincourse') === 'yes') { if (get_config('theme_boost_campus', 'showswitchedroleincourse') === 'yes') {
// Check if user is logged in. // Check if the user did a role switch.
// If not, adding this section would make no sense and, even worse, // If not, adding this section would make no sense and, even worse,
// user_get_user_navigation_info() will throw an exception due to the missing user object. // user_get_user_navigation_info() will throw an exception due to the missing user object.
if (isloggedin()) { if (is_role_switched($COURSE->id)) {
$opts = \user_get_user_navigation_info($USER, $this->page);
// Role is switched.
if (!empty($opts->metadata['asotherrole'])) {
// Get the role name switched to. // Get the role name switched to.
$opts = \user_get_user_navigation_info($USER, $this->page);
$role = $opts->metadata['rolename']; $role = $opts->metadata['rolename'];
// Get the URL to switch back (normal role). // Get the URL to switch back (normal role).
$url = new moodle_url('/course/switchrole.php', $url = new moodle_url('/course/switchrole.php',
...@@ -257,7 +259,6 @@ class core_renderer extends \theme_boost\output\core_renderer { ...@@ -257,7 +259,6 @@ class core_renderer extends \theme_boost\output\core_renderer {
$html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('div');
} }
} }
}
// MODIFICATION END. // MODIFICATION END.
return $html; return $html;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment