mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
moodle_page: MDL-12212 eliminate the two different interpretations of
pagetype
This commit is contained in:
parent
d529807a65
commit
e88462a055
9 changed files with 39 additions and 11 deletions
|
@ -189,6 +189,7 @@
|
|||
/// and upgrade if possible.
|
||||
|
||||
$stradministration = get_string('administration');
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
print_error('missingconfigversion', 'debug');
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
}
|
||||
|
||||
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');
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
|
||||
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');
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
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
|
||||
|
||||
|
|
|
@ -902,7 +902,7 @@ function blocks_get_by_page_pinned($page) {
|
|||
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();
|
||||
|
|
|
@ -1702,6 +1702,14 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
|||
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);
|
||||
|
|
|
@ -1929,6 +1929,10 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
|
|||
}
|
||||
}
|
||||
$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
|
||||
|
|
|
@ -317,7 +317,7 @@ function page_create_object($type, $id = NULL) {
|
|||
|
||||
$object->init_quick($data);
|
||||
$object->set_course($PAGE->course);
|
||||
$object->set_pagetype($type);
|
||||
//$object->set_pagetype($type);
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,12 @@ if (!defined('MOODLE_INTERNAL')) {
|
|||
|
||||
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.
|
||||
*/
|
||||
|
@ -47,7 +53,7 @@ class moodle_page_test extends UnitTestCase {
|
|||
public function setUp() {
|
||||
global $COURSE;
|
||||
$this->originalcourse = $COURSE;
|
||||
$this->testpage = new moodle_page();
|
||||
$this->testpage = new testable_moodle_page();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
|
@ -167,11 +173,9 @@ class moodle_page_test extends UnitTestCase {
|
|||
$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() {
|
||||
|
@ -180,6 +184,20 @@ class moodle_page_test extends UnitTestCase {
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue