diff --git a/lib/datalib.php b/lib/datalib.php index 88ae55dcb0c..1b95a9f4361 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -623,7 +623,7 @@ function get_record_sql($sql, $expectmultiple=false, $nolimit=false) { } if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++; }; - + if (!$rs = $db->Execute($sql . $limit)) { if (isset($CFG->debug) and $CFG->debug > 7) { // Debugging mode - print checks notify( $db->ErrorMsg() . '

'. $sql . $limit ); @@ -2218,7 +2218,7 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c */ function get_my_courses($userid, $sort='visible DESC,sortorder ASC') { - global $CFG, $USER; + global $CFG; $course = array(); @@ -2227,14 +2227,6 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC') { $course[$student->course] = $student->course; } } - if (count($course) > 0) { - $courses = get_records_list('course', 'id', implode(',', $course)); - foreach ($courses as $k => $c) { - if (empty($USER->admin) && (!$c->visible || !course_parent_visible($c))) { - unset($course[$c->id]); - } - } - } if ($teachers = get_records('user_teachers', 'userid', $userid, '', 'id, course')) { foreach ($teachers as $teacher) { $course[$teacher->course] = $teacher->course; @@ -2326,7 +2318,7 @@ function get_courses_search($searchterms, $sort='fullname ASC', $page=0, $record if ($courses) { /// Remove unavailable courses from the list foreach ($courses as $key => $course) { - if (!$course->visible || !course_parent_visible($course)) { + if (!$course->visible) { if (!isteacher($course->id)) { unset($courses[$key]); $totalcount--; @@ -2357,7 +2349,7 @@ function get_categories($parent='none', $sort='sortorder ASC') { if ($categories) { /// Remove unavailable categories from the list $creator = iscreator(); foreach ($categories as $key => $category) { - if (!$category->visible || !category_parent_visible($category->parent)) { + if (!$category->visible) { if (!$creator) { unset($categories[$key]); } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1b700073907..b96825285e9 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1406,13 +1406,6 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) { } return; } - if (! $course = get_record('course', 'id', $courseid)) { - error('That course doesn\'t exist'); - } - if (!(isteacher($courseid) || !empty($USER->admin)) && (!$course->visible || !course_parent_visible($course))) { - print_header(); - notice(get_string('coursehidden'), $CFG->wwwroot .'/'); - } if (!empty($USER->student[$courseid]) or !empty($USER->teacher[$courseid]) or !empty($USER->admin)) { if (isset($USER->realuser)) { // Make sure the REAL person can also access this course if (!isteacher($courseid, $USER->realuser)) { @@ -1424,6 +1417,13 @@ function require_login($courseid=0, $autologinguest=true, $cm=null) { redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course, get_string('activityiscurrentlyhidden')); } return; // user is a member of this course. + if (! $course = get_record('course', 'id', $courseid)) { + error('That course doesn\'t exist'); + } + if (!$course->visible) { + print_header(); + notice(get_string('coursehidden'), $CFG->wwwroot .'/'); + } } if ($USER->username == 'guest') { switch ($course->guest) {