Merge branch 'MDL-32340-master-2' of git://git.luns.net.uk/moodle

This commit is contained in:
Sam Hemelryk 2012-05-14 14:04:21 +12:00
commit 04d7103804

View File

@ -1491,15 +1491,16 @@ function calendar_get_default_courses() {
}
$courses = array();
if (!empty($CFG->calendar_adminseesall) && has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM))) {
if (!empty($CFG->calendar_adminseesall) && has_capability('moodle/calendar:manageentries', context_system::instance())) {
list ($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
$sql = "SELECT DISTINCT c.* $select
$sql = "SELECT c.* $select
FROM {course} c
JOIN {event} e ON e.courseid = c.id
$join";
$join
WHERE EXISTS (SELECT 1 FROM {event} e WHERE e.courseid = c.id)
";
$courses = $DB->get_records_sql($sql, null, 0, 20);
foreach ($courses as $course) {
context_instance_preload($course);
context_helper::preload_from_record($course);
}
return $courses;
}