admin tree: MDL-10047 and MDL-13104 weird things happen when you turn editing on and off.
That was becuase not enough information was being passed in for the blocks editing controls to construct the right URL to reload the page. It is also now possible for admin external pages to add some UI next to the turn blocks editing on/off button. For example, when you are editing the list of course catgories, the turn editing off button is now in the right place.
This commit is contained in:
+39
-6
@@ -20,8 +20,11 @@ page_map_class(PAGE_ADMIN, 'page_admin');
|
||||
|
||||
class page_admin extends page_base {
|
||||
|
||||
var $section;
|
||||
var $section = '';
|
||||
var $visiblepathtosection;
|
||||
var $extraurlparams = array();
|
||||
var $extrabutton = '';
|
||||
var $url = '';
|
||||
|
||||
// hack alert!
|
||||
// this function works around the inability to store the section name
|
||||
@@ -62,6 +65,9 @@ class page_admin extends page_base {
|
||||
|
||||
function url_get_path() {
|
||||
global $CFG;
|
||||
if (!empty($this->url)) {
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
$adminroot =& admin_get_root(false, false); //settings not required - only pages
|
||||
|
||||
@@ -73,8 +79,29 @@ class page_admin extends page_base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to pass extra HTML that is added after the turn blocks editing on/off button.
|
||||
*
|
||||
* @param string $extrabutton HTML code.
|
||||
*/
|
||||
function set_extra_button($extrabutton) {
|
||||
$this->extrabutton = $extrabutton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to pass extra URL parameters that, for example, the blocks editing controls need to reload the current page accurately.
|
||||
*
|
||||
* @param array $extraurlparams paramname => value array.
|
||||
*/
|
||||
function set_extra_url_params($extraurlparams, $actualurl = '') {
|
||||
$this->extraurlparams = $extraurlparams;
|
||||
if (!empty($actualurl)) {
|
||||
$this->url = $actualurl;
|
||||
}
|
||||
}
|
||||
|
||||
function url_get_parameters() { // only handles parameters relevant to the admin pagetype
|
||||
return array('section' => (isset($this->section) ? $this->section : ''));
|
||||
return array_merge($this->extraurlparams, array('section' => $this->section));
|
||||
}
|
||||
|
||||
function blocks_get_positions() {
|
||||
@@ -107,13 +134,19 @@ class page_admin extends page_base {
|
||||
|
||||
// The search page currently doesn't handle block editing
|
||||
if ($this->section != 'search' and $this->user_allowed_editing()) {
|
||||
$buttons = '<div><form '.$CFG->frametarget.' method="get" action="' . $this->url_get_path() . '">'.
|
||||
'<div><input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
'<input type="hidden" name="section" value="'.$this->section.'" />'.
|
||||
'<input type="submit" value="'.get_string($this->user_is_editing()?'blockseditoff':'blocksediton').'" /></div></form></div>';
|
||||
$options = $this->url_get_parameters();
|
||||
if ($this->user_is_editing()) {
|
||||
$caption = get_string('blockseditoff');
|
||||
$options['adminedit'] = 'off';
|
||||
} else {
|
||||
$caption = get_string('blocksediton');
|
||||
$options['adminedit'] = 'on';
|
||||
}
|
||||
$buttons = print_single_button($this->url_get_path(), $options, $caption, 'get', '', true);
|
||||
} else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
$buttons .= $this->extrabutton;
|
||||
|
||||
$navlinks = array();
|
||||
foreach ($this->visiblepathtosection as $element) {
|
||||
|
||||
@@ -23,7 +23,8 @@ $showsearch = optional_param('showsearch', false, PARAM_BOOL);
|
||||
$thorough = optional_param('thorough', false, PARAM_BOOL);
|
||||
|
||||
// Print the header.
|
||||
admin_externalpage_setup('reportunittest');
|
||||
admin_externalpage_setup('reportunittest', '', array('showpasses' => $showpasses,
|
||||
'showsearch' => $showsearch, 'thorough' => $thorough));
|
||||
admin_externalpage_print_header();
|
||||
|
||||
/* The UNITTEST constant can be checked elsewhere if you need to know
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
admin_externalpage_setup('defineroles', '', array(), $CFG->wwwroot . '/' . $CFG->admin . '/roles/allowassign.php');
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
admin_externalpage_setup('defineroles', '', array(), $CFG->wwwroot . '/' . $CFG->admin . '/roles/allowoverride.php');
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
|
||||
@@ -144,11 +144,11 @@
|
||||
$currenttab = 'assign';
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
} else if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
admin_externalpage_setup('assignroles');
|
||||
admin_externalpage_print_header();
|
||||
admin_externalpage_setup('assignroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
admin_externalpage_print_header('');
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
admin_externalpage_setup('frontpageroles');
|
||||
admin_externalpage_print_header();
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
|
||||
admin_externalpage_print_header('');
|
||||
$currenttab = 'assign';
|
||||
include_once('tabs.php');
|
||||
} else {
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // if set, we are editing a role
|
||||
$name = optional_param('name', '', PARAM_MULTILANG); // new role name
|
||||
$shortname = optional_param('shortname', '', PARAM_RAW); // new role shortname, special cleaning before storage
|
||||
@@ -14,6 +12,8 @@
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$cancel = optional_param('cancel', 0, PARAM_BOOL);
|
||||
|
||||
admin_externalpage_setup('defineroles', '', array('roleid' => $roleid));
|
||||
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
require_capability('moodle/role:manage', $sitecontext);
|
||||
@@ -414,7 +414,7 @@
|
||||
|
||||
/// print UI now
|
||||
|
||||
admin_externalpage_print_header();
|
||||
admin_externalpage_print_header('');
|
||||
|
||||
$currenttab = 'manage';
|
||||
include_once('managetabs.php');
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
include_once($CFG->dirroot.'/user/tabs.php');
|
||||
} else if ($context->contextlevel==CONTEXT_COURSE and $context->instanceid == SITEID) {
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
admin_externalpage_setup('frontpageroles');
|
||||
admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid), $CFG->wwwroot . '/' . $CFG->admin . '/roles/override.php');
|
||||
admin_externalpage_print_header();
|
||||
$currenttab = 'override';
|
||||
include_once('tabs.php');
|
||||
|
||||
Reference in New Issue
Block a user