Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
admin

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_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_autocomplete
 Autocomplete as you type form element. 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
 Allows to specify comma separated list of known country codes. More...
 
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_encryptedpassword
 Admin setting class for encrypted values using secure encryption. 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_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_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_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_requiredpasswordunmask
 This type of field should be used for mandatory config settings where setting password is required. More...
 
class  admin_setting_requiredtext
 This type of field should be used for mandatory config settings. More...
 
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 (?part_of_admin_tree $node=null, bool $unconditional=true)
 settings utility functions
 
 admin_critical_warnings_present ()
 Test if and critical warnings are present.
 
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.
 
 admin_find_write_settings ($node, $data)
 Internal recursive function - finds all settings from submitted form.
 
 admin_get_root ($reload=false, $requirefulltree=true)
 Returns the reference to admin tree root.
 
 admin_output_new_settings_by_page ($node)
 Internal function - returns arrays of html pages with uninitialised settings.
 
 admin_search_settings_html ($query)
 Internal function - prints the search results.
 
 admin_write_settings ($formdata)
 Store changed settings, this function updates the errors variable in $ADMIN.
 
 any_new_admin_settings ($node)
 Based on find_new_settings() in upgradesettings.php Looks to find any admin settings that have not been initialized.
 
 db_replace ($search, $replace, $additionalskiptables='')
 Moved from admin/replace.php so that we can use this in cron.
 
 db_should_replace ($table, $column='', $additionalskiptables='')
 Given a table and optionally a column name should replaces be done?
 
 drop_plugin_tables ($name, $file, $feedback=true)
 Delete all plugin tables.
 
 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.
 
 get_component_version ($component, $source='installed')
 Returns the version of installed component.
 
 get_db_directories ()
 Returns list of all directories where we expect install.xml files.
 
 get_used_table_names ()
 Returns names of all known tables == tables that moodle knows about.
 
 is_dataroot_insecure ($fetchtest=false)
 Try to verify that dataroot is not accessible from web.
 
 is_float_problem ()
 Detects if float supports at least 10 decimal digits.
 
 set_cron_lock ($name, $until, $ignorecurrent=false)
 Try to obtain or release the cron lock.
 
 uninstall_plugin ($type, $name)
 Automatically clean-up all plugin data and remove the plugin DB tables.
 

Variables

const INSECURE_DATAROOT_ERROR 2
 
const INSECURE_DATAROOT_WARNING 1
 Add libraries.
 

Detailed Description

Function Documentation

◆ admin_apply_default_settings()

admin_apply_default_settings ( ?part_of_admin_tree $node = null,
bool $unconditional = true )

settings utility functions

This function applies default settings recursively.

Because setting the defaults of some settings can enable other settings, this function calls itself repeatedly (max 4 times) until no more new settings are saved.

NOTE: previous "internal" parameters $admindefaultsettings, $settingsoutput were removed in Moodle 4.3.

Parameters
part_of_admin_tree | null$nodeNULL means apply all settings with repeated recursion
bool$unconditionalif true overrides all values with defaults (true for installation, false for CLI upgrade)
Return values
arrayThe names and values of the applied setting defaults

◆ admin_critical_warnings_present()

admin_critical_warnings_present ( )

Test if and critical warnings are present.

Return values
bool

◆ admin_externalpage_setup()

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.

This function must be called on each admin page before other code.

$PAGE

