portfolio MDL-24251 make sure $PAGE context is set up properly

This commit is contained in:
Penny Leach 2010-09-17 09:39:56 +00:00
parent adfc4d7c25
commit 90636e2b41
3 changed files with 20 additions and 9 deletions

View file

@ -477,6 +477,13 @@ abstract class portfolio_caller_base {
*/
public static abstract function expected_callbackargs();
/**
* return the context for this export. used for $PAGE->set_context
*
* @return stdclass
*/
public abstract function set_context($PAGE);
}
/**
@ -551,4 +558,11 @@ abstract class portfolio_module_caller_base extends portfolio_caller_base {
public function heading_summary() {
return get_string('exportingcontentfrom', 'portfolio', $this->display_name() . ': ' . $this->cm->name);
}
/**
* overridden to return the course module context
*/
public function set_context($PAGE) {
$PAGE->set_cm($this->cm);
}
}

View file

@ -1119,19 +1119,13 @@ function portfolio_insane_notify_admins($insane, $instances=false) {
}
function portfolio_export_pagesetup($PAGE, $caller) {
// for build navigation
if (!$course = $caller->get('course')) {
$course = $courseid;
}
// set up the course so that build_navigation works nice
$PAGE->set_course($course);
// set up the context so that build_navigation works nice
$caller->set_context($PAGE);
list($extranav, $cm) = $caller->get_navigation();
// and now we know the course for sure and maybe the cm, call require_login with it
// todo this will have to change when we have things exporting content outside the course context (eg blogs)
require_login($course, false, $cm);
require_login($PAGE->course, false, $cm);
foreach ($extranav as $navitem) {
$PAGE->navbar->add($navitem['name']);

View file

@ -108,6 +108,9 @@ class portfolio_caller_test extends portfolio_caller_base {
public static function base_supported_formats() {
return array(PORTFOLIO_FORMAT_RICH, PORTFOLIO_FORMAT_FILE);
}
public function set_context($PAGE) {
$PAGE->set_context(get_system_context());
}
}
class portfolio_exporter_test extends portfolio_exporter {