MDL-18309 Course: enrol/index.php returnurl improvement

This patch improves usability of enrolment page in case of course is not
enrollable. 'Continue' button now returns student to referring page instead of
main moodle page (as it used to be). To make this improvement, passing correct
returnurl parameter to enrol/index.php page was implemented for links that may
be accessible for not-enrolled students.
This commit is contained in:
Gregory Zbitnev
2015-04-10 09:32:31 +08:00
committed by Marina Glancy
parent d7551257a0
commit 6601690202
17 changed files with 55 additions and 12 deletions
+3 -1
View File
@@ -186,7 +186,9 @@ if (!$choiceformshown) {
echo $OUTPUT->box_start('generalbox', 'notice');
echo '<p align="center">'. get_string('notenrolledchoose', 'choice') .'</p>';
echo $OUTPUT->container_start('continuebutton');
echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?', array('id'=>$course->id)), get_string('enrolme', 'core_enrol', $courseshortname));
echo $OUTPUT->single_button(new moodle_url('/enrol/index.php?',
array('id' => $course->id, 'returnurl' => $PAGE->url)),
get_string('enrolme', 'core_enrol', $courseshortname));
echo $OUTPUT->container_end();
echo $OUTPUT->box_end();
+6 -1
View File
@@ -187,7 +187,12 @@ if (!empty($forum)) { // User is starting a new discussion in a forum
if (!is_enrolled($coursecontext)) { // User is a guest here!
$SESSION->wantsurl = qualified_me();
$SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
redirect($CFG->wwwroot.'/enrol/index.php?id='.$course->id, get_string('youneedtoenrol'));
redirect(new moodle_url('/enrol/index.php', array(
'id' => $course->id,
'returnurl' => new moodle_url('/mod/forum/view.php',
array('f' => $forum->id))
)),
get_string('youneedtoenrol'));
}
}
print_error('nopostforum', 'forum');