Parameters
string$sectionname of page
string$extrabuttonextra HTML that is added after the blocks editing on/off button.
array$extraurlparamsan array paramname => paramvalue, or parameters that need to be added to the turn blocks editing on/off form, so this page reloads correctly.
string$actualurlif the actual page being viewed is not the normal one for this page (e.g. admin/roles/allow.php, instead of admin/roles/manage.php, you can pass the alternate URL here.
array$optionsAdditional options that can be specified for page setup. pagelayout - This option can be used to set a specific pagelyaout, admin is default. nosearch - Do not display search bar

◆ admin_find_write_settings()

admin_find_write_settings ( $node,
$data )

Internal recursive function - finds all settings from submitted form.

Parameters
object$nodeInstance of admin_category, or admin_settingpage
array$data
Return values
array

◆ admin_get_root()

admin_get_root ( $reload = false,
$requirefulltree = true )

Returns the reference to admin tree root.

Return values
objectadmin_root object

◆ admin_output_new_settings_by_page()

admin_output_new_settings_by_page ( $node)

Internal function - returns arrays of html pages with uninitialised settings.

Parameters
object$nodeInstance of admin_category or admin_settingpage
Return values
array

◆ admin_search_settings_html()

admin_search_settings_html ( $query)

Internal function - prints the search results.

Parameters
string$queryString to search for
Return values
stringempty or XHTML

◆ admin_write_settings()

admin_write_settings ( $formdata)

Store changed settings, this function updates the errors variable in $ADMIN.

Parameters
object$formdatafrom form
Return values
intnumber of changed settings

◆ any_new_admin_settings()

any_new_admin_settings ( $node)

Based on find_new_settings() in upgradesettings.php Looks to find any admin settings that have not been initialized.

Returns 1 if it finds any.

Parameters
object$nodeInstance of admin_category, or admin_settingpage
Return values
booleantrue if any settings haven't been initialised, false if they all have

◆ db_replace()

db_replace ( $search,
$replace,
$additionalskiptables = '' )

Moved from admin/replace.php so that we can use this in cron.

Parameters
string$searchstring to look for
string$replacestring to replace
Return values
boolsuccess or fail

◆ db_should_replace()

db_should_replace ( $table,
$column = '',
$additionalskiptables = '' )

Given a table and optionally a column name should replaces be done?

Parameters
string$tablename
string$columnname
Return values
boolsuccess or fail

◆ drop_plugin_tables()

drop_plugin_tables ( $name,
$file,
$feedback = true )

Delete all plugin tables.

Parameters
string$nameName of plugin, used as table prefix
string$filePath to install.xml file
bool$feedbackdefaults to true
Return values
boolAlways returns true

◆ format_admin_setting()

format_admin_setting ( $setting,
$title = '',
$form = '',
$description = '',
$label = true,
$warning = '',
$defaultinfo = NULL,
$query = '' )

Format admin settings.

Parameters
object$setting
string$titlelabel element
string$formform fragment, html code - not highlighted automatically
string$description
mixed$labellink label to id, true by default or string being the label to connect it to
string$warningwarning text
sting$defaultinfodefaults info, null means nothing, '' is converted to "Empty" string, defaults to null
string$querysearch query to be highlighted
Return values
stringXHTML

◆ get_component_version()

get_component_version ( $component,
$source = 'installed' )

Returns the version of installed component.

Parameters
string$componentcomponent name
string$sourceeither 'disk' or 'installed' - where to get the version information from
Return values
string|boolversion number or false if the component is not found

◆ get_db_directories()

get_db_directories ( )

Returns list of all directories where we expect install.xml files.

Return values
arrayArray of paths

◆ get_used_table_names()

get_used_table_names ( )

Returns names of all known tables == tables that moodle knows about.

Return values
arrayArray of lowercase table names

◆ is_dataroot_insecure()

is_dataroot_insecure ( $fetchtest = false)

Try to verify that dataroot is not accessible from web.

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.

@uses INSECURE_DATAROOT_WARNING @uses INSECURE_DATAROOT_ERROR

Parameters
bool$fetchtesttry to test public access by fetching file, default false
Return values
mixedempty means secure, INSECURE_DATAROOT_ERROR found a critical problem, INSECURE_DATAROOT_WARNING might be problematic

◆ is_float_problem()

is_float_problem ( )

Detects if float supports at least 10 decimal digits.

Detects if float supports at least 10 decimal digits and also if float-->string conversion works as expected.

Return values
booltrue if problem found

◆ set_cron_lock()

set_cron_lock ( $name,
$until,
$ignorecurrent = false )

Try to obtain or release the cron lock.

Parameters
string$namename of lock
int$untiltimestamp when this lock considered stale, null means remove lock unconditionally
bool$ignorecurrentignore current lock state, usually extend previous lock, defaults to false
Return values
booltrue if lock obtained

◆ uninstall_plugin()

uninstall_plugin ( $type,
$name )

Automatically clean-up all plugin data and remove the plugin DB tables.

NOTE: do not call directly, use new /admin/plugins.php?uninstall=component instead!

Parameters
string$typeThe plugin type, eg. 'mod', 'qtype', 'workshopgrading' etc.
string$nameThe plugin name, eg. 'forum', 'multichoice', 'accumulative' etc. @uses global $OUTPUT to produce notices and other messages
Return values
void