mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-49985 core_enrol: direct user to appropriate URL
This commit is contained in:
parent
b3cb726431
commit
9542b15671
@ -26,6 +26,7 @@ require('../config.php');
|
||||
require_once("$CFG->libdir/formslib.php");
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);
|
||||
|
||||
if (!isloggedin()) {
|
||||
$referer = clean_param(get_referer(), PARAM_LOCALURL);
|
||||
@ -104,8 +105,14 @@ foreach ($forms as $form) {
|
||||
if (!$forms) {
|
||||
if (isguestuser()) {
|
||||
notice(get_string('noguestaccess', 'enrol'), get_login_url());
|
||||
} else if ($returnurl) {
|
||||
notice(get_string('notenrollable', 'enrol'), $returnurl);
|
||||
} else {
|
||||
notice(get_string('notenrollable', 'enrol'), "$CFG->wwwroot/index.php");
|
||||
$url = clean_param(get_referer(false), PARAM_LOCALURL);
|
||||
if (empty($url)) {
|
||||
$url = new moodle_url('/index.php');
|
||||
}
|
||||
notice(get_string('notenrollable', 'enrol'), $url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,9 @@ if (!empty($forum)) { // User is starting a new discussion in a forum
|
||||
if (enrol_selfenrol_available($course->id)) {
|
||||
$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' => '/mod/forum/view.php?f=' . $forum->id)),
|
||||
get_string('youneedtoenrol'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,7 +189,9 @@ 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' => '/mod/forum/view.php?f=' . $forum->id)),
|
||||
get_string('youneedtoenrol'));
|
||||
}
|
||||
}
|
||||
print_error('nopostforum', 'forum');
|
||||
|
Loading…
x
Reference in New Issue
Block a user