merged fix for MDL-7766, calendar not displaying course events
This commit is contained in:
+16
-7
@@ -1212,18 +1212,27 @@ function calendar_get_default_courses($ignoreref = false) {
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
if(has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
if(!empty($CFG->calendar_adminseesall)) {
|
||||
if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
|
||||
if (!empty($CFG->calendar_adminseesall)) {
|
||||
$courses = get_records_sql('SELECT id, 1 FROM '.$CFG->prefix.'course');
|
||||
return $courses;
|
||||
}
|
||||
}
|
||||
if(isset($USER->student) && is_array($USER->student)) {
|
||||
$courses = $courses + $USER->student;
|
||||
}
|
||||
if(isset($USER->teacher) && is_array($USER->teacher)) {
|
||||
$courses = $courses + $USER->teacher;
|
||||
|
||||
// find all course this student can view
|
||||
if ($allcourses = get_my_courses($USER->id,'visible DESC,sortorder ASC', '*', true)) {
|
||||
foreach ($allcourses as $courseid=>$acourse) {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
// let's try to see if there is any direct assignments on tihs context
|
||||
if ($roleassign = get_record('role_assignments', 'contextid', $context->id, 'userid', $USER->id)) {
|
||||
$auth = $roleassign->enrol;
|
||||
} else {
|
||||
$auth = '';
|
||||
}
|
||||
$courses[$courseid] = $auth;
|
||||
}
|
||||
}
|
||||
|
||||
return $courses;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -671,7 +671,7 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
|
||||
* @param string $fields the fields to return
|
||||
* @return array {@link $COURSE} of course objects
|
||||
*/
|
||||
function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields='*') {
|
||||
function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields='*', $doanything=false) {
|
||||
|
||||
$mycourses = array();
|
||||
|
||||
@@ -686,7 +686,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields='*'
|
||||
// the course needs to be visible, or user must have moodle/course:viewhiddencourses
|
||||
// capability set to view hidden courses
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if ( has_capability('moodle/course:view', $context, $userid, false) &&
|
||||
if ( has_capability('moodle/course:view', $context, $userid, $doanything) &&
|
||||
!has_capability('moodle/legacy:guest', $context, $userid, false) &&
|
||||
($course->visible || has_capability('moodle/course:viewhiddencourses', $context, $userid))) {
|
||||
$mycourses[$course->id] = $course;
|
||||
|
||||
Reference in New Issue
Block a user