include_once($CFG->dirroot . '/backup/lib.php');
//---------------------------------------------------------------------------------------------------
-// Interfaces
+// Interfaces (pseudointerfaces, for PHP 4 compatibility)
//---------------------------------------------------------------------------------------------------
// part_of_admin_tree indicates that a node (whether it be an admin_settingpage or an
// admin_category or an admin_externalpage) is searchable
-interface part_of_admin_tree {
+class part_of_admin_tree {
- function &locate($name);
- function check_access();
- function path($name, $path = array());
+ function &locate($name) { trigger_error('Admin class does not implement method <strong>locate()</strong>', E_USER_WARNING); return; }
+ function check_access() { trigger_error('Admin class does not implement method <strong>check_access()</strong>', E_USER_WARNING); return; }
+ function path($name, $path = array()) { trigger_error('Admin class does not implement method <strong>path()</strong>', E_USER_WARNING); return; }
}
// parentable_part_of_admin_tree indicates that a node can have children in the hierarchy. only
// admin_category implements this interface (yes, yes, theoretically admin_setting* is a child of
// admin_settingpage, but you can't navigate admin_setting*s through the hierarchy)
-interface parentable_part_of_admin_tree {
+class parentable_part_of_admin_tree extends part_of_admin_tree {
- function add($destinationname, &$something);
+ function add($destinationname, &$something) { trigger_error('Admin class does not implement method <strong>add()</strong>', E_USER_WARNING); return; }
}
// admin categories don't handle much... they can't be printed to the screen (except as a hierarchy), and when we
// check_access() to a category, we're actually just checking if any of its children are accessible
-class admin_category implements part_of_admin_tree, parentable_part_of_admin_tree {
+class admin_category extends parentable_part_of_admin_tree {
var $children;
var $name;
function add($destinationname, &$something, $precedence = '') {
- if (!($something instanceof part_of_admin_tree)) {
+ if (!is_a($something, 'part_of_admin_tree')) {
return false;
}
}
foreach($this->children as $child) {
- if ($child instanceof parentable_part_of_admin_tree) {
+ if (is_a($child, 'parentable_part_of_admin_tree')) {
if ($child->add($destinationname, $something, $precedence)) {
return true;
}
// -start the page with a call to admin_externalpage_setup($name)
// -use admin_externalpage_print_header() to print the header & blocks
// -use admin_externalpage_print_footer() to print the footer
-class admin_externalpage implements part_of_admin_tree {
+class admin_externalpage extends part_of_admin_tree {
var $name;
var $visiblename;
// authentication happens at this level
// an admin_settingpage is a LEAF of the admin_tree, it can't have children. it only contains
// an array of admin_settings that can be printed out onto a webpage
-class admin_settingpage implements part_of_admin_tree {
+class admin_settingpage extends part_of_admin_tree {
var $name;
var $visiblename;
}
function add(&$setting) {
- if ($setting instanceof admin_setting) {
+ if (is_a($setting, 'admin_setting')) {
$temp = $setting->name;
$this->settings->$temp =& $setting;
return true;
var $paramtype;
- function admin_setting_configtext($name, $visiblename, $description, $paramtype = 'PARAM_RAW') {
+ function admin_setting_configtext($name, $visiblename, $description, $paramtype = PARAM_RAW) {
$this->paramtype = $paramtype;
parent::admin_setting($name, $visiblename, $description);
}
function write_setting($data) {
$data = clean_param($data, $this->paramtype);
- return (set_config($this->name,$data) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name,$data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
function write_setting($data) {
if ($data == '1') {
- return (set_config($this->name,1) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name,1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
} else {
- return (set_config($this->name,0) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name,0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
return 'Error setting ' . $this->visiblename . '<br />';
}
- return (set_config($this->name, $data) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
function write_setting($data) {
// check that what we got was in the original choices
if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
- return (set_config($this->name, $data['h']) && set_config($this->name2, $data['m']) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name, $data['h']) && set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
function write_setting($data) {
foreach ($data as $datum) {
if (! in_array($datum, array_keys($this->choices))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
}
- return (set_config($this->name, implode(',',$data)) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name, implode(',',$data)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
function write_setting($data) {
if (!in_array($data, array_keys($this->choices))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
$record = new stdClass();
$record->id = $this->id;
$temp = $this->name;
$record->$temp = $data;
$record->timemodified = time();
- return (update_record('course', $record) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
}
foreach($data as $datum) {
if (! in_array($datum, array_keys($this->choices))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
}
- return (set_config($this->name, implode(',', $data)) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name, implode(',', $data)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
$temp = $this->name;
$record->$temp = ($data == '1' ? 1 : 0);
$record->timemodified = time();
- return (update_record('course', $record) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
$temp = $this->name;
$record->$temp = $data;
$record->timemodified = time();
- return (update_record('course', $record) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
$record->$temp = $data;
$record->timemodified = time();
- return(update_record('course', $record) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return(update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
$result = substr($result, 0, -1); // trim the last semicolon
- return (set_config($this->name, $result) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
if (empty($data)) { $data = array(); }
foreach ($data as $key => $value) {
if (!in_array($key, array_keys($this->items))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
if ($value == '1') {
$result[] = $key;
}
}
- return (set_config($this->name, implode(' ',$result)) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name, implode(' ',$result)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
function write_setting($data) {
// check that what we got was in the original choices
if (! in_array($data, array_keys($this->choices))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
- return (backup_set_config($this->name, $data) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (backup_set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
} else if (!empty($data) and !is_dir($data)) {
return get_string('pathnotexists') . '<br />';
}
- return (backup_set_config($this->name, $data) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (backup_set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
function write_setting($data) {
if ($data == '1') {
- return (backup_set_config($this->name, 1) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (backup_set_config($this->name, 1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
} else {
- return (backup_set_config($this->name, 0) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (backup_set_config($this->name, 0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
function write_setting($data) {
// check that what we got was in the original choices
if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) {
- return 'Error setting ' . $this->visiblename . '<br />';
+ return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
}
- return (backup_set_config($this->name, $data['h']) && backup_set_config($this->name2, $data['m']) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (backup_set_config($this->name, $data['h']) && backup_set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
$result[strpos($week, $key)] = 1;
}
}
- return (backup_set_config($this->name, implode('',$result)) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (backup_set_config($this->name, implode('',$result)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
function write_setting($data) {
if ($data == '1') {
- return (set_config($this->name,15) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name,15) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
} else {
- return (set_config($this->name,7) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name,7) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
$result[strpos($week, $key)] = 1;
}
}
- return (set_config($this->name, bindec(implode('',$result))) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name, bindec(implode('',$result))) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
function output_html() {
function write_setting($data) {
if ($data == '1') {
- return (set_config($this->name,15) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name,15) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
} else {
- return (set_config($this->name,7) ? '' : 'Error setting ' . $this->visiblename . '<br />');
+ return (set_config($this->name,7) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
}
}
require_once($CFG->libdir . '/blocklib.php');
require_once($CFG->dirroot . '/admin/pagelib.php');
- // we really shouldn't do this... but it works. and it's so elegantly simple.
- // oh well :)
+
+ // this needs to be changed.
$_GET['section'] = $section;
define('TEMPORARY_ADMIN_PAGE_ID',26);
define('BLOCK_L_MIN_WIDTH',160);
define('BLOCK_L_MAX_WIDTH',210);
- $pagetype = PAGE_ADMIN; // erm... someone should check this. does
- $pageclass = 'page_admin'; // any of it duplicate the code I have in
- page_map_class($pagetype, $pageclass); // admin/pagelib.php?
+ $pagetype = PAGE_ADMIN;
+ $pageclass = 'page_admin';
+ page_map_class($pagetype, $pageclass);
$PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID);
die;
}
- if (!($root instanceof admin_externalpage)) {
+ if (!is_a($root, 'admin_externalpage')) {
error(get_string('sectionerror','admin'));
die;
}
die;
}
- $adminediting = optional_param('adminedit', PARAM_BOOL);
+ $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
if (!isset($USER->adminediting)) {
$USER->adminediting = true;
}
if ($PAGE->user_allowed_editing()) {
- if ($adminediting == 'on') {
+ if ($adminediting == 1) {
$USER->adminediting = true;
- } elseif ($adminediting == 'off') {
+ } elseif ($adminediting == 0) {
$USER->adminediting = false;
}
}
<?php // $Id$
require_once('../config.php');
-require_once($CFG->dirroot . '/admin/adminlib.php');
-
-// for external pages, most of this code is duplicated in the admin_externalpage_print_header()
-// and admin_externalpage_print_footer() functions... just include adminlib.php!
-//
-// lines marked //d at the end are handled (for other pages) by admin_externalpage_print_header()
-// and admin_externalpage_print_footer()
+require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
require_once($CFG->libdir . '/blocklib.php'); //d
-require_once($CFG->dirroot . '/admin/pagelib.php'); //d
+require_once($CFG->dirroot . '/' . $CFG->admin . '/pagelib.php'); //d
+
+if ($site = get_site()) {
+ require_login();
+}
+
+define('TEMPORARY_ADMIN_PAGE_ID',26);
+
+define('BLOCK_L_MIN_WIDTH',160);
+define('BLOCK_L_MAX_WIDTH',210);
-if ($site = get_site()) { //d
- require_login(); //d
-} //d
+$pagetype = PAGE_ADMIN;
+$pageclass = 'page_admin';
+page_map_class($pagetype, $pageclass);
-$adminediting = optional_param('adminedit', PARAM_BOOL);
+$PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID);
+
+$PAGE->init_full();
+
+$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
if (!isset($USER->adminediting)) {
$USER->adminediting = true;
}
if ($PAGE->user_allowed_editing()) {
- if ($adminediting == 'on') {
+ if ($adminediting == 1) {
$USER->adminediting = true;
- } elseif ($adminediting == 'off') {
+ } elseif ($adminediting == 0) {
$USER->adminediting = false;
}
}
-// Question: what pageid should be used for this?
-
-define('TEMPORARY_ADMIN_PAGE_ID',26); //d
+unset($root);
-define('BLOCK_L_MIN_WIDTH',160); //d
-define('BLOCK_L_MAX_WIDTH',210); //d
+$root = $ADMIN->locate($PAGE->section);
-$pagetype = PAGE_ADMIN; //d
-$pageclass = 'page_admin'; //d
-page_map_class($pagetype, $pageclass); //d
-
-$PAGE = page_create_object($pagetype,TEMPORARY_ADMIN_PAGE_ID); //d
-
-$PAGE->init_full(); //d
-
-unset($root); //d
-
-$root = $ADMIN->locate($PAGE->section); //d
-
-if (!($root instanceof admin_settingpage)) { //d
- error('Section does not exist, is invalid, or should not be accessed via this URL.'); //d
- die; //d
-} //d
+if (!is_a($root, 'admin_settingpage')) {
+ error(get_string('sectionerror', 'admin'));
+ die;
+}
-if (!($root->check_access())) { //d
- error('Access denied.'); //d
- die; //d
-} //d
+if (!($root->check_access())) {
+ error(get_string('accessdenied', 'admin'));
+ die;
+}
// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
if (empty($errors)) {
redirect("$CFG->wwwroot/admin/settings.php?section=" . $PAGE->section, get_string('changessaved'),1);
} else {
- error('The following errors occurred when trying to save settings: <br />' . $errors);
+ error(get_string('errorwithsettings', 'admin') . ' <br />' . $errors);
}
} else {
error(get_string('confirmsesskeybad', 'error'));
echo '<center><input type="submit" value="Save Changes" /></center>';
echo '</form>';
print_simple_box_end();
-echo '</td></tr></table>'; //d
+echo '</td></tr></table>';
-print_footer(); //d
+print_footer();
?>
\ No newline at end of file