Skip to content

Commit

Permalink
MDL-23616 extremely messy hack to work around weird course handling r…
Browse files Browse the repository at this point in the history
…esulting in unknown PAGE->context
  • Loading branch information
skodak committed Aug 4, 2010
1 parent 44388c4 commit ca74470
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
9 changes: 5 additions & 4 deletions calendar/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@
*/
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
Expand Down
5 changes: 4 additions & 1 deletion calendar/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@
}
$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');
Expand Down
1 change: 1 addition & 0 deletions calendar/preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
require_login($course);
} else {
require_login();
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
}
// Initialize the session variables
calendar_session_vars();
Expand Down
1 change: 1 addition & 0 deletions calendar/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
$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();
Expand Down
8 changes: 6 additions & 2 deletions calendar/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@
}
$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);
Expand Down Expand Up @@ -140,7 +144,7 @@
// 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
}
Expand Down

0 comments on commit ca74470

Please sign in to comment.