mirror of
https://github.com/moodle/moodle.git
synced 2025-04-17 14:35:29 +02:00
MDL-23616 extremely messy hack to work around weird course handling resulting in unknown PAGE->context
This commit is contained in:
parent
44388c41f5
commit
ca74470c8d
@ -50,10 +50,11 @@ $event = calendar_event::load($eventid);
|
||||
*/
|
||||
if ($event->eventtype !== 'user' && $event->eventtype !== 'site') {
|
||||
$courseid = $event->courseid;
|
||||
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
} else {
|
||||
require_login();
|
||||
}
|
||||
$course = $DB->get_record('course', array('id'=>$courseid));
|
||||
require_login($course);
|
||||
if (!$course) {
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
|
||||
}
|
||||
|
||||
// Check the user has the required capabilities to edit an event
|
||||
|
@ -79,7 +79,10 @@ if ($course !== NULL) {
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
require_login();
|
||||
require_login($course);
|
||||
if (!$course) {
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
|
||||
}
|
||||
|
||||
if (empty($CFG->enablecalendarexport)) {
|
||||
die('no export');
|
||||
|
@ -17,6 +17,7 @@ if ($course->id != SITEID) {
|
||||
require_login($course);
|
||||
} else {
|
||||
require_login();
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
|
||||
}
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
|
@ -70,6 +70,7 @@ if ($type !== 0) {
|
||||
$url->param('type', $type);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
|
||||
|
||||
// Initialize the session variables
|
||||
calendar_session_vars();
|
||||
|
@ -70,11 +70,15 @@ if ($yr !== 0) {
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
//TODO: the courseid handling in /calendar/ is a bloody mess!!!
|
||||
|
||||
if ($courseid && $courseid != SITEID) {
|
||||
require_login($courseid);
|
||||
} else if ($CFG->forcelogin) {
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
|
||||
require_login();
|
||||
} else {
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
|
||||
}
|
||||
|
||||
$calendar = new calendar_information($day, $mon, $yr);
|
||||
@ -140,7 +144,7 @@ if (!isloggedin() or isguestuser()) {
|
||||
// but NOT for the "main page" course
|
||||
if ($SESSION->cal_course_referer != SITEID &&
|
||||
($shortname = $DB->get_field('course', 'shortname', array('id'=>$SESSION->cal_course_referer))) !== false) {
|
||||
require_login();
|
||||
require_login(); //TODO: very wrong!!
|
||||
if (empty($course)) {
|
||||
$course = $DB->get_record('course', array('id'=>$SESSION->cal_course_referer)); // Useful to have around
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user