-<?php //$Id$
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* adminlib.php - Contains functions that only administrators will ever need to use
*
- * @author Martin Dougiamas and many others
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
+ * Administration tree classes and functions
+ * 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 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:
+ * <code>
+ * $ADMIN->add('userinterface', new admin_externalpage('foo', get_string('foo'),
+ * $CFG->wwwdir . '/' . '$CFG->admin . '/foo.php', 'some_role_permission'));
+ * </code>
+ *
+ * Next, in foo.php, your file structure would resemble the following:
+ * <code>
+ * require_once('.../config.php');
+ * require_once($CFG->libdir.'/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();
+ * </code>
+ *
+ * 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 find parent path.
+ *
+ * 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.
+ *
+ * Key Author: Vincenzo K. Marcovecchio
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/// Add libraries
+/**
+ * Include the essential files
+ */
require_once($CFG->libdir.'/ddllib.php');
require_once($CFG->libdir.'/xmlize.php');
require_once($CFG->libdir.'/messagelib.php'); // Messagelib functions
define('INSECURE_DATAROOT_WARNING', 1);
define('INSECURE_DATAROOT_ERROR', 2);
-
+
/**
* Delete all plugin tables
- * @name string name of plugin, used as table prefix
- * @file string path to install.xml file
- * @feedback boolean
+ *
+ * @global object
+ * @global object
+ * @param string $name Name of plugin, used as table prefix
+ * @param string $file Path to install.xml file
+ * @param bool $feedback defaults to true
+ * @return boolean Always returns true
*/
function drop_plugin_tables($name, $file, $feedback=true) {
global $CFG, $DB;
/**
* Returns names of all known tables == tables that moodle knowns about.
- * @return array of lowercase table names
+ *
+ * @return array Array of lowercase table names
*/
function get_used_table_names() {
$table_names = array();
/**
* Lists all plugin types
- * @return array of strings - name=>location
+ *
+ * @global object
+ * @return array Array of strings - name=>location
*/
function get_plugin_types() {
global $CFG;
/**
* Returns list of all directories where we expect install.xml files
- * @return array of paths
+ *
+ * @global object
+ * @return array Array of paths
*/
function get_db_directories() {
global $CFG;
/**
* Try to obtain or release the cron lock.
*
+ * @global object
* @param string $name name of lock
* @param int $until timestamp when this lock considered stale, null means remove lock unconditionaly
- * @param bool $ignorecurrent ignore current lock state, usually entend previous lock
+ * @param bool $ignorecurrent ignore current lock state, usually entend previous lock, defaults to false
* @return bool true if lock obtained
*/
function set_cron_lock($name, $until, $ignorecurrent=false) {
/**
* Test if and critical warnings are present
+ *
+ * @global object
* @return bool
*/
function admin_critical_warnings_present() {
}
/**
- * Detects if float support at least 10 deciman digits
+ * Detects if float supports at least 10 decimal digits
+ *
+ * Detects if float supports at least 10 deciman digits
* and also if float-->string conversion works as expected.
+ *
* @return bool true if problem found
*/
function is_float_problem() {
/**
* Try to verify that dataroot is not accessible from web.
- * It is not 100% correct but might help to reduce number of vulnerable sites.
*
+ * Try to verify that dataroot is not accessible from web.
+ * It is not 100% correct but might help to reduce number of vulnerable sites.
* Protection from httpd.conf and .htaccess is not detected properly.
- * @param bool $fetchtest try to test public access by fetching file
+ *
+ * @global object
+ * @uses INSECURE_DATAROOT_WARNING
+ * @uses INSECURE_DATAROOT_ERROR
+ * @param bool $fetchtest try to test public access by fetching file, default false
* @return mixed empty means secure, INSECURE_DATAROOT_ERROR found a critical problem, INSECURE_DATAROOT_WARNING migth be problematic
*/
function is_dataroot_insecure($fetchtest=false) {
return INSECURE_DATAROOT_WARNING;
}
-/// =============================================================================================================
-/// administration tree classes and functions
-
-
-// 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 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->libdir.'/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 find parent path.
-
-/// 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.
-
-
/// CLASS DEFINITIONS /////////////////////////////////////////////////////////
/**
* 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
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
interface part_of_admin_tree {
/**
* Search using query
- * @param strin query
+ * @param string $query
* @return mixed array-object structure of found settings and pages
*/
public function search($query);
* 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
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
interface parentable_part_of_admin_tree extends part_of_admin_tree {
*
* Each admin_category object contains a number of part_of_admin_tree objects.
*
- * @author Vincenzo K. Marcovecchio
- * @package admin
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_category implements parentable_part_of_admin_tree {
/**
* paths
+ * @var mixed Either a string or an array or strings
*/
public $path;
public $visiblepath;
*
* @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()
- * @param bool $hidden hide category in admin tree block
+ * @param bool $hidden hide category in admin tree block, defaults to false
*/
public function __construct($name, $visiblename, $hidden=false) {
$this->children = array();
*
* @param string $name The internal name of the object we want.
* @param bool $findpath initialize path and visiblepath arrays
- * @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
+ * @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
+ * defaults to false
*/
public function locate($name, $findpath=false) {
if ($this->name == $name) {
/**
* Search using query
- * @param strin query
+ *
+ * @param string query
* @return mixed array-object structure of found settings and pages
*/
public function search($query) {
}
}
+/**
+ *
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_root extends admin_category {
- /** list of errors */
+ /**
+ * @var array List of errors
+ */
public $errors;
- /** search query */
+ /**
+ * @var string search query
+ */
public $search;
- /** full tree flag - true means all settings required, false onlypages required */
+ /**
+ * @var bool full tree flag - true means all settings required,
+ * false onlypages required
+ */
public $fulltree;
- /** flag indicating loaded tree */
+ /**
+ * @var bool flag indicating loaded tree
+ */
public $loaded;
- /** site custom defaults overriding defaults in setings files */
+ /**
+ * @var mixed site custom defaults overriding defaults in setings files
+ */
public $custom_defaults;
+ /**
+ * @global object
+ * @param bool $fulltree true means all settings required,
+ * false only pages required
+ */
public function __construct($fulltree) {
global $CFG;
}
}
+ /**
+ * Empties children array, and sets loaded to false
+ *
+ * @param bool $requirefulltree
+ */
public function purge_children($requirefulltree) {
$this->children = array();
$this->fulltree = ($requirefulltree || $this->fulltree);
*
* See detailed usage example at the top of this document (adminlib.php)
*
- * @author Vincenzo K. Marcovecchio
- * @package admin
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_externalpage implements part_of_admin_tree {
public $hidden;
/**
- * visible path
+ * @var mixed either string or array of string
*/
public $path;
public $visiblepath;
* 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.
+ * @param bool $findpath defaults to false
* @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
*/
public function locate($name, $findpath=false) {
}
}
+ /**
+ * This function always returns false, required function by interface
+ *
+ * @param string $name
+ * @return false
+ */
public function prune($name) {
return false;
}
/**
* Search using query
- * @param strin query
+ *
+ * @param string $query
* @return mixed array-object structure of found settings and pages
*/
public function search($query) {
/**
* Determines if the current user has access to this external page based on $this->req_capability.
+ *
+ * @global object
* @return bool True if user has access, false otherwise.
*/
public function check_access() {
/**
* Is this external page hidden in admin tree block?
*
+ * Returns the 'hidden' property
+ *
* @return bool True if hidden
*/
public function is_hidden() {
/**
* 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
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_settingpage implements part_of_admin_tree {
public $hidden;
/**
- * paths
+ * @var mixed string of paths or array of strings of paths
*/
public $path;
public $visiblepath;
- // see admin_externalpage
+ /**
+ * see admin_settingpage for details of this function
+ *
+ * @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 mixed $req_capability The role capability/permission a user must have to access this external page. Defaults to 'moodle/site:config'.
+ * @param boolean $hidden Is this external page hidden in admin tree block? Default false.
+ * @param context $context The context the page relates to. Not sure what happens
+ * if you specify something other than system or front page. Defaults to system.
+ */
public function __construct($name, $visiblename, $req_capability='moodle/site:config', $hidden=false, $context=NULL) {
$this->settings = new object();
$this->name = $name;
$this->context = $context;
}
- // see admin_category
+ /**
+ * see admin_category
+ *
+ * @param string $name
+ * @param bool $findpath
+ * @return mixed Object (this) if name == this->name, else returns null
+ */
public function locate($name, $findpath=false) {
if ($this->name == $name) {
if ($findpath) {
}
}
+ /*
+ * @param string $query
+ * @return array
+ */
public function search($query) {
$found = array();
}
}
+ /**
+ * This function always returns false, required by interface
+ *
+ * @param string $name
+ * @return bool Always false
+ */
public function prune($name) {
return false;
}
/**
+ * adds an admin_setting to this admin_settingpage
+ *
* 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
+ *
* @param object $setting is the admin_setting object you want to add
- * @return true if successful, false if not
+ * @return bool true if successful, false if not
*/
public function add($setting) {
if (!($setting instanceof admin_setting)) {
return true;
}
- // see admin_externalpage
+ /**
+ * see admin_externalpage
+ *
+ * @return bool Returns true for yes false for no
+ */
public function check_access() {
global $CFG;
$context = empty($this->context) ? get_context_instance(CONTEXT_SYSTEM) : $this->context;
/**
* outputs this page as html in a table (suitable for inclusion in an admin pagetype)
- * returns a string of the html
+ * @return string Returns an XHTML string
*/
public function output_html() {
$adminroot = admin_get_root();
/**
* Admin settings class. Only exists on setting pages.
* Read & write happens at this level; no authentication.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
abstract class admin_setting {
-
+ /**
+ * @var string unique ascii name, either 'mysetting' for settings that in config,
+ * or 'myplugin/mysetting' for ones in config_plugins.
+ */
public $name;
+ /**
+ * @var string localised name
+ */
public $visiblename;
+ /**
+ * @var string localised long description
+ */
public $description;
+ /**
+ * @var mixed Can be string or array of string
+ */
public $defaultsetting;
+ /**
+ * @var string
+ */
public $updatedcallback;
+ /**
+ * @var mixed can be String or Null. Null means main config table
+ */
public $plugin; // null means main config table
/**
* Constructor
- * @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins.
+ * @param string $name unique ascii name, either 'mysetting' for settings that in config,
+ * or 'myplugin/mysetting' for ones in config_plugins.
* @param string $visiblename localised name
* @param string $description localised long description
* @param mixed $defaultsetting string or array depending on implementation
}
/**
+ * Set up $this->name and potentially $this->plugin
+ *
* Set up $this->name and possibly $this->plugin based on whether $name looks
* like 'settingname' or 'plugin/settingname'. Also, do some sanity checking
* on the names, that is, output a developer debug warning if the name
}
}
+ /**
+ * Returns the fullname prefixed by the plugin
+ * @return string
+ */
public function get_full_name() {
return 's_'.$this->plugin.'_'.$this->name;
}
+ /**
+ * Returns the ID string based on plugin and name
+ * @return string
+ */
public function get_id() {
return 'id_s_'.$this->plugin.'_'.$this->name;
}
+ /**
+ * Returns the config if possible
+ *
+ * @global object
+ * @return mixed returns config if successfull else null
+ */
public function config_read($name) {
global $CFG;
if (!empty($this->plugin)) {
}
/**
+ * Used to set a config pair and log change
*
- * @param <type> $name
- * @param <type> $value
- * @return <type> Write setting to confix table
+ * @global object
+ * @global object
+ * @global object
+ * @param string $name
+ * @param mixed $value Gets converted to string if not null
+ * @return bool Write setting to confix table
*/
public function config_write($name, $value) {
global $DB, $USER, $CFG;
/**
* Store new setting
- * @param mixed string or array, must not be NULL
- * @return '' if ok, string error message otherwise
+ *
+ * @param mixed $data string or array, must not be NULL
+ * @return string empty string if ok, string error message otherwise
*/
public abstract function write_setting($data);
/**
* Return part of form with setting
- * @param mixed data array or string depending on setting
+ * This function should always be overwritten
+ *
+ * @param mixed $data array or string depending on setting
+ * @param string $query
* @return string
*/
public function output_html($data, $query='') {
}
/**
- * function called if setting updated - cleanup, cache reset, etc.
+ * Function called if setting updated - cleanup, cache reset, etc.
+ * @param string $functionname Sets the function name
*/
public function set_updatedcallback($functionname) {
$this->updatedcallback = $functionname;
/**
* No setting - just heading and text.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_heading extends admin_setting {
/**
parent::__construct($name, $heading, $information, '');
}
+ /**
+ * Always returns true
+ * @return bool Always returns true
+ */
public function get_setting() {
return true;
}
+ /**
+ * Always returns true
+ * @return bool Always returns true
+ */
public function get_defaultsetting() {
return true;
}
+ /**
+ * Never write settings
+ * @return string Always returns an empty string
+ */
public function write_setting($data) {
// do not write any setting
return '';
}
-
+
+ /**
+ * Returns an HTML string
+ * @return string Returns an HTML string
+ */
public function output_html($data, $query='') {
$return = '';
if ($this->visiblename != '') {
/**
* The most flexibly setting, user is typing text
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configtext extends admin_setting {
+ /**
+ * @var mixed int means PARAM_XXX type, string is a allowed format in regex
+ */
public $paramtype;
+ /**
+ * @var int default field size
+ */
public $size;
/**
- * config text contructor
+ * Config text contructor
+ *
* @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins.
* @param string $visiblename localised
* @param string $description long localised info
parent::__construct($name, $visiblename, $description, $defaultsetting);
}
+ /**
+ * Return the setting
+ *
+ * @return mixed returns config if successfull else null
+ */
public function get_setting() {
return $this->config_read($this->name);
}
}
}
+ /**
+ * Return an XHTML string for the setting
+ * @return string Returns an XHTML string
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
/**
* General text area without html editor.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configtextarea extends admin_setting_configtext {
+ /**
+ * @var string Represents the number of rows/cols to make the editor
+ */
public $rows;
public $cols;
+ /**
+ * @param string $name
+ * @param string $visiblename
+ * @param string $description
+ * @param mixed $defaultsetting string or array
+ * @param mixed $paramtype
+ * @param string $cols The number of columns to make the editor
+ * @param string $rows The number of rows to make the editor
+ */
public function __construct($name, $visiblename, $description, $defaultsetting, $paramtype=PARAM_RAW, $cols='60', $rows='8') {
$this->rows = $rows;
$this->cols = $cols;
parent::__construct($name, $visiblename, $description, $defaultsetting, $paramtype);
}
-
+ /**
+ * Returns an XHTML string for the editor
+ *
+ * @param string $data
+ * @param string $query
+ * @return string XHTML string for the editor
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
/**
* Password field, allows unmasking of password
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configpasswordunmask extends admin_setting_configtext {
/**
public function __construct($name, $visiblename, $description, $defaultsetting) {
parent::__construct($name, $visiblename, $description, $defaultsetting, PARAM_RAW, 30);
}
-
+
+ /**
+ * Returns XHTML for the field
+ * Writes Javascript into the HTML below right before the last div
+ *
+ * @todo Make javascript available through newer methods if possible
+ * @param string $data Value for the field
+ * @param string $query Passed as final argument for format_admin_setting
+ * @return string XHTML field
+ */
public function output_html($data, $query='') {
$id = $this->get_id();
$unmask = get_string('unmaskpassword', 'form');
/**
* Path to directory
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configfile extends admin_setting_configtext {
/**
parent::__construct($name, $visiblename, $description, $defaultdirectory, PARAM_RAW, 50);
}
+ /**
+ * Returns XHTML for the field
+ *
+ * Returns XHTML for the field and also checks whether the file
+ * specified in $data exists using file_exists()
+ *
+ * @param string $data File name and path to use in value attr
+ * @param string $query
+ * @return string XHTML field
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
/**
* Path to executable file
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configexecutable extends admin_setting_configfile {
+ /**
+ * Returns an XHTML field
+ *
+ * @param string $data This is the value for the field
+ * @param string $query
+ * @return string XHTML field
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
/**
* Path to directory
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configdirectory extends admin_setting_configfile {
+
+ /**
+ * Returns an XHTML field
+ *
+ * @param string $data This is the value for the field
+ * @param string $query
+ * @return string XHTML
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
/**
* Checkbox
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configcheckbox extends admin_setting {
+ /**
+ * @var string Value used when checked
+ */
public $yes;
+ /**
+ * @var string Value used when not checked
+ */
public $no;
/**
$this->no = (string)$no;
}
+ /**
+ * Retrieves the current setting using the objects name
+ *
+ * @return string
+ */
public function get_setting() {
return $this->config_read($this->name);
}
+ /**
+ * Sets the value for the setting
+ *
+ * Sets the value for the setting to either the yes or no values
+ * of the object by comparing $data to yes
+ *
+ * @param mixed $data Gets converted to str for comparison against yes value
+ * @return string empty string or error
+ */
public function write_setting($data) {
if ((string)$data === $this->yes) { // convert to strings before comparison
$data = $this->yes;
return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin'));
}
+ /**
+ * Returns an XHTML checkbox field
+ *
+ * @param string $data If $data matches yes then checkbox is checked
+ * @param string $query
+ * @return string XHTML field
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
/**
* Multiple checkboxes, each represents different value, stored in csv format
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configmulticheckbox extends admin_setting {
+ /**
+ * @var array Array of choices value=>label
+ */
public $choices;
/**
- * Constructor
+ * Constructor: uses parent::__construct
+ *
* @param string $name unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins.
* @param string $visiblename localised
* @param string $description long localised info
/**
* This public function may be used in ancestors for lazy loading of choices
- * @return true if loaded, false if error
+ *
+ * @todo Check if this function is still required content commented out only returns true
+ * @return bool true if loaded, false if error
*/
public function load_choices() {
/*
/**
* Is setting related to query text - used when searching
+ *
* @param string $query
- * @return bool
+ * @return bool true on related, false on not or failure
*/
public function is_related($query) {
if (!$this->load_choices() or empty($this->choices)) {
return false;
}
+ /**
+ * Returns the current setting if it is set
+ *
+ * @return mixed null if null, else an array
+ */
public function get_setting() {
$result = $this->config_read($this->name);
return $setting;
}
+ /**
+ * Saves the setting(s) provided in $data
+ *
+ * @param array $data An array of data, if not array returns empty str
+ * @return mixed empty string on useless data or bool true=success, false=failed
+ */
public function write_setting($data) {
if (!is_array($data)) {
return ''; // ignore it
}
return $this->config_write($this->name, implode(',', $result)) ? '' : get_string('errorsetting', 'admin');
}
-
+
+ /**
+ * Returns XHTML field(s) as required by choices
+ *
+ * Relies on data being an array should data ever be another valid vartype with
+ * acceptable value this may cause a warning/error
+ * if (!is_array($data)) would fix the problem
+ *
+ * @todo Add vartype handling to ensure $data is an array
+ *
+ * @param array $data An array of checked values
+ * @param string $query
+ * @return string XHTML field
+ */
public function output_html($data, $query='') {
if (!$this->load_choices() or empty($this->choices)) {
return '';
/**
* Multiple checkboxes 2, value stored as string 00101011
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configmulticheckbox2 extends admin_setting_configmulticheckbox {
+
+ /**
+ * Returns the setting if set
+ *
+ * @return mixed null if not set, else an array of set settings
+ */
public function get_setting() {
$result = $this->config_read($this->name);
if (is_null($result)) {
return $setting;
}
+ /**
+ * Save setting(s) provided in $data param
+ *
+ * @param array $data An array of settings to save
+ * @return mixed empty string for bad data or bool true=>success, false=>error
+ */
public function write_setting($data) {
if (!is_array($data)) {
return ''; // ignore it
/**
* Select one value from list
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configselect extends admin_setting {
+ /**
+ * @var array
+ */
public $choices;
/**
/**
* This function may be used in ancestors for lazy loading of choices
- * @return true if loaded, false if error
+ *
+ * @todo Check if this function is still required content commented out only returns true
+ * @return bool true if loaded, false if error
*/
public function load_choices() {
/*
return true;
}
+ /**
+ * Check if this is $query is related to a choice
+ *
+ * @param string $query
+ * @return bool true if related, false if not
+ */
public function is_related($query) {
if (parent::is_related($query)) {
return true;
return false;
}
+ /**
+ * Return the setting
+ *
+ * @return mixed returns config if successfull else null
+ */
public function get_setting() {
return $this->config_read($this->name);
}
+ /**
+ * Save a setting
+ *
+ * @param string $data
+ * @return string empty of error string
+ */
public function write_setting($data) {
if (!$this->load_choices() or empty($this->choices)) {
return '';
}
/**
- * Ensure the options are loaded, and generate the HTML for the select
+ * Returns XHTML select field
+ *
+ * Ensure the options are loaded, and generate the XHTML for the select
* element and any warning message. Separating this out from output_html
* makes it easier to subclass this class.
*
return array($selecthtml, $warning);
}
+ /**
+ * Returns XHTML select field and wrapping div(s)
+ *
+ * @see output_select_html()
+ *
+ * @param string $data the option to show as selected
+ * @param string $query
+ * @return string XHTML field and wrapping div
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
$current = $this->get_setting();
/**
* Select multiple items from list
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configmultiselect extends admin_setting_configselect {
/**
parent::__construct($name, $visiblename, $description, $defaultsetting, $choices);
}
+ /**
+ * Returns the select setting(s)
+ *
+ * @return mixed null or array. Null if no settings else array of setting(s)
+ */
public function get_setting() {
$result = $this->config_read($this->name);
if (is_null($result)) {
return explode(',', $result);
}
+ /**
+ * Saves setting(s) provided through $data
+ *
+ * Potential bug in the works should anyone call with this function
+ * using a vartype that is not an array
+ *
+ * @todo Add vartype handling to ensure $data is an array
+ * @param array $data
+ */
public function write_setting($data) {
if (!is_array($data)) {
return ''; //ignore it
/**
* Is setting related to query text - used when searching
+ *
* @param string $query
- * @return bool
+ * @return bool true if related, false if not
*/
public function is_related($query) {
if (!$this->load_choices() or empty($this->choices)) {
return false;
}
+ /**
+ * Returns XHTML multi-select field
+ *
+ * @todo Add vartype handling to ensure $data is an array
+ * @param array $data Array of values to select by default
+ * @param string $query
+ * @return string XHTML multi-select field
+ */
public function output_html($data, $query='') {
if (!$this->load_choices() or empty($this->choices)) {
return '';
/**
* Time selector
- * this is a liiitle bit messy. we're using two selects, but we're returning
+ *
+ * This is a liiitle bit messy. we're using two selects, but we're returning
* them as an array named after $name (so we only use $name2 internally for the setting)
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_configtime extends admin_setting {
+ /**
+ * @var string Used for setting second select (minutes)
+ */
public $name2;
/**
parent::__construct($hoursname, $visiblename, $description, $defaultsetting);
}
+ /**
+ * Get the selected time
+ *
+ * @return mixed An array containing 'h'=>xx, 'm'=>xx, or null if not set
+ */
public function get_setting() {
$result1 = $this->config_read($this->name);
$result2 = $this->config_read($this->name2);
return array('h' => $result1, 'm' => $result2);
}
+ /**
+ * Store the time (hours and minutes)
+ *
+ * @param array $data Must be form 'h'=>xx, 'm'=>xx
+ * @return bool true if success, false if not
+ */
public function write_setting($data) {
if (!is_array($data)) {
return '';
return ($result ? '' : get_string('errorsetting', 'admin'));
}
+ /**
+ * Returns XHTML time select fields
+ *
+ * @param array $data Must be form 'h'=>xx, 'm'=>xx
+ * @param string $query
+ * @return string XHTML time select fields and wrapping div(s)
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
}
+/**
+ * Used to validate a textarea used for ip addresses
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_configiplist extends admin_setting_configtextarea {
+
+ /**
+ * Validate the contents of the textarea as IP addresses
+ *
+ * Used to validate a new line seperated list of IP addresses collected from
+ * a textarea control
+ *
+ * @param string $data A list of IP Addresses seperated by new lines
+ * @return mixed bool true for success or string:error on failure
+ */
public function validate($data) {
if(!empty($data)) {
$ips = explode("\n", $data);
}
/**
+ * An admin setting for selecting one or more users who have a capability
+ * in the system context
+ *
* An admin setting for selecting one or more users, who have a particular capability
* in the system context. Warning, make sure the list will never be too long. There is
* no paging or searching of this list.
*
* To correctly get a list of users from this config setting, you need to call the
* get_users_from_config($CFG->mysetting, $capability); function in moodlelib.php.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_users_with_capability extends admin_setting_configmultiselect {
+ /**
+ * @var string The capabilities name
+ * @access protected
+ */
protected $capability;
/**
parent::__construct($name, $visiblename, $description, $defaultsetting, NULL);
}
+ /**
+ * Load all of the uses who have the capability into choice array
+ *
+ * @return bool Always returns true
+ */
function load_choices() {
if (is_array($this->choices)) {
return true;
return true;
}
+ /**
+ * Returns the default setting for class
+ *
+ * @return mixed Array, or string. Empty string if no default
+ */
public function get_defaultsetting() {
$this->load_choices();
$defaultsetting = parent::get_defaultsetting();
}
}
+ /**
+ * Returns the current setting
+ *
+ * @return mixed array or string
+ */
public function get_setting() {
$result = parent::get_setting();
if (empty($result)) {
return $result;
}
+ /**
+ * Save the chosen setting provided as $data
+ *
+ * @param array $data
+ * @return mixed string or array
+ */
public function write_setting($data) {
// If all is selected, remove any explicit options.
if (in_array('$@ALL@$', $data)) {
/**
* Special checkbox for calendar - resets SESSION vars.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_adminseesall extends admin_setting_configcheckbox {
+ /**
+ * Calls the parent::__construct with default values
+ *
+ * name => calendar_adminseesall
+ * visiblename => get_string('adminseesall', 'admin')
+ * description => get_string('helpadminseesall', 'admin')
+ * defaultsetting => 0
+ */
public function __construct() {
parent::__construct('calendar_adminseesall', get_string('adminseesall', 'admin'),
get_string('helpadminseesall', 'admin'), '0');
}
+ /**
+ * Stores the setting passed in $data
+ *
+ * @global object
+ * @param mixed gets converted to string for comparison
+ * @return string empty string or error message
+ */
public function write_setting($data) {
global $SESSION;
unset($SESSION->cal_courses_shown);
/**
* Special select for settings that are altered in setup.php and can not be altered on the fly
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_selectsetup extends admin_setting_configselect {
+ /**
+ * Reads the setting directly from the database
+ *
+ * @return mixed
+ */
public function get_setting() {
// read directly from db!
return get_config(NULL, $this->name);
}
+ /**
+ * Save the setting passed in $data
+ *
+ * @global object
+ * @param string $data The setting to save
+ * @return string empty or error message
+ */
public function write_setting($data) {
global $CFG;
// do not change active CFG setting!
/**
* Special select for frontpage - stores data in course table
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_sitesetselect extends admin_setting_configselect {
+ /**
+ * Returns the site name for the selected site
+ *
+ * @see get_site()
+ * @return string The site name of the selected site
+ */
public function get_setting() {
$site = get_site();
return $site->{$this->name};
}
-
+ /**
+ * Updates the database and save the setting
+ *
+ * @global object
+ * @global object
+ * @param string data
+ * @return string empty or error message
+ */
public function write_setting($data) {
global $DB, $SITE;
if (!in_array($data, array_keys($this->choices))) {
/**
* Special select - lists on the frontpage - hacky
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_courselist_frontpage extends admin_setting {
+ /**
+ * @var array
+ */
public $choices;
+ /**
+ * Construct override, requires one param
+ *
+ * @global object
+ * @param bool $loggedin Is the user logged in
+ */
public function __construct($loggedin) {
global $CFG;
require_once($CFG->dirroot.'/course/lib.php');
parent::__construct($name, $visiblename, $description, $defaults);
}
+ /**
+ * Loads the choices available
+ *
+ * @global object
+ * @return bool always returns true
+ */
public function load_choices() {
global $DB;
if (is_array($this->choices)) {
}
return true;
}
+ /**
+ * Returns the selected settings
+ *
+ * @param mixed array or setting or null
+ */
public function get_setting() {
$result = $this->config_read($this->name);
if (is_null($result)) {
return explode(',', $result);
}
+ /**
+ * Save the selected options
+ *
+ * @param array $data
+ * @return mixed empty string (data is not an array) or bool true=success false=failure
+ */
public function write_setting($data) {
if (!is_array($data)) {
return '';
return ($this->config_write($this->name, implode(',', $save)) ? '' : get_string('errorsetting', 'admin'));
}
+ /**
+ * Return XHTML select field and wrapping div
+ *
+ * @todo Add vartype handling to make sure $data is an array
+ * @param array $data Array of elements to select by default
+ * @return string XHTML select field and wrapping div
+ */
public function output_html($data, $query='') {
$this->load_choices();
$currentsetting = array();
/**
* Special checkbox for frontpage - stores data in course table
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
+ /**
+ * Returns the current sites name
+ *
+ * @return string
+ */
public function get_setting() {
$site = get_site();
return $site->{$this->name};
}
+ /**
+ * Save the selected setting
+ *
+ * @global object
+ * @global object
+ * @param string $data The selected site
+ * @return string empty string or error message
+ */
public function write_setting($data) {
global $DB, $SITE;
$record = new object();
/**
* Special text for frontpage - stores data in course table.
* Empty string means not set here. Manual setting is required.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_sitesettext extends admin_setting_configtext {
+ /**
+ * Return the current setting
+ *
+ * @return mixed string or null
+ */
public function get_setting() {
$site = get_site();
return $site->{$this->name} != '' ? $site->{$this->name} : NULL;
}
+ /**
+ * Validate the selected data
+ *
+ * @param string $data The selected value to validate
+ * @return mixed true or message string
+ */
public function validate($data) {
$cleaned = clean_param($data, PARAM_MULTILANG);
if ($cleaned === '') {
}
}
+ /**
+ * Save the selected setting
+ *
+ * @global object
+ * @global object
+ * @param string $data The selected value
+ * @return string emtpy or error message
+ */
public function write_setting($data) {
global $DB, $SITE;
$data = trim($data);
/**
* Special text editor for site description.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_frontpagedesc extends admin_setting {
+ /**
+ * Calls parent::__construct with specific arguments
+ */
public function __construct() {
parent::__construct('summary', get_string('frontpagedescription'), get_string('frontpagedescriptionhelp'), NULL);
}
+ /**
+ * Return the current setting
+ * @return string The current setting
+ */
public function get_setting() {
$site = get_site();
return $site->{$this->name};
}
+ /**
+ * Save the new setting
+ *
+ * @global object
+ * @global object
+ * @param string $data The new value to save
+ * @return string empty or error message
+ */
public function write_setting($data) {
global $DB, $SITE;
$record = new object();
return ($DB->update_record('course', $record) ? '' : get_string('errorsetting', 'admin'));
}
+ /**
+ * Returns XHTML for the field plus wrapping div
+ *
+ * @global object
+ * @global object
+ * @param string $data The current value
+ * @param string $query
+ * @return string The XHTML output
+ */
public function output_html($data, $query='') {
global $CFG;
}
}
+/**
+ * Special font selector for use in admin section
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_special_editorfontlist extends admin_setting {
+ /**
+ * @var array
+ * @todo Apparently unused var check if removable
+ */
public $items;
+ /**
+ * @global object
+ * Construct method, calls parent::__construct with specific args
+ */
public function __construct() {
global $CFG;
$name = 'editorfontlist';
parent::__construct($name, $visiblename, $description, $defaults);
}
+ /**
+ * Return the current setting
+ *
+ * @global object
+ * @return array Array of the current setting(s)
+ */
public function get_setting() {
global $CFG;
$result = $this->config_read($this->name);
return $currentsetting;
}
+ /**
+ * Save the new setting(s)
+ *
+ * @todo Add vartype handling to ensure $data is an array
+ * @param array $data Array containing the new settings
+ * @return bool
+ */
public function write_setting($data) {
// there miiight be an easier way to do this :)
return ($this->config_write($this->name, implode(';', $result)) ? '' : get_string('errorsetting', 'admin'));
}
+ /**
+ * Returns XHTML for the options
+ *
+ * @todo Add vartype handling to ensure that $data is an array
+ * @param array $data An array of values to set
+ * @param string $query
+ * @return string XHTML
+ */
public function output_html($data, $query='') {
$fullname = $this->get_full_name();
$return = '<div class="form-group">';
}
}
-
+/**
+ * Special settings for emoticons
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_emoticons extends admin_setting {
+ /**
+ * @var array
+ * @todo Apparently unused var, check if removable
+ */
public $items;
+ /**
+ * @global object
+ * Calls parent::__construct with specific args
+ */
public function __construct() {
global $CFG;
$name = 'emoticons';
'v27' => 'egg');
parent::__construct($name, $visiblename, $description, $defaults);
}
-
+
+ /**
+ * Return the current setting(s)
+ *
+ * @global object
+ * @return array Current settings array
+ */
public function get_setting() {
global $CFG;
$result = $this->config_read($this->name);
return $currentsetting;
}
+ /**
+ * Save selected settings
+ *
+ * @param array $data Array of settings to save
+ * @return bool
+ */
public function write_setting($data) {
// there miiight be an easier way to do this :)
return ($this->config_write($this->name, implode('{;}', $result)) ? '' : get_string('errorsetting', 'admin').$this->visiblename.'<br />');
}
+ /**
+ * Return XHTML field(s) for options
+ *
+ * @param array $data Array of options to set in HTML
+ * @return string XHTML string for the fields and wrapping div(s)
+ */
public function output_html($data, $query='') {
$fullname = $this->get_full_name();
$return = '<div class="form-group">';
}
}
+/**
+ * Used to set editor options/settings
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_special_editorhidebuttons extends admin_setting {
+ /**
+ * @var array Array of possible options
+ */
public $items;
+ /**
+ * Calls parent::__construct with specific options
+ */
public function __construct() {
parent::__construct('editorhidebuttons', get_string('editorhidebuttons', 'admin'),
get_string('confeditorhidebuttons', 'admin'), array());
'search_replace' => 'ed_replace.gif');
}
+ /**
+ * Get an array of current settings
+ *
+ * @return array Array of current settings
+ */
public function get_setting() {
$result = $this->config_read($this->name);
if (is_null($result)) {
return explode(' ', $result);
}
+ /**
+ * Save the selected settings
+ *
+ * @param array $data Array of settings to save
+ * @return mixed empty string, error string, or bool true=>success, false=>error
+ */
public function write_setting($data) {
if (!is_array($data)) {
return ''; // ignore it
return ($this->config_write($this->name, implode(' ', $result)) ? '' : get_string('errorsetting', 'admin'));
}
+ /**
+ * Return XHTML for the field and wrapping div(s)
+ *
+ * @global object
+ * @param array $data
+ * @param string $query
+ * @return string XHTML for output
+ */
public function output_html($data, $query='') {
global $CFG;
/**
* Special setting for limiting of the list of available languages.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_langlist extends admin_setting_configtext {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct() {
parent::__construct('langlist', get_string('langlist', 'admin'), get_string('configlanglist', 'admin'), '', PARAM_NOTAGS);
}
+ /**
+ * Save the new setting
+ *
+ * @param string $data The new setting
+ * @return bool
+ */
public function write_setting($data) {
$return = parent::write_setting($data);
get_list_of_languages(true);//refresh the list
/**
* Course category selection
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_settings_coursecat_select extends admin_setting_configselect {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct($name, $visiblename, $description, $defaultsetting) {
parent::__construct($name, $visiblename, $description, $defaultsetting, NULL);
}
+ /**
+ * Load the available choices for the select box
+ *
+ * @global object
+ * @return bool
+ */
public function load_choices() {
global $CFG;
require_once($CFG->dirroot.'/course/lib.php');
}
}
+/**
+ * Special control for selecting days to backup
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_special_backupdays extends admin_setting_configmulticheckbox2 {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct() {
parent::__construct('backup_sche_weekdays', get_string('schedule'), get_string('backupschedulehelp'), array(), NULL);
$this->plugin = 'backup';
}
-
+ /**
+ * Load the available choices for the select box
+ *
+ * @return bool Always returns true
+ */
public function load_choices() {
if (is_array($this->choices)) {
return true;
/**
* Special debug setting
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_debug extends admin_setting_configselect {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct() {
parent::__construct('debug', get_string('debug', 'admin'), get_string('configdebug', 'admin'), DEBUG_NONE, NULL);
}
+ /**
+ * Load the available choices for the select box
+ *
+ * @return bool
+ */
public function load_choices() {
if (is_array($this->choices)) {
return true;
}
}
-
+/**
+ * Special admin control
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_special_calendar_weekend extends admin_setting {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct() {
$name = 'calendar_weekend';
$visiblename = get_string('calendar_weekend', 'admin');
$default = array ('0', '6'); // Saturdays and Sundays
parent::__construct($name, $visiblename, $description, $default);
}
-
+ /**
+ * Gets the current settins as an array
+ *
+ * @return mixed Null if none, else array of settings
+ */
public function get_setting() {
$result = $this->config_read($this->name);
if (is_null($result)) {
return $settings;
}
+ /**
+ * Save the new settings
+ *
+ * @param array $data Array of new settings
+ * @return bool
+ */
public function write_setting($data) {
if (!is_array($data)) {
return '';
return ($this->config_write($this->name, $result) ? '' : get_string('errorsetting', 'admin'));
}
+ /**
+ * Return XHTML to display the control
+ *
+ * @param array $data array of selected days
+ * @param string $query
+ * @return string XHTML for display (field + wrapping div(s)
+ */
public function output_html($data, $query='') {
// The order matters very much because of the implied numeric keys
$days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
/**
* Admin setting that allows a user to pick appropriate roles for something.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_pickroles extends admin_setting_configmulticheckbox {
+ /**
+ * @var array Array of capabilities which identify roles
+ */
private $types;
/**
$this->types = $types;
}
+ /**
+ * Load roles as choices
+ *
+ * @global object
+ * @global object
+ * @return bool true=>success, false=>error
+ */
public function load_choices() {
global $CFG, $DB;
if (empty($CFG->rolesactive)) {
return false;
}
}
-
+ /**
+ * Return the default setting for this control
+ *
+ * @global object
+ * @return array Array of default settings
+ */
public function get_defaultsetting() {
global $CFG;
/**
* Text field with an advanced checkbox, that controls a additional "fix_$name" setting.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_text_with_advanced extends admin_setting_configtext {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct($name, $visiblename, $description, $defaultsetting, $paramtype) {
parent::__construct($name, $visiblename, $description,
$defaultsetting, $paramtype);
}
+ /**
+ * Loads the current setting and returns array
+ *
+ * @return array Returns array value=>xx, fix=>xx
+ */
public function get_setting() {
$value = parent::get_setting();
$fix = $this->config_read('fix_' . $this->name);
return array('value' => $value, 'fix' => $fix);
}
+ /**
+ * Saves the new settings passed in $data
+ *
+ * @todo Add vartype handling to ensure $data is an array
+ * @param array $data
+ * @return mixed string or Array
+ */
public function write_setting($data) {
$error = parent::write_setting($data['value']);
if (!$error) {
return $error;
}
+ /**
+ * Return XHTML for the control
+ *
+ * @param array $data Default data array
+ * @param string $query
+ * @return string XHTML to display control
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
$defaultinfo = array();
/**
* Dropdown menu with an advanced checkbox, that controls a additional "fix_$name" setting.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_combo_with_advanced extends admin_setting_configselect {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct($name, $visiblename, $description, $defaultsetting, $choices) {
parent::__construct($name, $visiblename, $description, $defaultsetting, $choices);
}
-
+
+ /**
+ * Loads the current setting and returns array
+ *
+ * @return array Returns array value=>xx, fix=>xx
+ */
public function get_setting() {
$value = parent::get_setting();
$fix = $this->config_read('fix_' . $this->name);
return array('value' => $value, 'fix' => $fix);
}
+ /**
+ * Saves the new settings passed in $data
+ *
+ * @todo Add vartype handling to ensure $data is an array
+ * @param array $data
+ * @return mixed string or Array
+ */
public function write_setting($data) {
$error = parent::write_setting($data['value']);
if (!$error) {
return $error;
}
+ /**
+ * Return XHTML for the control
+ *
+ * @param array $data Default data array
+ * @param string $query
+ * @return string XHTML to display control
+ */
public function output_html($data, $query='') {
$default = $this->get_defaultsetting();
$current = $this->get_setting();
/**
* Specialisation of admin_setting_combo_with_advanced for easy yes/no choices.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_yesno_with_advanced extends admin_setting_combo_with_advanced {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct($name, $visiblename, $description, $defaultsetting) {
parent::__construct($name, $visiblename, $description,
$defaultsetting, array(get_string('no'), get_string('yes')));
/**
* Graded roles in gradebook
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_gradebookroles extends admin_setting_pickroles {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct() {
parent::__construct('gradebookroles', get_string('gradebookroles', 'admin'),
get_string('configgradebookroles', 'admin'),
}
}
-
+/**
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_regradingcheckbox extends admin_setting_configcheckbox {
+ /**
+ * Saves the new settings passed in $data
+ *
+ * @global object
+ * @global object
+ * @param string $data
+ * @return mixed string or Array
+ */
public function write_setting($data) {
global $CFG, $DB;
/**
* Which roles to show on course decription page
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_coursemanager extends admin_setting_pickroles {
+ /**
+ * Calls parent::__consturct with specific arguments
+ */
public function __construct() {
parent::__construct('coursemanager', get_string('coursemanager', 'admin'),
get_string('configcoursemanager', 'admin'),
}
}
+/**
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_special_gradelimiting extends admin_setting_configcheckbox {
+ /**
+ * Calls parent::__construct with specific arguments
+ */
function admin_setting_special_gradelimiting() {
parent::__construct('unlimitedgrades', get_string('unlimitedgrades', 'grades'),
get_string('configunlimitedgrades', 'grades'), '0', '1', '0');
}
+ /**
+ * @global object
+ * Force site regrading
+ */
function regrade_all() {
global $CFG;
require_once("$CFG->libdir/gradelib.php");
grade_force_site_regrading();
}
+ /**
+ * Saves the new settings
+ *
+ * @param mixed $data
+ * @return string empty string or error message
+ */
function write_setting($data) {
$previous = $this->get_setting();
/**
* Primary grade export plugin - has state tracking.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_gradeexport extends admin_setting_configmulticheckbox {
+ /**
+ * Calls parent::__construct with specific arguments
+ */
public function __construct() {
parent::__construct('gradeexport', get_string('gradeexport', 'admin'),
get_string('configgradeexport', 'admin'), array(), NULL);
}
+ /**
+ * Load the available choices for the multicheckbox
+ *
+ * @return bool always returns true
+ */
public function load_choices() {
if (is_array($this->choices)) {
return true;
/**
* Grade category settings
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_gradecat_combo extends admin_setting {
-
+ /**
+ * @var array Array of choices
+ */
public $choices;
+ /**
+ * Sets choices and calls parent::__construct with passed arguments
+ * @param string $name
+ * @param string $visiblename
+ * @param string $description
+ * @param mixed $defaultsetting string or array depending on implementation
+ * @param array $choices An array of choices for the control
+ */
public function __construct($name, $visiblename, $description, $defaultsetting, $choices) {
$this->choices = $choices;
parent::__construct($name, $visiblename, $description, $defaultsetting);
}
+ /**
+ * Return the current setting(s) array
+ *
+ * @global object
+ * @return array Array of value=>xx, forced=>xx, adv=>xx
+ */
public function get_setting() {
global $CFG;
return array('value' => $value, 'forced' => $forced, 'adv' => $adv);
}
+ /**
+ * Save the new settings passed in $data
+ *
+ * @todo Add vartype handling to ensure $data is array
+ * @global object
+ * @param array $data Associative array of value=>xx, forced=>xx, adv=>xx
+ * @return string empty or error message
+ */
public function write_setting($data) {
global $CFG;
}
}
+ /**
+ * Return XHTML to display the field and wrapping div
+ *
+ * @todo Add vartype handling to ensure $data is array
+ * @param array $data Associative array of value=>xx, forced=>xx, adv=>xx
+ * @param string $query
+ * @return string XHTML to display control
+ */
public function output_html($data, $query='') {
$value = $data['value'];
$forced = !empty($data['forced']);
/**
* Selection of grade report in user profiles
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_grade_profilereport extends admin_setting_configselect {
+ /**
+ * Calls parent::__construct with specific arguments
+ */
public function __construct() {
parent::__construct('grade_profilereport', get_string('profilereport', 'grades'), get_string('configprofilereport', 'grades'), 'user', null);
}
+ /**
+ * Loads an array of choices for the configselect control
+ *
+ * @global object
+ * @return bool always return true
+ */
public function load_choices() {
if (is_array($this->choices)) {
return true;
/**
* Special class for register auth selection
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_special_registerauth extends admin_setting_configselect {
+ /**
+ * Calls parent::__construct with specific arguments
+ */
public function __construct() {
parent::__construct('registerauth', get_string('selfregistration', 'auth'), get_string('selfregistration_help', 'auth'), '', null);
}
+ /**
+ * Returns the default option
+ *
+ * @return string emtpy or default option
+ */
public function get_defaultsetting() {
$this->load_choices();
$defaultsetting = parent::get_defaultsetting();
}
}
+ /**
+ * Loads the possible choices for the array
+ *
+ * @global object
+ * @return bool always returns true
+ */
public function load_choices() {
global $CFG;
/**
* Module manage page
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_page_managemods extends admin_externalpage {
+ /**
+ * Calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('managemodules', get_string('modsettings', 'admin'), "$CFG->wwwroot/$CFG->admin/modules.php");
}
+ /**
+ * Try to find the specified module
+ *
+ * @global object
+ * @param string $query The module to search for
+ * @return array
+ */
public function search($query) {
global $DB;
if ($result = parent::search($query)) {
/**
* Enrolment manage page
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_enrolment_page extends admin_externalpage {
+ /**
+ * Calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('enrolment', get_string('enrolments'), $CFG->wwwroot . '/'.$CFG->admin.'/enrol.php');
}
+ /**
+ * @param string The string to search for
+ * @return array
+ */
public function search($query) {
if ($result = parent::search($query)) {
return $result;
/**
* Blocks manage page
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_page_manageblocks extends admin_externalpage {
+ /**
+ * Calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('manageblocks', get_string('blocksettings', 'admin'), "$CFG->wwwroot/$CFG->admin/blocks.php");
}
+ /**
+ * Search for a specific block
+ *
+ * @global object
+ * @global object
+ * @param string $query The string to search for
+ * @return array
+ */
public function search($query) {
global $CFG, $DB;
if ($result = parent::search($query)) {
/**
* Question type manage page
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_page_manageqtypes extends admin_externalpage {
+ /**
+ * Calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('manageqtypes', get_string('manageqtypes', 'admin'), "$CFG->wwwroot/$CFG->admin/qtypes.php");
}
+ /**
+ * Search QTYPES for the specified string
+ *
+ * @global object
+ * @global array
+ * @param string $query The string to search for in QTYPES
+ * @return array
+ */
public function search($query) {
global $CFG;
if ($result = parent::search($query)) {
/**
* Special class for authentication administration.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_manageauths extends admin_setting {
+ /**
+ * Calls parent::__construct with specific arguments
+ */
public function __construct() {
parent::__construct('authsui', get_string('authsettings', 'admin'), '', '');
}
+ /**
+ * Always returns true
+ *
+ * @return true
+ */
public function get_setting() {
return true;
}
+ /**
+ * Always returns true
+ *
+ * @return true
+ */
public function get_defaultsetting() {
return true;
}
+ /**
+ * Always returns '' and doesn't write anything
+ *
+ * @return string Always returns ''
+ */
public function write_setting($data) {
// do not write any setting
return '';
}
+ /**
+ * Search to find if Query is related to auth plugin
+ *
+ * @param string $query The string to search for
+ * @return bool true for related false for not
+ */
public function is_related($query) {
if (parent::is_related($query)) {
return true;
return false;
}
+ /**
+ * Return XHTML to display control
+ *
+ * @global object
+ * @param mixed $data Unused
+ * @param string $query
+ * @return string highlight
+ */
public function output_html($data, $query='') {
global $CFG;
/**
* Special class for authentication administration.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_setting_manageeditors extends admin_setting {
+ /**
+ * Calls parent::__construct with specific arguments
+ */
public function __construct() {
parent::__construct('editorsui', get_string('editorsettings', 'editor'), '', '');
}
+ /**
+ * Always returns true, does nothing
+ *
+ * @return true
+ */
public function get_setting() {
return true;
}
+ /**
+ * Always returns true, does nothing
+ *
+ * @return true
+ */
public function get_defaultsetting() {
return true;
}
+ /**
+ * Always returns '', does not write anything
+ *
+ * @return string Always returns ''
+ */
public function write_setting($data) {
// do not write any setting
return '';
}
+ /**
+ * Checks if $query is one of the available editors
+ *
+ * @param string $query The string to search for
+ * @return bool Returns true if found, false if not
+ */
public function is_related($query) {
if (parent::is_related($query)) {
return true;
return false;
}
+ /**
+ * Builds the XHTML to display the control
+ *
+ * @global object
+ * @param string $data Unused
+ * @param string $query
+ * @return string
+ */
public function output_html($data, $query='') {
global $CFG;
/**
* Special class for filter administration.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
*/
class admin_page_managefilters extends admin_externalpage {
+ /**
+ * Calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('managefilters', get_string('filtersettings', 'admin'), "$CFG->wwwroot/$CFG->admin/filters.php");
}
+ /**
+ * Searches all installed filters for specified filter
+ *
+ * @global object
+ * @param string $query The filter(string) to search for
+ * @param string $query
+ */
public function search($query) {
global $CFG;
if ($result = parent::search($query)) {
}
}
+/**
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_manageportfolio extends admin_setting {
private $baseurl;
+ /**
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('manageportfolio', get_string('manageportfolio', 'portfolio'), '', '');
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/portfolio.php?sesskey=' . sesskey();
}
+ /**
+ * Always returns true, does nothing
+ *
+ * @return true
+ */
public function get_setting() {
return true;
}
+ /**
+ * Always returns true, does nothing
+ *
+ * @return true
+ */
public function get_defaultsetting() {
return true;
}
+ /**
+ * Always returns '', does not write anything
+ *
+ * @return string Always returns ''
+ */
public function write_setting($data) {
return '';
}
+ /**
+ * Searches the portfolio types for the specified type(string)
+ *
+ * @param string $query The string to search for
+ * @return bool true for found or related, false for not
+ */
public function is_related($query) {
if (parent::is_related($query)) {
return true;
return false;
}
+ /**
+ * Builds XHTML to display the control
+ *
+ * @global object
+ * @param string $data Unused
+ * @param string $query
+ * @return string XHTML to display the control
+ */
public function output_html($data, $query='') {
global $CFG;
/**
* Initialise admin page - this function does require login and permission
* checks specified in page definition.
+ *
* This function must be called on each admin page before other code.
+ *
+ * @global object
+ * @global object
+ * @global object
* @param string $section name of page
* @param string $extrabutton extra HTML that is added after the blocks editing on/off button.
- * @param string $extraurlparams an array paramname => paramvalue, or parameters that need to be
+ * @param array $extraurlparams an array paramname => paramvalue, or parameters that need to be
* added to the turn blocks editing on/off form, so this page reloads correctly.
* @param string $actualurl if the actual page being viewed is not the normal one for this
* page (e.g. admin/roles/allowassin.php, instead of admin/roles/manage.php, you can pass the alternate URL here.
/**
* Print header for admin page
+ *
+ * @global object
+ * @global object
+ * @global object
+ * @global object
* @param string $focus focus element
*/
function admin_externalpage_print_header($focus='') {
/**
* Returns the reference to admin tree root
- * @return reference
+ *
+ * @global object
+ * @global object
+ * @return object admin_roow object
*/
function admin_get_root($reload=false, $requirefulltree=true) {
global $CFG, $DB;
/**
* This function applies default settings.
- * @param object $node, NULL means complete tree
- * @param bool $uncoditional if true overrides all values with defaults
- * @return void
+ *
+ * @global object
+ * @param object $node, NULL means complete tree, null by default
+ * @param bool $uncoditional if true overrides all values with defaults, null buy default
*/
function admin_apply_default_settings($node=NULL, $unconditional=true) {
global $CFG;
/**
* Store changed settings, this function updates the errors variable in $ADMIN
+ *
+ * @global object
+ * @global object
* @param object $formdata from form
* @return int number of changed settings
*/
/**
* Internal recursive function - finds all settings from submitted form
+ *
+ * @param object $node Instance of admin_category, or admin_settingpage
+ * @param array $data
+ * @return array
*/
function admin_find_write_settings($node, $data) {
$return = array();
/**
* Internal function - prints the search results
+ *
+ * @global object
+ * @param string $query String to search for
+ * @return string empty or XHTML
*/
function admin_search_settings_html($query) {
global $CFG;
/**
* Internal function - returns arrays of html pages with uninitialised settings
+ *
+ * @param object $node Instance of admin_category or admin_settingpage
+ * @return array
*/
function admin_output_new_settings_by_page($node) {
$return = array();
/**
* Format admin settings
- * @param string $object setting
+ *
+ * @global object
+ * @param object $setting
* @param string $title label element
* @param string $form form fragment, html code - not highlighed automaticaly
* @param string $description
- * @param bool $label link label to id
+ * @param bool $label link label to id, true by default
* @param string $warning warning text
- * @param sting $defaultinfo defaults info, null means nothing, '' is converted to "Empty" string
+ * @param sting $defaultinfo defaults info, null means nothing, '' is converted to "Empty" string, defaults to null
* @param string $query search query to be highlighted
+ * @return string XHTML
*/
function format_admin_setting($setting, $title='', $form='', $description='', $label=true, $warning='', $defaultinfo=NULL, $query='') {
global $CFG;
* Based on find_new_settings{@link ()} in upgradesettings.php
* Looks to find any admin settings that have not been initialized. Returns 1 if it finds any.
*
- * @param string $node The node at which to start searching.
+ * @param object $node Instance of admin_category, or admin_settingpage
* @return boolen true if any settings haven't been initialised, false if they all have
*/
function any_new_admin_settings($node) {
/**
* Moved from admin/replace.php so that we can use this in cron
- * @param string $search - string to look for
- * @param string $replace - string to replace
- * @return bool - success or fail
+ *
+ * @global object
+ * @global object
+ * @param string $search string to look for
+ * @param string $replace string to replace
+ * @return bool success or fail
*/
function db_replace($search, $replace) {
* Prints tables of detected plugins, one table per plugin type,
* and prints whether they are part of the standard Moodle
* distribution or not.
+ *
+ * @global object
*/
function print_plugin_tables() {
global $DB;
echo $html;
}
-
+/**
+ * Manage repository settings
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_managerepository extends admin_setting {
+ /**
+ * @var string
+ */
private $baseurl;
+ /**
+ * calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('managerepository', get_string('managerepository', 'repository'), '', '');
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/repository.php?sesskey=' . sesskey();
}
+ /**
+ * Always returns true, does nothing
+ *
+ * @return true
+ */
public function get_setting() {
return true;
}
+ /**
+ * Always returns true does nothing
+ *
+ * @return true
+ */
public function get_defaultsetting() {
return true;
}
+ /**
+ * Always returns s_managerepository
+ *
+ * @return string Always return 's_managerepository'
+ */
public function get_full_name() {
return 's_managerepository';
}
+ /**
+ * Always returns '' doesn't do anything
+ */
public function write_setting($data) {
$url = $this->baseurl . '&new=' . $data;
return '';
// exit;
}
+ /**
+ * Searches repository plugins for one that matches $query
+ *
+ * @param string $query The string to search for
+ * @return bool true if found, false if not
+ */
public function is_related($query) {
if (parent::is_related($query)) {
return true;
return false;
}
+ /**
+ * Builds XHTML to display the control
+ *
+ * @global object
+ * @global object
+ * @param string $data Unused
+ * @param string $query
+ * @return string XHTML
+ */
public function output_html($data, $query='') {
global $CFG, $USER;
$output = print_box_start('generalbox','',true);
}
}
+/**
+ *
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_managewsprotocols extends admin_setting {
+ /**
+ * @var string
+ */
private $baseurl;
+ /**
+ * Calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('managewsprotocols', get_string('managewsprotocols', 'admin'), '', '');
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/wsprotocols.php?sesskey=' . sesskey();
}
+ /**
+ * Always returns true, does nothing
+ * @return true
+ */
public function get_setting() {
return true;
}
+ /**
+ * Doesnt nothing, always returns ''
+ *
+ * @return string Always returns ''
+ */
public function write_setting($data) {
$url = $this->baseurl . '&new=' . $data;
return '';
}
+ /**
+ * Builds XHTML to display the control
+ *
+ * @global object
+ * @param string $data
+ * @param string $query
+ * @return string XHTML
+ */
public function output_html($data, $query='') {
global $CFG;
}
}
+/**
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package moodlecore
+ */
class admin_setting_managewsusersettings extends admin_setting {
+ /**
+ * @var string
+ */
private $baseurl;
+ /**
+ * Calls parent::__construct with specific arguments
+ *
+ * @global object
+ */
public function __construct() {
global $CFG;
parent::__construct('managewsusersettings', get_string('managewsusersettings', 'admin'), '', '');
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/wsprotocols.php?sesskey=' . sesskey();
}
+ /**
+ * Always returns true does nothing
+ *
+ * @return true
+ */
public function get_setting() {
return true;
}
+ /**
+ * Does nothing always returns ''
+ *
+ * @return string Always returns ''
+ */
public function write_setting($data) {
$url = $this->baseurl . '&new=' . $data;
return '';
}
+ /**
+ * Build XHTML to display the control
+ *
+ * @global object
+ * @param string $data Unused
+ * @param string $query
+ * @return string XHTML
+ */
public function output_html($data, $query='') {
global $CFG;
$output = "";