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:
vinkmar 2006-08-21 04:06:58 +00:00
parent d37bac7e5d
commit 6fcbab99ef
4 changed files with 807 additions and 793 deletions

File diff suppressed because it is too large Load diff

View file

@ -9,10 +9,10 @@ page_map_class(PAGE_ADMIN, 'page_admin');
class page_admin extends page_base { class page_admin extends page_base {
var $section; var $section;
var $pathtosection; var $pathtosection;
var $visiblepathtosection; var $visiblepathtosection;
function init_full() { function init_full($section) {
global $CFG, $ADMIN; global $CFG, $ADMIN;
if($this->full_init_done) { if($this->full_init_done) {
@ -20,19 +20,19 @@ class page_admin extends page_base {
} }
// fetch the path parameter // fetch the path parameter
$this->section = optional_param("section","",PARAM_PATH); $this->section = $section;
$this->visiblepathtosection = array(); $this->visiblepathtosection = array();
// this part is (potentially) processor-intensive... there's gotta be a better way // this part is (potentially) processor-intensive... there's gotta be a better way
// of handling this // of handling this
if ($this->pathtosection = $ADMIN->path($this->section)) { if ($this->pathtosection = $ADMIN->path($this->section)) {
foreach($this->pathtosection as $element) { foreach($this->pathtosection as $element) {
if ($pointer = $ADMIN->locate($element)) { if ($pointer = $ADMIN->locate($element)) {
array_push($this->visiblepathtosection, $pointer->visiblename); array_push($this->visiblepathtosection, $pointer->visiblename);
} }
} }
} }
// all done // all done
$this->full_init_done = true; $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 function url_get_parameters() { // only handles parameters relevant to the admin pagetype
$this->init_full(); return array('section' => (isset($this->section) ? $this->section : ''));
return array('section' => $this->section);
} }
function blocks_get_positions() { function blocks_get_positions() {
@ -82,12 +81,12 @@ class page_admin extends page_base {
parent::init_quick($data); parent::init_quick($data);
} }
function print_header() { function print_header($section = '') {
global $USER, $CFG, $SITE; 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()) { if ($this->user_allowed_editing()) {
$buttons = '<table><tr><td><form target="' . $CFG->framename . '" method="get" action="' . $this->url_get_path() . '">'. $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').'" />'. '<input type="hidden" name="adminedit" value="'.($this->user_is_editing()?'off':'on').'" />'.

View file

@ -2,8 +2,8 @@
require_once('../config.php'); require_once('../config.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php'); require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
require_once($CFG->libdir . '/blocklib.php'); //d require_once($CFG->libdir . '/blocklib.php');
require_once($CFG->dirroot . '/' . $CFG->admin . '/pagelib.php'); //d require_once($CFG->dirroot . '/' . $CFG->admin . '/pagelib.php');
if ($site = get_site()) { if ($site = get_site()) {
require_login(); require_login();
@ -20,7 +20,9 @@ page_map_class($pagetype, $pageclass);
$PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID); $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); $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
@ -42,12 +44,12 @@ $root = $ADMIN->locate($PAGE->section);
if (!is_a($root, 'admin_settingpage')) { if (!is_a($root, 'admin_settingpage')) {
error(get_string('sectionerror', 'admin')); error(get_string('sectionerror', 'admin'));
die; die;
} }
if (!($root->check_access())) { if (!($root->check_access())) {
error(get_string('accessdenied', 'admin')); error(get_string('accessdenied', 'admin'));
die; die;
} }
// WRITING SUBMITTED DATA (IF ANY) ------------------------------------------------------------------------------- // WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
@ -56,14 +58,14 @@ if ($data = data_submitted()) {
if (confirm_sesskey()) { if (confirm_sesskey()) {
$errors = $root->write_settings((array)$data); $errors = $root->write_settings((array)$data);
if (empty($errors)) { if (empty($errors)) {
redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1); redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1);
} else { } else {
error(get_string('errorwithsettings', 'admin') . ' <br />' . $errors); error(get_string('errorwithsettings', 'admin') . ' <br />' . $errors);
} }
} else { } else {
error(get_string('confirmsesskeybad', 'error')); error(get_string('confirmsesskeybad', 'error'));
die; die;
} }
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------