/// and upgrade if possible.
$stradministration = get_string('administration');
+ $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
if (empty($CFG->version)) {
print_error('missingconfigversion', 'debug');
}
admin_externalpage_setup('mnetenrol');
- $PAGE->set_pagetype('admin-mnet');
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
$enrolment = enrolment_factory::factory('mnet');
admin_externalpage_setup('mnetenrol');
- $PAGE->set_pagetype('admin-mnet');
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
$enrolment = enrolment_factory::factory('mnet');
require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('mnetenrol');
- $PAGE->set_pagetype('admin-mnet');
require_once("$CFG->dirroot/enrol/enrol.class.php"); /// Open the factory class
function blocks_get_by_page($page) {
global $DB;
- $blocks = $DB->get_records_select('block_instance', "pageid = ? AND pagetype = ?",
+ $blocks = $DB->get_records_select('block_instance', "pageid = ? AND ? LIKE (" . $DB->sql_concat('pagetype', "'%'") . ")",
array($page->get_id(), $page->pagetype), 'position, weight');
$positions = $page->blocks_get_positions();
upgrade_main_savepoint($result, 2009042700);
}
+ if ($result && $oldversion < 2009042800) {
+ /// Site front page blocks need to be moved due to page name change.
+ $DB->set_field('block_instance', 'pagetype', 'site-index', array('pagetype' => 'course-view', 'pageid' => SITEID));
+
+ /// Main savepoint reached
+ upgrade_main_savepoint($result, 2009042800);
+ }
+
if ($result && $oldversion < 2009043000) {
unset_config('grade_report_showgroups');
upgrade_main_savepoint($result, 2009043000);
}
}
$PAGE->set_course($course);
+ } else {
+ // If $PAGE->course, and hence $PAGE->context, have not already been set
+ // up properly, set them up now.
+ $PAGE->set_course($PAGE->course);
}
/// If the user is not even logged in yet then make sure they are
$object->init_quick($data);
$object->set_course($PAGE->course);
- $object->set_pagetype($type);
+ //$object->set_pagetype($type);
return $object;
}
require_once($CFG->libdir . '/pagelib.php');
+class testable_moodle_page extends moodle_page {
+ public function initialise_default_pagetype($script = '') {
+ parent::initialise_default_pagetype($script);
+ }
+}
+
/**
* Test functions that affect filter_active table with contextid = $syscontextid.
*/
public function setUp() {
global $COURSE;
$this->originalcourse = $COURSE;
- $this->testpage = new moodle_page();
+ $this->testpage = new testable_moodle_page();
}
public function tearDown() {
$this->assert(new CheckSpecifiedFieldsExpectation($context), $this->testpage->context);
}
- public function test_cant_get_pagetype_before_set() {
- // Set expectation.
- $this->expectException();
- // Exercise SUT
- $this->testpage->pagetype;
+ public function test_pagetype_defaults_to_script() {
+ // Exercise SUT and validate
+ $this->assertEqual('admin-report-unittest-index', $this->testpage->pagetype);
}
public function test_set_pagetype() {
// Validate
$this->assertEqual('a-page-type', $this->testpage->pagetype);
}
+
+ public function test_initialise_default_pagetype() {
+ // Exercise SUT
+ $this->testpage->initialise_default_pagetype('admin/report/unittest/index.php');
+ // Validate
+ $this->assertEqual('admin-report-unittest-index', $this->testpage->pagetype);
+ }
+
+ public function test_initialise_default_pagetype_fp() {
+ // Exercise SUT
+ $this->testpage->initialise_default_pagetype('index.php');
+ // Validate
+ $this->assertEqual('site-index', $this->testpage->pagetype);
+ }
}
/**