Permalink
Browse files

navigation MDL-26903 Fixed regression to navigation ajax after CM cha…

…nges
  • Loading branch information...
1 parent 56babbc commit c78262b54269c5f5dfe22dc93145e78c4c87da9e Sam Hemelryk committed Mar 21, 2011
Showing with 8 additions and 9 deletions.
  1. +8 −9 lib/navigationlib.php
View
@@ -2247,23 +2247,22 @@ public function initialise() {
$this->load_section_activities($sections[$course->sectionnumber]->sectionnode, $course->sectionnumber, get_fast_modinfo($course));
break;
case self::TYPE_ACTIVITY :
- $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
+ $sql = "SELECT c.*
+ FROM {course} c
+ JOIN {course_modules} cm ON cm.course = c.id
+ WHERE cm.id = :cmid";
+ $params = array('cmid' => $this->instanceid);
+ $course = $DB->get_record_sql($sql, $params, MUST_EXIST);
$modinfo = get_fast_modinfo($course);
$cm = $modinfo->get_cm($this->instanceid);
require_course_login($course, true, $cm);
$this->page->set_context(get_context_instance(CONTEXT_MODULE, $cm->id));
$coursenode = $this->load_course($course);
- $sections = $this->load_course_sections($course, $coursenode);
- foreach ($sections as $section) {
- if ($section->id == $cm->section) {
- $cm->sectionnumber = $section->section;
- break;
- }
- }
if ($course->id == SITEID) {
$modulenode = $this->load_activity($cm, $course, $coursenode->find($cm->id, self::TYPE_ACTIVITY));
} else {
- $activities = $this->load_section_activities($sections[$cm->sectionnumber]->sectionnode, $cm->sectionnumber, get_fast_modinfo($course));
+ $sections = $this->load_course_sections($course, $coursenode);
+ $activities = $this->load_section_activities($sections[$cm->sectionnum]->sectionnode, $cm->sectionnum, get_fast_modinfo($course));
$modulenode = $this->load_activity($cm, $course, $activities[$cm->id]);
}
break;

0 comments on commit c78262b

Please sign in to comment.