From 800688bd1ef460c6447779d77780c16fc90348a7 Mon Sep 17 00:00:00 2001 From: "Andrew Davis (andyjdavis)" Date: Thu, 30 Jun 2011 15:30:34 +0800 Subject: [PATCH] MDL-27829 blocks: added code to make the page type restrictions for blocks on admin setting pages make sense --- admin/lib.php | 39 +++++++++++++++++++++++++++++++++++++++ blocks/edit_form.php | 5 +++-- course/lib.php | 3 +-- lang/en/pagetype.php | 2 ++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 admin/lib.php diff --git a/admin/lib.php b/admin/lib.php new file mode 100644 index 0000000000000..dde1bc58e225b --- /dev/null +++ b/admin/lib.php @@ -0,0 +1,39 @@ +. + +/** + * This file contains functions used by the admin pages + * + * @since 2.1 + * @package admin + * @copyright 2011 Andrew Davis + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Return a list of page types + * @param string $pagetype current page type + * @param stdClass $parentcontext Block's parent context + * @param stdClass $currentcontext Current context of block + */ +function admin_page_type_list($pagetype, $parentcontext, $currentcontext) { + $array = array( + 'admin-setting-*' => get_string('page-admin-setting-x', 'pagetype'), + $pagetype => get_string('page-admin-setting', 'pagetype') + ); + return $array; +} \ No newline at end of file diff --git a/blocks/edit_form.php b/blocks/edit_form.php index 3e5a9e03a2bd4..80d40582b63c9 100644 --- a/blocks/edit_form.php +++ b/blocks/edit_form.php @@ -99,8 +99,9 @@ function definition() { $contextoptions = array(); if ( ($parentcontext->contextlevel == CONTEXT_COURSE && $parentcontext->instanceid == SITEID) || ($parentcontext->contextlevel == CONTEXT_SYSTEM)) { // Home page - if ($bits[0] == 'tag') { - // tag always use system context, the contexts options don't make differences, so we use + if ($bits[0] == 'tag' || ($bits[0] == 'admin' && $bits[1] == 'setting')) { + // tag and admin settings always use system context + // the contexts options don't make differences, so we use // page type patterns only $mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_ENTIRE_SITE); } else { diff --git a/course/lib.php b/course/lib.php index 8517148404a86..5e388adcc231c 100644 --- a/course/lib.php +++ b/course/lib.php @@ -4226,8 +4226,7 @@ function course_page_type_list($pagetype, $parentcontext, $currentcontext) { } else { return array('*'=>get_string('page-x', 'pagetype'), 'course-*'=>get_string('page-course-x', 'pagetype'), - 'course-view-*'=>get_string('page-course-view-x', 'pagetype'), - 'mod-*'=>get_string('page-mod-x', 'pagetype') + 'course-view-*'=>get_string('page-course-view-x', 'pagetype') ); } } \ No newline at end of file diff --git a/lang/en/pagetype.php b/lang/en/pagetype.php index 7a073f4482e12..e011acb62509d 100644 --- a/lang/en/pagetype.php +++ b/lang/en/pagetype.php @@ -23,6 +23,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string['page-admin-setting'] = 'The current admin setting page'; +$string['page-admin-setting-x'] = 'Any admin setting page'; $string['page-course-view-x'] = 'Any type of course main page'; $string['page-course-x'] = 'Any course page'; $string['page-course-report-x'] = 'Any course report';