Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Classes | Functions | Variables
adminlib.php File Reference

Functions and classes used during installation, upgrades and for admin settings. More...

Classes

class  admin_category
 The object used to represent folders (a.k.a. More...
 
class  admin_externalpage
 Links external PHP pages into the admin tree. More...
 
class  admin_page_defaultmessageoutputs
 Default message outputs configuration. More...
 
class  admin_page_manageblocks
 Blocks manage page. More...
 
class  admin_page_managefilters
 Special class for filter administration. More...
 
class  admin_page_managemessageoutputs
 Message outputs configuration. More...
 
class  admin_page_managemods
 Module manage page. More...
 
class  admin_page_manageportfolios
 
class  admin_page_manageqbehaviours
 Manage question behaviours page. More...
 
class  admin_page_manageqtypes
 Question type manage page. More...
 
class  admin_page_managerepositories
 
class  admin_page_pluginsoverview
 General plugins manager. More...
 
class  admin_root
 Root of admin settings tree, does not have any parent. More...
 
class  admin_setting
 Admin settings class. More...
 
class  admin_setting_agedigitalconsentmap
 Used to validate the content and format of the age of digital consent map and ensuring it is parsable. More...
 
class  admin_setting_bloglevel
 Select for blog's bloglevel setting: if set to 0, will set blog_menu block to hidden. More...
 
class  admin_setting_configcheckbox
 Checkbox. More...
 
class  admin_setting_configcheckbox_with_advanced
 Checkbox with an advanced checkbox that controls an additional $name. More...
 
class  admin_setting_configcheckbox_with_lock
 Checkbox with an advanced checkbox that controls an additional $name. More...
 
class  admin_setting_configcolourpicker
 Colour picker. More...
 
class  admin_setting_configdirectory
 Path to directory. More...
 
class  admin_setting_configduration
 Seconds duration setting. More...
 
class  admin_setting_configduration_with_advanced
 Seconds duration setting with an advanced checkbox, that controls a additional $name. More...
 
class  admin_setting_configempty
 Empty setting used to allow flags (advanced) on settings that can have no sensible default. More...
 
class  admin_setting_configexecutable
 Path to executable file. More...
 
class  admin_setting_configfile
 Path to directory. More...
 
class  admin_setting_confightmleditor
 General text area with html editor. More...
 
class  admin_setting_configiplist
 Used to validate a textarea used for ip addresses. More...
 
class  admin_setting_configmixedhostiplist
 Used to validate a textarea used for domain names, wildcard domain names and IP addresses/ranges (both IPv4 and IPv6 format). More...
 
class  admin_setting_configmulticheckbox
 Multiple checkboxes, each represents different value, stored in csv format. More...
 
class  admin_setting_configmulticheckbox2
 Multiple checkboxes 2, value stored as string 00101011. More...
 
class  admin_setting_configmultiselect
 Select multiple items from list. More...
 
class  admin_setting_configmultiselect_modules
 Multiselect for current modules. More...
 
class  admin_setting_configpasswordunmask
 Password field, allows unmasking of password. More...
 
class  admin_setting_configpasswordunmask_with_advanced
 Password field, allows unmasking of password, with an advanced checkbox that controls an additional $name. More...
 
class  admin_setting_configportlist
 Used to validate a textarea used for port numbers. More...
 
class  admin_setting_configselect
 Select one value from list. More...
 
class  admin_setting_configselect_with_advanced
 Dropdown menu with an advanced checkbox, that controls a additional $name. More...
 
class  admin_setting_configselect_with_lock
 Select with an advanced checkbox that controls an additional $name. More...
 
class  admin_setting_configstoredfile
 Class used for uploading of one file into file storage, the file name is stored in config table. More...
 
class  admin_setting_configtext
 The most flexible setting, the user enters text. More...
 
class  admin_setting_configtext_with_advanced
 Text field with an advanced checkbox, that controls a additional $name. More...
 
class  admin_setting_configtext_with_maxlength
 Text input with a maximum length constraint. More...
 
class  admin_setting_configtextarea
 General text area without html editor. More...
 
class  admin_setting_configthemepreset
 Used to validate theme presets code and ensuring they compile well. More...
 
class  admin_setting_configtime
 Time selector. More...
 
class  admin_setting_countrycodes
 
class  admin_setting_courselist_frontpage
 Special select - lists on the frontpage - hacky. More...
 
class  admin_setting_description
 No setting - just name and description in same row. More...
 
class  admin_setting_devicedetectregex
 Administration interface for user specified regular expressions for device detection. More...
 
class  admin_setting_emoticons
 Administration interface for emoticon_manager settings. More...
 
class  admin_setting_enablemobileservice
 Special checkbox for enable mobile web service If enable then we store the service id of the mobile service into config table If disable then we unstore the service id from the config table. More...
 
class  admin_setting_filetypes
 Administration setting to define a list of file types. More...
 
class  admin_setting_flag
 An additional option that can be applied to an admin setting. More...
 
class  admin_setting_forcetimezone
 Forced user timezone setting. More...
 
class  admin_setting_grade_profilereport
 Selection of grade report in user profiles. More...
 
class  admin_setting_gradecat_combo
 Grade category settings. More...
 
class  admin_setting_heading
 No setting - just heading and text. More...
 
class  admin_setting_langlist
 Special setting for limiting of the list of available languages. More...
 
class  admin_setting_manage_fileconverter_plugins
 Generic class for managing plugins in a table that allows re-ordering and enable/disable of each plugin. More...
 
class  admin_setting_manage_plugins
 Generic class for managing plugins in a table that allows re-ordering and enable/disable of each plugin. More...
 
class  admin_setting_manageantiviruses
 Special class for antiviruses administration. More...
 
class  admin_setting_manageauths
 Special class for authentication administration. More...
 
class  admin_setting_managecontentbankcontenttypes
 Content bank content types manager. More...
 
class  admin_setting_managecustomfields
 Custom fields manager. More...
 
class  admin_setting_managedataformats
 Data formats manager. More...
 
class  admin_setting_manageeditors
 Special class for authentication administration. More...
 
class  admin_setting_manageenrols
 Special class for enrol plugins management. More...
 
class  admin_setting_manageexternalservices
 Special class for management of external services. More...
 
class  admin_setting_manageformats
 Course formats manager. More...
 
class  admin_setting_managelicenses
 Special class for license administration. More...
 
class  admin_setting_managemediaplayers
 Special class for media player plugins management. More...
 
class  admin_setting_managerepository
 Manage repository settings. More...
 
class  admin_setting_managewebserviceprotocols
 Special class for web service protocol administration. More...
 
class  admin_setting_managewebservicetokens
 Special class for web service token administration. More...
 
class  admin_setting_my_grades_report
 Provides a selection of grade reports to be used for "grades". More...
 
class  admin_setting_php_extension_enabled
 Admin setting to show if a php extension is enabled or not. More...
 
class  admin_setting_pickfilters
 Admin setting that is a list of installed filter plugins. More...
 
class  admin_setting_pickroles
 Admin setting that allows a user to pick appropriate roles for something. More...
 
class  admin_setting_question_behaviour
 Admin setting that allows a user to pick a behaviour. More...
 
class  admin_setting_regradingcheckbox
 
class  admin_setting_scsscode
 Used to validate the contents of SCSS code and ensuring they are parsable. More...
 
class  admin_setting_searchsetupinfo
 Search setup steps info. More...
 
class  admin_setting_servertimezone
 Server timezone setting. More...
 
class  admin_setting_sitesetcheckbox
 Special checkbox for frontpage - stores data in course table. More...
 
class  admin_setting_sitesetselect
 Special select for frontpage - stores data in course table. More...
 
class  admin_setting_sitesettext
 Special text for frontpage - stores data in course table. More...
 
class  admin_setting_special_adminseesall
 Special checkbox for calendar - resets SESSION vars. More...
 
class  admin_setting_special_backup_auto_destination
 Special setting for backup auto destination. More...
 
class  admin_setting_special_backupdays
 Special control for selecting days to backup. More...
 
class  admin_setting_special_calendar_weekend
 Special admin control. More...
 
class  admin_setting_special_coursecontact
 Which roles to show on course description page. More...
 
class  admin_setting_special_debug
 Special debug setting. More...
 
class  admin_setting_special_frontpagedesc
 Special text editor for site description. More...
 
class  admin_setting_special_gradebookroles
 Graded roles in gradebook. More...
 
class  admin_setting_special_gradeexport
 Primary grade export plugin - has state tracking. More...
 
class  admin_setting_special_gradelimiting
 
class  admin_setting_special_grademinmaxtouse
 Special setting for $CFG->grade_minmaxtouse. More...
 
class  admin_setting_special_gradepointdefault
 A setting for setting the default grade point value. More...
 
class  admin_setting_special_gradepointmax
 A setting for setting the maximum grade value. More...
 
class  admin_setting_special_registerauth
 Special class for register auth selection. More...
 
class  admin_setting_special_selectsetup
 Special select for settings that are altered in setup.php and can not be altered on the fly. More...
 
class  admin_setting_users_with_capability
 An admin setting for selecting one or more users who have a capability in the system context. More...
 
class  admin_setting_webservicesoverview
 Special class for overview of external services. More...
 
class  admin_settingdependency
 Used to store details of the dependency between two settings elements. More...
 
class  admin_settingpage
 Used to group a number of admin_setting objects into a page and add them to the admin tree. More...
 
class  admin_settings_country_select
 Selection of one of the recognised countries using the list returned by get_list_of_countries(). More...
 
class  admin_settings_coursecat_select
 Course category selection. More...
 
class  admin_settings_h5plib_handler_select
 Selection of plugins that can work as H5P libraries handlers. More...
 
class  admin_settings_num_course_sections
 admin_setting_configselect for the default number of sections in a course, simply so we can lazy-load the choices. More...
 
class  admin_settings_sitepolicy_handler_select
 Selection of plugins that can work as site policy handlers. More...
 
interface  parentable_part_of_admin_tree
 Interface implemented by any part_of_admin_tree that has children. More...
 
interface  part_of_admin_tree
 CLASS DEFINITIONS /////////////////////////////////////////////////////////. More...
 

Functions

 admin_apply_default_settings ($node=null, $unconditional=true, $admindefaultsettings=array(), $settingsoutput=array())
 settings utility functions More...
 
 admin_critical_warnings_present ()
 Test if and critical warnings are present. More...
 
moodle_page admin_externalpage_setup ($section, $extrabutton='', array $extraurlparams=null, $actualurl='', array $options=array())
 Initialise admin page - this function does require login and permission checks specified in page definition. More...
 
 admin_find_write_settings ($node, $data)
 Internal recursive function - finds all settings from submitted form. More...
 
 admin_get_root ($reload=false, $requirefulltree=true)
 Returns the reference to admin tree root. More...
 
 admin_output_new_settings_by_page ($node)
 Internal function - returns arrays of html pages with uninitialised settings. More...
 
 admin_search_settings_html ($query)
 Internal function - prints the search results. More...
 
 admin_write_settings ($formdata)
 Store changed settings, this function updates the errors variable in $ADMIN. More...
 
 any_new_admin_settings ($node)
 Based on find_new_settings() in upgradesettings.php Looks to find any admin settings that have not been initialized. More...
 
 db_replace ($search, $replace)
 Moved from admin/replace.php so that we can use this in cron. More...
 
 db_should_replace ($table, $column='')
 Given a table and optionally a column name should replaces be done? More...
 
 drop_plugin_tables ($name, $file, $feedback=true)
 Delete all plugin tables. More...
 
 enable_cli_maintenance_mode ()
 Enables CLI maintenance mode by creating new dataroot/climaintenance.html file.
 
 format_admin_setting ($setting, $title='', $form='', $description='', $label=true, $warning='', $defaultinfo=NULL, $query='')
 Format admin settings. More...
 
 get_component_version ($component, $source='installed')
 Returns the version of installed component. More...
 
 get_db_directories ()
 Returns list of all directories where we expect install.xml files. More...
 
 get_used_table_names ()
 Returns names of all known tables == tables that moodle knows about. More...
 
 is_dataroot_insecure ($fetchtest=false)
 Try to verify that dataroot is not accessible from web. More...
 
 is_float_problem ()
 Detects if float supports at least 10 decimal digits. More...
 
 set_cron_lock ($name, $until, $ignorecurrent=false)
 Try to obtain or release the cron lock. More...
 
 uninstall_plugin ($type, $name)
 Automatically clean-up all plugin data and remove the plugin DB tables. More...
 

Variables

const INSECURE_DATAROOT_ERROR 2
 
const INSECURE_DATAROOT_WARNING 1
 Add libraries.
 

Detailed Description

Functions and classes used during installation, upgrades and for admin settings.

ADMIN SETTINGS TREE 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_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(DIR.'/../../config.php'); require_once($CFG->libdir.'/adminlib.php'); admin_externalpage_setup('foo'); // functionality like processing form submissions goes here echo $OUTPUT->header(); // your HTML goes here echo $OUTPUT->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. It also configures all $PAGE properties needed for navigation.

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.

Original author: Vincenzo K. Marcovecchio Maintainer: Petr Skoda

@subpackage admin

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later