Skip to content
Browse files

Merge branch 'w07_MDL-25974_20_switchhidden' of git://github.com/skod…

…ak/moodle
  • Loading branch information...
2 parents 0db846a + 44303ca commit a49d8aa25ae732b614dbe82029a6e66e28ba0ec5 @stronk7 stronk7 committed Feb 14, 2011
Showing with 14 additions and 8 deletions.
  1. +14 −8 lib/navigationlib.php
View
22 lib/navigationlib.php
@@ -1023,7 +1023,7 @@ public function initialise() {
$this->add_course_essentials($coursenode, $course);
// Load the course sections into the page
$sections = $this->load_course_sections($course, $coursenode);
- if ($course->id !== SITEID) {
+ if ($course->id != SITEID) {
// Find the section for the $CM associated with the page and collect
// its section number.
if (isset($cm->sectionnum)) {
@@ -1105,7 +1105,7 @@ public function initialise() {
}
// Load each extending user into the navigation.
foreach ($this->extendforuser as $user) {
- if ($user->id !== $USER->id) {
+ if ($user->id != $USER->id) {
$this->load_for_user($user);
}
}
@@ -1517,7 +1517,7 @@ protected function load_stealth_activity(navigation_node $coursenode, $modinfo)
*/
protected function load_activity($cm, stdClass $course, navigation_node $activity) {
global $CFG, $DB;
-
+
// make sure we have a $cm from get_fast_modinfo as this contains activity access details
if (!($cm instanceof cm_info)) {
$modinfo = get_fast_modinfo($course);
@@ -1569,7 +1569,7 @@ protected function load_for_user($user=null, $forceforcontext=false) {
// Get the course set against the page, by default this will be the site
$course = $this->page->course;
$baseargs = array('id'=>$user->id);
- if ($course->id !== SITEID && (!$iscurrentuser || $forceforcontext)) {
+ if ($course->id != SITEID && (!$iscurrentuser || $forceforcontext)) {
if (array_key_exists($course->id, $this->mycourses)) {
$coursenode = $this->mycourses[$course->id]->coursenode;
} else {
@@ -1857,9 +1857,15 @@ public function get_extending_users() {
*/
public function add_course(stdClass $course, $forcegeneric = false) {
global $CFG;
- $canviewhidden = has_capability('moodle/course:viewhiddencourses', $this->page->context);
- if ($course->id !== SITEID && !$canviewhidden && !$course->visible) {
- return false;
+
+ if ($course->id != SITEID) {
+ if (!$course->visible) {
+ if (is_role_switched($course->id)) {
+ // user has to be able to access course in order to switch, let's skip the visibility test here
+ } else if (!has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ return false;
+ }
+ }
}
$issite = ($course->id == SITEID);
@@ -2984,7 +2990,7 @@ protected function load_course_settings($forceopen = false) {
$availableroles = get_switchable_roles($coursecontext);
if (is_array($availableroles)) {
foreach ($availableroles as $key=>$role) {
- if ($assumedrole===(int)$key) {
+ if ($assumedrole == (int)$key) {
continue;
}
$roles[$key] = $role;

0 comments on commit a49d8aa

Please sign in to comment.
Something went wrong with that request. Please try again.