mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
fixed tabs, fixed potential notices for undefined variables, added structure that will be used for detecting what variables to flag during installs & upgrades, removed all $_GET usage, switched 'admin' to $CFG->admin (for directory paths), and fixed blank line at end of index.php
This commit is contained in:
parent
d37bac7e5d
commit
6fcbab99ef
4 changed files with 807 additions and 793 deletions
1533
admin/adminlib.php
1533
admin/adminlib.php
File diff suppressed because it is too large
Load diff
|
@ -559,4 +559,4 @@
|
|||
|
||||
admin_externalpage_print_footer();
|
||||
|
||||
?>
|
||||
?>
|
|
@ -9,10 +9,10 @@ page_map_class(PAGE_ADMIN, 'page_admin');
|
|||
class page_admin extends page_base {
|
||||
|
||||
var $section;
|
||||
var $pathtosection;
|
||||
var $pathtosection;
|
||||
var $visiblepathtosection;
|
||||
|
||||
function init_full() {
|
||||
function init_full($section) {
|
||||
global $CFG, $ADMIN;
|
||||
|
||||
if($this->full_init_done) {
|
||||
|
@ -20,19 +20,19 @@ class page_admin extends page_base {
|
|||
}
|
||||
|
||||
// fetch the path parameter
|
||||
$this->section = optional_param("section","",PARAM_PATH);
|
||||
$this->section = $section;
|
||||
|
||||
$this->visiblepathtosection = array();
|
||||
|
||||
// this part is (potentially) processor-intensive... there's gotta be a better way
|
||||
// of handling this
|
||||
if ($this->pathtosection = $ADMIN->path($this->section)) {
|
||||
foreach($this->pathtosection as $element) {
|
||||
if ($pointer = $ADMIN->locate($element)) {
|
||||
array_push($this->visiblepathtosection, $pointer->visiblename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this part is (potentially) processor-intensive... there's gotta be a better way
|
||||
// of handling this
|
||||
if ($this->pathtosection = $ADMIN->path($this->section)) {
|
||||
foreach($this->pathtosection as $element) {
|
||||
if ($pointer = $ADMIN->locate($element)) {
|
||||
array_push($this->visiblepathtosection, $pointer->visiblename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// all done
|
||||
$this->full_init_done = true;
|
||||
|
@ -65,8 +65,7 @@ class page_admin extends page_base {
|
|||
}
|
||||
|
||||
function url_get_parameters() { // only handles parameters relevant to the admin pagetype
|
||||
$this->init_full();
|
||||
return array('section' => $this->section);
|
||||
return array('section' => (isset($this->section) ? $this->section : ''));
|
||||
}
|
||||
|
||||
function blocks_get_positions() {
|
||||
|
@ -82,12 +81,12 @@ class page_admin extends page_base {
|
|||
parent::init_quick($data);
|
||||
}
|
||||
|
||||
function print_header() {
|
||||
function print_header($section = '') {
|
||||
global $USER, $CFG, $SITE;
|
||||
|
||||
$this->init_full();
|
||||
$this->init_full($section); // we're trusting that init_full() has already been called by now; it should have.
|
||||
// if not, print_header() has to be called with a $section parameter
|
||||
|
||||
// should this rely on showblocksonmodpages in any way? after all, teachers aren't accessing this...
|
||||
if ($this->user_allowed_editing()) {
|
||||
$buttons = '<table><tr><td><form target="' . $CFG->framename . '" method="get" action="' . $this->url_get_path() . '">'.
|
||||
'<input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.
|
||||
|
@ -97,7 +96,7 @@ class page_admin extends page_base {
|
|||
} else {
|
||||
$buttons = ' ';
|
||||
}
|
||||
|
||||
|
||||
print_header("$SITE->shortname: " . implode(": ",$this->visiblepathtosection), $SITE->fullname, implode(" -> ",$this->visiblepathtosection),'', '', true, $buttons, '');
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/blocklib.php'); //d
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/pagelib.php'); //d
|
||||
require_once($CFG->libdir . '/blocklib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/pagelib.php');
|
||||
|
||||
if ($site = get_site()) {
|
||||
require_login();
|
||||
|
@ -20,7 +20,9 @@ page_map_class($pagetype, $pageclass);
|
|||
|
||||
$PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID);
|
||||
|
||||
$PAGE->init_full();
|
||||
$section = optional_param('section', '', PARAM_ALPHAEXT);
|
||||
|
||||
$PAGE->init_full($section);
|
||||
|
||||
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
||||
|
||||
|
@ -42,12 +44,12 @@ $root = $ADMIN->locate($PAGE->section);
|
|||
|
||||
if (!is_a($root, 'admin_settingpage')) {
|
||||
error(get_string('sectionerror', 'admin'));
|
||||
die;
|
||||
die;
|
||||
}
|
||||
|
||||
if (!($root->check_access())) {
|
||||
error(get_string('accessdenied', 'admin'));
|
||||
die;
|
||||
die;
|
||||
}
|
||||
|
||||
// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
|
||||
|
@ -56,14 +58,14 @@ if ($data = data_submitted()) {
|
|||
if (confirm_sesskey()) {
|
||||
$errors = $root->write_settings((array)$data);
|
||||
if (empty($errors)) {
|
||||
redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1);
|
||||
} else {
|
||||
error(get_string('errorwithsettings', 'admin') . ' <br />' . $errors);
|
||||
}
|
||||
} else {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
die;
|
||||
}
|
||||
redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1);
|
||||
} else {
|
||||
error(get_string('errorwithsettings', 'admin') . ' <br />' . $errors);
|
||||
}
|
||||
} else {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue