* documentation started in adminlib.php

* default for block editing changed to "off" (bug in previous revisions)
* added defaults for all admin_setting's
This commit is contained in:
vinkmar 2006-08-28 01:31:37 +00:00
parent 49884e9702
commit d83f27cefe
3 changed files with 391 additions and 71 deletions

View File

@ -1,52 +1,253 @@
<?php // $Id$
//---------------------------------------------------------------------------------------------------
// Miscellaneous Header Stuff
//---------------------------------------------------------------------------------------------------
// n.b. documentation is still in progress for this code
/// INTRODUCTION
/// This file performs the following tasks:
/// -it defines the necessary objects and interfaces to build the Moodle
/// admin hierarchy
/// -it builds the $ADMIN global object (the admin tree)
/// -it defines the admin_externalpage_setup(), admin_externalpage_print_header(),
/// and admin_externalpage_print_footer() functions used on admin pages
/// ADMIN_SETTING OBJECTS
/// Moodle settings are represented by objects that inherit from the admin_setting
/// class. These objects encapsulate how to read a setting, how to write a new value
/// to a setting, and how to appropriately display the HTML to modify the setting.
/// ADMIN_SETTINGPAGE OBJECTS
/// The admin_setting objects are then grouped into admin_settingpages. The latter
/// appear in the Moodle admin tree block. All interaction with admin_settingpage
/// objects is handled by the admin/settings.php file.
/// ADMIN_EXTERNALPAGE OBJECTS
/// There are some settings in Moodle that are too complex to (efficiently) handle
/// with admin_settingpages. (Consider, for example, user management and displaying
/// lists of users.) In this case, we use the admin_externalpage object. This object
/// places a link to an external PHP file in the admin tree block.
/// If you're using an admin_externalpage object for some settings, you can take
/// advantage of the admin_externalpage_* functions. For example, suppose you wanted
/// to add a foo.php file into admin. First off, you add the following line to
/// admin/settings/first.php (at the end of the file) or to some other file in
/// admin/settings:
/// $ADMIN->add('userinterface', new admin_externalpage('foo', get_string('foo'),
/// $CFG->wwwdir . '/' . '$CFG->admin . '/foo.php', 'some_role_permission'));
/// Next, in foo.php, your file structure would resemble the following:
/// require_once('.../config.php');
/// require_once($CFG->dirroot . '/' . $CFG->admin . '/adminlib.php');
/// admin_externalpage_setup('foo');
/// // functionality like processing form submissions goes here
/// admin_externalpage_print_header();
/// // your HTML goes here
/// admin_externalpage_print_footer();
/// The admin_externalpage_setup() function call ensures the user is logged in,
/// and makes sure that they have the proper role permission to access the page.
/// The admin_externalpage_print_header() function prints the header (it figures
/// out what category and subcategories the page is classified under) and ensures
/// that you're using the admin pagelib (which provides the admin tree block and
/// the admin bookmarks block).
/// The admin_externalpage_print_footer() function properly closes the tables
/// opened up by the admin_externalpage_print_header() function and prints the
/// standard Moodle footer.
/// ADMIN_CATEGORY OBJECTS
/// Above and beyond all this, we have admin_category objects. These objects
/// appear as folders in the admin tree block. They contain admin_settingpage's,
/// admin_externalpage's, and other admin_category's.
/// OTHER NOTES
/// admin_settingpage's, admin_externalpage's, and admin_category's all inherit
/// from part_of_admin_tree (a pseudointerface). This interface insists that
/// a class has a check_access method for access permissions, a locate method
/// used to find a specific node in the $ADMIN tree, and a path method used
/// to determine the path to a specific node in the $ADMIN tree.
/// admin_category's inherit from parentable_part_of_admin_tree. This pseudo-
/// interface ensures that the class implements a recursive add function which
/// accepts a part_of_admin_tree object and searches for the proper place to
/// put it. parentable_part_of_admin_tree implies part_of_admin_tree.
/// Please note that the $this->name field of any part_of_admin_tree must be
/// UNIQUE throughout the ENTIRE admin tree.
/// The $this->name field of an admin_setting object (which is *not* part_of_
/// admin_tree) must be unique on the respective admin_settingpage where it is
/// used.
/// MISCELLANEOUS STUFF (used by classes defined below) ///////////////////////
include_once($CFG->dirroot . '/backup/lib.php');
//---------------------------------------------------------------------------------------------------
// Interfaces (pseudointerfaces, for PHP 4 compatibility)
//---------------------------------------------------------------------------------------------------
/// CLASS DEFINITIONS /////////////////////////////////////////////////////////
// part_of_admin_tree indicates that a node (whether it be an admin_settingpage or an
// admin_category or an admin_externalpage) is searchable
/**
* Pseudointerface for anything appearing in the admin tree
*
* The pseudointerface that is implemented by anything that appears in the admin tree
* block. It forces inheriting classes to define a method for checking user permissions
* and methods for finding something in the admin tree.
*
* @author Vincenzo K. Marcovecchio
* @package admin
*/
class part_of_admin_tree {
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; }
/**
* Finds a named part_of_admin_tree.
*
* Used to find a part_of_admin_tree. If a class only inherits part_of_admin_tree
* and not parentable_part_of_admin_tree, then this function should only check if
* $this->name matches $name. If it does, it should return a reference to $this,
* otherwise, it should return a reference to NULL.
*
* If a class inherits parentable_part_of_admin_tree, this method should be called
* recursively on all child objects (assuming, of course, the parent object's name
* doesn't match the search criterion).
*
* @param string $name The internal name of the part_of_admin_tree we're searching for.
* @return mixed An object reference or a NULL reference.
*/
function &locate($name) {
trigger_error('Admin class does not implement method <strong>locate()</strong>', E_USER_WARNING);
return;
}
/**
* Verifies current user's access to this part_of_admin_tree.
*
* Used to check if the current user has access to this part of the admin tree or
* not. If a class only inherits part_of_admin_tree and not parentable_part_of_admin_tree,
* then this method is usually just a call to has_capability() in the site context.
*
* If a class inherits parentable_part_of_admin_tree, this method should return the
* logical OR of the return of check_access() on all child objects.
*
* @return bool True if the user has access, false if she doesn't.
*/
function check_access() {
trigger_error('Admin class does not implement method <strong>check_access()</strong>', E_USER_WARNING);
return;
}
/**
* Determines the path to $name in the admin tree.
*
* Used to determine the path to $name in the admin tree. If a class inherits only
* part_of_admin_tree and not parentable_part_of_admin_tree, then this method should
* check if $this->name matches $name. If it does, $name is pushed onto the $path
* array (at the end), and $path should be returned. If it doesn't, NULL should be
* returned.
*
* If a class inherits parentable_part_of_admin_tree, it should do the above, but not
* return NULL on failure. Instead, it pushes $this->name onto $path, and then
* recursively calls path() on its child objects. If any are non-NULL, it should
* return $path (being certain that the last element of $path is equal to $name).
* If they are all NULL, it returns NULL.
*
* @param string $name The internal name of the part_of_admin_tree we're searching for.
* @param array $path Not used on external calls. Defaults to empty array.
* @return mixed If found, an array containing the internal names of each part_of_admin_tree that leads to $name. If not found, NULL.
*/
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)
/**
* Pseudointerface implemented by any part_of_admin_tree that has children.
*
* The pseudointerface implemented by any part_of_admin_tree that can be a parent
* to other part_of_admin_tree's. (For now, this only includes admin_category.) Apart
* from ensuring part_of_admin_tree compliancy, it also ensures inheriting methods
* include an add method for adding other part_of_admin_tree objects as children.
*
* @author Vincenzo K. Marcovecchio
* @package admin
*/
class parentable_part_of_admin_tree extends part_of_admin_tree {
function add($destinationname, &$something) { trigger_error('Admin class does not implement method <strong>add()</strong>', E_USER_WARNING); return; }
/**
* Adds a part_of_admin_tree object to the admin tree.
*
* Used to add a part_of_admin_tree object to this object or a child of this
* object. $something should only be added if $destinationname matches
* $this->name. If it doesn't, add should be called on child objects that are
* also parentable_part_of_admin_tree's.
*
* @param string $destinationname The internal name of the new parent for $something.
* @param part_of_admin_tree &$something The object to be added.
* @return bool True on success, false on failure.
*/
function add($destinationname, &$something) {
trigger_error('Admin class does not implement method <strong>add()</strong>', E_USER_WARNING);
return;
}
}
//---------------------------------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------------------------------
// 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
/**
* The object used to represent folders (a.k.a. categories) in the admin tree block.
*
* Each admin_category object contains a number of part_of_admin_tree objects.
*
* @author Vincenzo K. Marcovecchio
* @package admin
*/
class admin_category extends parentable_part_of_admin_tree {
/**
* @var mixed An array of part_of_admin_tree objects that are this object's children
*/
var $children;
/**
* @var string An internal name for this category. Must be unique amongst ALL part_of_admin_tree objects
*/
var $name;
/**
* @var string The displayed name for this category. Usually obtained through get_string()
*/
var $visiblename;
// constructor for an empty admin category
// $name is the internal name of the category. it MUST be unique in the entire hierarchy
// $visiblename is the displayed name of the category. use a get_string for this
/**
* Constructor for an empty admin category
*
* @param string $name The internal name for this category. Must be unique amongst ALL part_of_admin_tree objects
* @param string $visiblename The displayed named for this category. Usually obtained through get_string()
* @return mixed Returns the new object.
*/
function admin_category($name, $visiblename) {
$this->children = array();
$this->name = $name;
$this->visiblename = $visiblename;
}
/**
* Finds the path to the part_of_admin_tree called $name.
*
* @param string $name The internal name that we're searching for.
* @param array $path Used internally for recursive calls. Do not specify on external calls. Defaults to array().
* @return mixed An array of internal names that leads to $name, or NULL if not found.
*/
function path($name, $path = array()) {
$path[count($path)] = $this->name;
@ -65,6 +266,12 @@ class admin_category extends parentable_part_of_admin_tree {
}
/**
* Returns a reference to the part_of_admin_tree object with internal name $name.
*
* @param string $name The internal name of the object we want.
* @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
*/
function &locate($name) {
if ($this->name == $name) {
@ -80,6 +287,14 @@ class admin_category extends parentable_part_of_admin_tree {
return $return;
}
/**
* Adds a part_of_admin_tree to a child or grandchild (or great-grandchild, and so forth) of this object.
*
* @param string $destinationame The internal name of the immediate parent that we want for &$something.
* @param mixed &$something A part_of_admin_tree object to be added.
* @param int $precedence The precedence of &$something when displayed. Smaller numbers mean it'll be displayed higher up in the admin menu. Defaults to '', meaning "next available position".
* @return bool True if successfully added, false if &$something is not a part_of_admin_tree or if $name is not found.
*/
function add($destinationname, &$something, $precedence = '') {
if (!is_a($something, 'part_of_admin_tree')) {
@ -115,6 +330,11 @@ class admin_category extends parentable_part_of_admin_tree {
}
/**
* Checks if the user has access to anything in this category.
*
* @return bool True if the user has access to atleast one child in this category, false otherwise.
*/
function check_access() {
$return = false;
@ -128,19 +348,44 @@ class admin_category extends parentable_part_of_admin_tree {
}
// this is the class we use to add an external page to the admin hierarchy. on the
// external page (if you'd like), do the following for a consistent look & feel:
// -require_once admin/adminlib.php
// -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
/**
* Links external PHP pages into the admin tree.
*
* See detailed usage example at the top of this document (adminlib.php)
*
* @author Vincenzo K. Marcovecchio
* @package admin
*/
class admin_externalpage extends part_of_admin_tree {
/**
* @var string An internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects
*/
var $name;
/**
* @var string The displayed name for this external page. Usually obtained through get_string().
*/
var $visiblename;
/**
* @var string The external URL that we should link to when someone requests this external page.
*/
var $url;
/**
* @var string The role capability/permission a user must have to access this external page.
*/
var $role;
/**
* Constructor for adding an external page into the admin tree.
*
* @param string $name The internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects.
* @param string $visiblename The displayed name for this external page. Usually obtained through get_string().
* @param string $url The external URL that we should link to when someone requests this external page.
* @param string $role The role capability/permission a user must have to access this external page. Defaults to 'moodle/legacy:admin'.
*/
function admin_externalpage($name, $visiblename, $url, $role = 'moodle/legacy:admin') {
$this->name = $name;
$this->visiblename = $visiblename;
@ -148,6 +393,13 @@ class admin_externalpage extends part_of_admin_tree {
$this->role = $role;
}
/**
* Finds the path to the part_of_admin_tree called $name.
*
* @param string $name The internal name that we're searching for.
* @param array $path Used internally for recursive calls. Do not specify on external calls. Defaults to array().
* @return mixed An array of internal names that leads to $name, or NULL if not found.
*/
function path($name, $path = array()) {
if ($name == $this->name) {
array_push($path, $this->name);
@ -157,11 +409,24 @@ class admin_externalpage extends part_of_admin_tree {
}
}
/**
* Returns a reference to the part_of_admin_tree object with internal name $name.
*
* @param string $name The internal name of the object we want.
* @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
*/
function &locate($name) {
$return = ($this->name == $name ? $this : NULL);
return $return;
}
/**
* Determines if the current user has access to this external page based on $this->role.
*
* @uses CONTEXT_SYSTEM
* @uses SITEID
* @return bool True if user has access, false otherwise.
*/
function check_access() {
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
return has_capability($this->role, $context);
@ -169,16 +434,34 @@ class admin_externalpage extends part_of_admin_tree {
}
// 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
/**
* Used to group a number of admin_setting objects into a page and add them to the admin tree.
*
* @author Vincenzo K. Marcovecchio
* @package admin
*/
class admin_settingpage extends part_of_admin_tree {
/**
* @var string An internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects
*/
var $name;
/**
* @var string The displayed name for this external page. Usually obtained through get_string().
*/
var $visiblename;
/**
* @var mixed An array of admin_setting objects that are part of this setting page.
*/
var $settings;
/**
* @var string The role capability/permission a user must have to access this external page.
*/
var $role;
// see admin_category
function path($name, $path = array()) {
if ($name == $this->name) {
array_push($path, $this->name);
@ -188,11 +471,13 @@ class admin_settingpage extends part_of_admin_tree {
}
}
// see admin_category
function &locate($name) {
$return = ($this->name == $name ? $this : NULL);
return $return;
}
// see admin_externalpage
function admin_settingpage($name, $visiblename, $role = 'moodle/legacy:admin') {
global $CFG;
$this->settings = new stdClass();
@ -201,6 +486,10 @@ class admin_settingpage extends part_of_admin_tree {
$this->role = $role;
}
// not the same as add for admin_category. adds an admin_setting to this admin_settingpage. settings appear (on the settingpage) in the order in which they're added
// n.b. each admin_setting in an admin_settingpage must have a unique internal name
// &$setting is the admin_setting object you want to add
// returns true if successful, false if not (will fail if &$setting is an admin_setting or child thereof)
function add(&$setting) {
if (is_a($setting, 'admin_setting')) {
$this->settings->{$setting->name} =& $setting;
@ -209,11 +498,14 @@ class admin_settingpage extends part_of_admin_tree {
return false;
}
// see admin_externalpage
function check_access() {
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
return has_capability($this->role, $context);
}
// outputs this page as html in a table (suitable for inclusion in an admin pagetype)
// returns a string of the html
function output_html() {
$return = '<table class="generaltable" width="100%" border="0" align="center" cellpadding="5" cellspacing="1">' . "\n";
foreach($this->settings as $setting) {
@ -223,7 +515,10 @@ class admin_settingpage extends part_of_admin_tree {
return $return;
}
// return '' (empty string) for successful write, otherwise return language-specific error
// writes settings (the ones that have been added to this admin_settingpage) to the database, or wherever else they're supposed to be written to
// -- calls write_setting() to each child setting, sending it only the data that matches each setting's internal name
// $data should be the result from data_submitted()
// returns an empty string if everything went well, otherwise returns a printable error string (that's language-specific)
function write_settings($data) {
$return = '';
foreach($this->settings as $setting) {
@ -245,12 +540,13 @@ class admin_setting {
var $name;
var $visiblename;
var $description;
var $data;
var $defaultsetting;
function admin_setting($name, $visiblename, $description) {
function admin_setting($name, $visiblename, $description, $defaultsetting) {
$this->name = $name;
$this->visiblename = $visiblename;
$this->description = $description;
$this->defaultsetting = $defaultsetting;
}
function get_setting() {
@ -272,9 +568,9 @@ class admin_setting_configtext extends admin_setting {
var $paramtype;
function admin_setting_configtext($name, $visiblename, $description, $paramtype) {
function admin_setting_configtext($name, $visiblename, $description, $defaultsetting, $paramtype) {
$this->paramtype = $paramtype;
parent::admin_setting($name, $visiblename, $description);
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
function get_setting() {
@ -297,8 +593,8 @@ class admin_setting_configtext extends admin_setting {
class admin_setting_configcheckbox extends admin_setting {
function admin_setting_configcheckbox($name, $visiblename, $description) {
parent::admin_setting($name, $visiblename, $description);
function admin_setting_configcheckbox($name, $visiblename, $description, $defaultsetting) {
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
function get_setting() {
@ -326,9 +622,9 @@ class admin_setting_configselect extends admin_setting {
var $choices;
function admin_setting_configselect($name, $visiblename, $description, $choices) {
function admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices) {
$this->choices = $choices;
parent::admin_setting($name, $visiblename, $description);
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
function get_setting() {
@ -363,8 +659,9 @@ class admin_setting_configtime extends admin_setting {
var $name2;
var $choices;
var $choices2;
var $defaultsetting2;
function admin_setting_configtime($hoursname, $minutesname, $visiblename, $description) {
function admin_setting_configtime($hoursname, $minutesname, $visiblename, $description, $defaultsetting) {
$this->name2 = $minutesname;
$this->choices = array();
for ($i = 0; $i < 24; $i++) {
@ -374,7 +671,7 @@ class admin_setting_configtime extends admin_setting {
for ($i = 0; $i < 60; $i += 5) {
$this->choices2[$i] = $i;
}
parent::admin_setting($hoursname, $visiblename, $description);
parent::admin_setting($hoursname, $visiblename, $description, $defaultsetting);
}
function get_setting() {
@ -412,8 +709,8 @@ class admin_setting_configtime extends admin_setting {
class admin_setting_configmultiselect extends admin_setting_configselect {
function admin_setting_configmultiselect($name, $visiblename, $description, $choices) {
parent::admin_setting_configselect($name, $visiblename, $description, $choices);
function admin_setting_configmultiselect($name, $visiblename, $description, $defaultsetting, $choices) {
parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices);
}
function get_setting() {
@ -452,7 +749,7 @@ class admin_setting_special_adminseesall extends admin_setting_configcheckbox {
$name = 'calendar_adminseesall';
$visiblename = get_string('adminseesall', 'admin');
$description = get_string('helpadminseesall', 'admin');
parent::admin_setting($name, $visiblename, $description);
parent::admin_setting($name, $visiblename, $description, 0);
}
function write_setting($data) {
@ -466,11 +763,11 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
var $id;
function admin_setting_sitesetselect($name, $visiblename, $description, $choices) {
function admin_setting_sitesetselect($name, $visiblename, $description, $defaultsetting, $choices) {
$site = get_site();
$this->id = $site->id;
parent::admin_setting_configselect($name, $visiblename, $description, $choices);
parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices);
}
@ -510,7 +807,7 @@ class admin_setting_special_frontpage extends admin_setting_configselect {
if (count_records("course") > FRONTPAGECOURSELIMIT) {
unset($choices[FRONTPAGECOURSELIST]);
}
parent::admin_setting_configselect($name, $visiblename, $description, $choices);
parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
}
function get_setting() {
@ -563,11 +860,11 @@ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
var $id;
function admin_setting_sitesetcheckbox($name, $visiblename, $description) {
function admin_setting_sitesetcheckbox($name, $visiblename, $description, $defaultsetting) {
$site = get_site();
$this->id = $site->id;
parent::admin_setting_configcheckbox($name, $visiblename, $description);
parent::admin_setting_configcheckbox($name, $visiblename, $description, $defaultsetting);
}
@ -591,11 +888,11 @@ class admin_setting_sitesettext extends admin_setting_configtext {
var $id;
function admin_setting_sitesettext($name, $visiblename, $description, $paramtype) {
function admin_setting_sitesettext($name, $visiblename, $description, $defaultsetting, $paramtype) {
$site = get_site();
$this->id = $site->id;
parent::admin_setting_configtext($name, $visiblename, $description, $paramtype);
parent::admin_setting_configtext($name, $visiblename, $description, $defaultsetting, $paramtype);
}
@ -625,7 +922,7 @@ class admin_setting_special_frontpagedesc extends admin_setting {
$name = 'summary';
$visiblename = get_string('frontpagedescription');
$description = get_string('frontpagedescriptionhelp');
parent::admin_setting($name, $visiblename, $description);
parent::admin_setting($name, $visiblename, $description, '');
}
function output_html() {
@ -691,7 +988,26 @@ class admin_setting_special_editorfontlist extends admin_setting {
} else {
$items = NULL;
}
parent::admin_setting($name, $visiblename, $description);
unset($defaults);
$defaults = array('k0' => 'Trebuchet',
'v0' => 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif',
'k1' => 'Arial',
'v1' => 'arial,helvetica,sans-serif',
'k2' => 'Courier New',
'v2' => 'courier new,courier,monospace',
'k3' => 'Georgia',
'v3' => 'georgia,times new roman,times,serif',
'k4' => 'Tahoma',
'v4' => 'tahoma,arial,helvetica,sans-serif',
'k5' => 'Times New Roman',
'v5' => 'times new roman,times,serif',
'k6' => 'Verdana',
'v6' => 'verdana,arial,helvetica,sans-serif',
'k7' => 'Impact',
'v7' => 'impact',
'k8' => 'Wingdings',
'v8' => 'wingdings');
parent::admin_setting($name, $visiblename, $description, $defaults);
}
function get_setting() {
@ -701,6 +1017,8 @@ class admin_setting_special_editorfontlist extends admin_setting {
function write_setting($data) {
// there miiight be an easier way to do this :)
// if this is changed, make sure the $defaults array above is modified so that this
// function processes it correctly
$keys = array();
$values = array();
@ -761,7 +1079,7 @@ class admin_setting_special_editordictionary extends admin_setting_configselect
$choices = array('');
}
parent::admin_setting_configselect($name, $visiblename, $description, $choices);
parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
}
// function borrowed from the old moodle/admin/editor.php, slightly modified
@ -834,6 +1152,7 @@ class admin_setting_special_editorhidebuttons extends admin_setting {
$this->name = 'editorhidebuttons';
$this->visiblename = get_string('editorhidebuttons', 'admin');
$this->description = get_string('confeditorhidebuttons', 'admin');
$this->defaultsetting = array();
// weird array... buttonname => buttonimage (assume proper path appended). if you leave buttomimage blank, text will be printed instead
$this->items = array('fontname' => '',
'fontsize' => '',
@ -937,8 +1256,8 @@ class admin_setting_special_editorhidebuttons extends admin_setting {
class admin_setting_backupselect extends admin_setting_configselect {
function admin_setting_backupselect($name, $visiblename, $description, $choices) {
parent::admin_setting_configselect($name, $visiblename, $description, $choices);
function admin_setting_backupselect($name, $visiblename, $description, $default, $choices) {
parent::admin_setting_configselect($name, $visiblename, $description, $default, $choices);
}
function get_setting() {
@ -963,7 +1282,7 @@ class admin_setting_special_backupsaveto extends admin_setting_configtext {
$name = 'backup_sche_destination';
$visiblename = get_string('saveto');
$description = get_string('backupsavetohelp');
parent::admin_setting_configtext($name, $visiblename, $description, PARAM_PATH);
parent::admin_setting_configtext($name, $visiblename, $description, '', PARAM_PATH);
}
function get_setting() {
@ -985,8 +1304,8 @@ class admin_setting_special_backupsaveto extends admin_setting_configtext {
class admin_setting_backupcheckbox extends admin_setting_configcheckbox {
function admin_setting_backupcheckbox($name, $visiblename, $description) {
parent::admin_setting_configcheckbox($name, $visiblename, $description);
function admin_setting_backupcheckbox($name, $visiblename, $description, $default) {
parent::admin_setting_configcheckbox($name, $visiblename, $description, $default);
}
function write_setting($data) {
@ -1011,7 +1330,8 @@ class admin_setting_special_backuptime extends admin_setting_configtime {
$name2 = 'backup_sche_minute';
$visiblename = get_string('executeat');
$description = get_string('backupexecuteathelp');
parent::admin_setting_configtime($name, $name2, $visiblename, $description);
$default = array('h' => 0, 'm' => 0);
parent::admin_setting_configtime($name, $name2, $visiblename, $description, $default);
}
function get_setting() {
@ -1036,7 +1356,7 @@ class admin_setting_special_backupdays extends admin_setting {
$name = 'backup_sche_weekdays';
$visiblename = get_string('schedule');
$description = get_string('backupschedulehelp');
parent::admin_setting($name, $visiblename, $description);
parent::admin_setting($name, $visiblename, $description, array());
}
function get_setting() {
@ -1089,7 +1409,7 @@ class admin_setting_special_debug extends admin_setting_configcheckbox {
$name = 'debug';
$visiblename = get_string('debug', 'admin');
$description = get_string('configdebug', 'admin');
parent::admin_setting_configcheckbox($name, $visiblename, $description);
parent::admin_setting_configcheckbox($name, $visiblename, $description, '');
}
function write_setting($data) {
@ -1115,7 +1435,7 @@ class admin_setting_special_calendar_weekend extends admin_setting {
$name = 'calendar_weekend';
$visiblename = get_string('calendar_weekend', 'admin');
$description = get_string('helpweekenddays', 'admin');
parent::admin_setting($name, $visiblename, $description);
parent::admin_setting($name, $visiblename, $description, array('u' => 1, 's' => 1));
}
function get_setting() {
@ -1171,7 +1491,7 @@ class admin_setting_special_perfdebug extends admin_setting_configcheckbox {
$name = 'perfdebug';
$visiblename = get_string('perfdebug', 'admin');
$description = get_string('configperfdebug', 'admin');
parent::admin_setting_configcheckbox($name, $visiblename, $description);
parent::admin_setting_configcheckbox($name, $visiblename, $description, '');
}
function write_setting($data) {
@ -1235,7 +1555,7 @@ function admin_externalpage_setup($section) {
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
if (!isset($USER->adminediting)) {
$USER->adminediting = true;
$USER->adminediting = false;
}
if ($PAGE->user_allowed_editing()) {

View File

@ -39,7 +39,7 @@ class page_admin extends page_base {
}
function blocks_get_default() {
return 'admin_2';
return 'admin_2,admin_bookmarks';
}
// seems reasonable that the only people that can edit blocks on the admin pages
@ -105,4 +105,4 @@ class page_admin extends page_base {
}
}
?>
?>

View File

@ -27,7 +27,7 @@ $PAGE->init_full($section);
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
if (!isset($USER->adminediting)) {
$USER->adminediting = true;
$USER->adminediting = false;
}
if ($PAGE->user_allowed_editing()) {
@ -89,8 +89,8 @@ print_simple_box_start('','100%','',5,'generalbox','');
echo $root->output_html();
echo '<center><input type="submit" value="Save Changes" /></center>';
echo '</form>';
print_simple_box_end();
echo '</form>';
echo '</td></tr></table>';
print_footer();