mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
portfolio MDL-24251 make sure $PAGE context is set up properly
This commit is contained in:
parent
adfc4d7c25
commit
90636e2b41
3 changed files with 20 additions and 9 deletions
|
@ -477,6 +477,13 @@ abstract class portfolio_caller_base {
|
||||||
*/
|
*/
|
||||||
public static abstract function expected_callbackargs();
|
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() {
|
public function heading_summary() {
|
||||||
return get_string('exportingcontentfrom', 'portfolio', $this->display_name() . ': ' . $this->cm->name);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1119,19 +1119,13 @@ function portfolio_insane_notify_admins($insane, $instances=false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function portfolio_export_pagesetup($PAGE, $caller) {
|
function portfolio_export_pagesetup($PAGE, $caller) {
|
||||||
// for build navigation
|
// set up the context so that build_navigation works nice
|
||||||
if (!$course = $caller->get('course')) {
|
$caller->set_context($PAGE);
|
||||||
$course = $courseid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set up the course so that build_navigation works nice
|
|
||||||
$PAGE->set_course($course);
|
|
||||||
|
|
||||||
list($extranav, $cm) = $caller->get_navigation();
|
list($extranav, $cm) = $caller->get_navigation();
|
||||||
|
|
||||||
// and now we know the course for sure and maybe the cm, call require_login with it
|
// 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($PAGE->course, false, $cm);
|
||||||
require_login($course, false, $cm);
|
|
||||||
|
|
||||||
foreach ($extranav as $navitem) {
|
foreach ($extranav as $navitem) {
|
||||||
$PAGE->navbar->add($navitem['name']);
|
$PAGE->navbar->add($navitem['name']);
|
||||||
|
|
|
@ -108,6 +108,9 @@ class portfolio_caller_test extends portfolio_caller_base {
|
||||||
public static function base_supported_formats() {
|
public static function base_supported_formats() {
|
||||||
return array(PORTFOLIO_FORMAT_RICH, PORTFOLIO_FORMAT_FILE);
|
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 {
|
class portfolio_exporter_test extends portfolio_exporter {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue