Skip to content

Commit

Permalink
MDL-27829 blocks: added code to make the page type restrictions for b…
Browse files Browse the repository at this point in the history
…locks on admin setting pages make sense
  • Loading branch information
andyjdavis committed Jun 30, 2011
1 parent b38e2e2 commit 800688b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
39 changes: 39 additions & 0 deletions admin/lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* 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;
}
5 changes: 3 additions & 2 deletions blocks/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
}
}
2 changes: 2 additions & 0 deletions lang/en/pagetype.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 800688b

Please sign in to comment.