Merge branch 'wip-MDL-36317-master' of git://github.com/marinaglancy/moodle

Conflicts:
	course/format/lib.php
This commit is contained in:
Dan Poltawski
2012-11-07 16:41:53 +08:00
2 changed files with 32 additions and 2 deletions
+18
View File
@@ -767,6 +767,24 @@ abstract class format_base {
}
return new editsection_form($action, $customdata);
}
/**
* Allows course format to execute code on moodle_page::set_course()
*
* @param moodle_page $page instance of page calling set_course
*/
public function page_set_course(moodle_page $page) {
}
/**
* Allows course format to execute code on moodle_page::set_cm()
*
* Current module can be accessed as $page->cm (returns instance of cm_info)
*
* @param moodle_page $page instance of page calling set_cm
*/
public function page_set_cm(moodle_page $page) {
}
}
/**
+14 -2
View File
@@ -845,7 +845,7 @@ class moodle_page {
* @param stdClass $course the course to set as the global course.
*/
public function set_course($course) {
global $COURSE, $PAGE;
global $COURSE, $PAGE, $CFG, $SITE;
if (empty($course->id)) {
throw new coding_exception('$course passed to moodle_page::set_course does not look like a proper course object.');
@@ -867,6 +867,12 @@ class moodle_page {
if (!$this->_context) {
$this->set_context(context_course::instance($this->_course->id));
}
// notify course format that this page is set for the course
if ($this->_course->id != $SITE->id) {
require_once($CFG->dirroot.'/course/lib.php');
course_get_format($this->_course)->page_set_course($this);
}
}
/**
@@ -911,7 +917,7 @@ class moodle_page {
* @return void
*/
public function set_cm($cm, $course = null, $module = null) {
global $DB;
global $DB, $CFG, $SITE;
if (!isset($cm->id) || !isset($cm->course)) {
throw new coding_exception('Invalid $cm parameter for $PAGE object, it has to be instance of cm_info or record from the course_modules table.');
@@ -943,6 +949,12 @@ class moodle_page {
if ($module) {
$this->set_activity_record($module);
}
// notify course format that this page is set for the course module
if ($this->_course->id != $SITE->id) {
require_once($CFG->dirroot.'/course/lib.php');
course_get_format($this->_course)->page_set_cm($this);
}
}
/**