Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
admin_setting Class Reference

Admin settings class. More...

Inheritance diagram for admin_setting:
admin_setting_configcheckbox admin_setting_configcolourpicker admin_setting_configduration admin_setting_configmulticheckbox admin_setting_configselect admin_setting_configstoredfile admin_setting_configtext admin_setting_configtime admin_setting_courselist_frontpage admin_setting_description admin_setting_devicedetectregex admin_setting_emoticons admin_setting_encryptedpassword admin_setting_gradecat_combo admin_setting_heading admin_setting_ldap_rolemapping admin_setting_manage_plugins admin_setting_manageantiviruses admin_setting_manageauths admin_setting_managecontentbankcontenttypes admin_setting_managecustomfields admin_setting_managedataformats admin_setting_manageenrols admin_setting_manageexternalservices admin_setting_manageformats admin_setting_managemediaplayers admin_setting_managerepository admin_setting_managewebserviceprotocols admin_setting_php_extension_enabled admin_setting_searchsetupinfo admin_setting_special_calendar_weekend admin_setting_webservicesoverview core_admin\admin\admin_setting_plugin_manager core_admin\local\settings\filesize core_communication\admin\manage_communication_providers_page core_question\admin\manage_qbank_plugins_page editor_atto_subplugins_setting enrol_lti\local\ltiadvantage\admin\admin_setting_registeredplatforms mod_glossary_admin_setting_display_formats mod_quiz\admin\review_setting tiny_premium\local\admin_setting_tiny_premium_plugins tool_log_setting_managestores tool_mfa\local\admin_setting_managemfa

Public Member Functions

 __construct ($name, $visiblename, $description, $defaultsetting)
 Constructor.
 
 add_dependent_on ($dependenton)
 Add a setting to the list of those that could cause this one to be hidden.
 
 config_read ($name)
 Returns the config if possible.
 
 config_write ($name, $value)
 Used to set a config pair and log change.
 
 get_defaultsetting ()
 Returns default setting if exists.
 
 get_dependent_on ()
 Get a list of the settings that could cause this one to be hidden.
 
 get_force_ltr ()
 Get whether this should be displayed in LTR mode.
 
 get_full_name ()
 Returns the fullname prefixed by the plugin.
 
 get_id ()
 Returns the ID string based on plugin and name.
 
 get_setting ()
 Returns current value of this setting.
 
 get_setting_flag_defaults (& $defaults)
 Get the list of defaults for the flags on this setting.
 
 get_setting_flag_value (admin_setting_flag $flag)
 Get the currently saved value for a setting flag.
 
 has_custom_form_control ()
 Whether this setting uses a custom form control.
 
 is_forceable ()
 Whether the setting can be overridden in config.php.
 
 is_readonly ()
 Is this option forced in config.php?
 
 is_related ($query)
 Is setting related to query text - used when searching.
 
 output_html ($data, $query='')
 Return part of form with setting This function should always be overwritten.
 
 output_setting_flags ()
 Output the input fields for the advanced and locked flags on this setting.
 
 post_write_settings ($original)
 Execute postupdatecallback if necessary.
 
 set_advanced_flag_options ($enabled, $default)
 Set the advanced options flag on this admin setting.
 
 set_affects_modinfo ($affectsmodinfo)
 
 set_enabled_flag_options ($enabled, $default)
 Set the enabled options flag on this admin setting.
 
 set_force_ltr ($value)
 Set whether to force LTR or not.
 
 set_locked_flag_options ($enabled, $default)
 Set the locked options flag on this admin setting.
 
 set_required_flag_options ($enabled, $default)
 Set the required options flag on this admin setting.
 
 set_updatedcallback ($functionname)
 Function called if setting updated - cleanup, cache reset, etc.
 
 write_setting ($data)
 Store new setting.
 
 write_setting_flags ($data)
 Write the values of the flags for this admin setting.
 

Public Attributes

bool $affectsmodinfo = false
 if set, indicates that a change to this setting requires rebuild course cache
 
mixed $defaultsetting
 Can be string or array of string.
 
string $description
 localised long description in Markdown format
 
string $name
 unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins.
 
bool $nosave = false
 true indicates this setting does not actually save anything, just information
 
mixed $paramtype
 int means PARAM_XXX type, string is a allowed format in regex
 
mixed $plugin
 can be String or Null.
 
string $updatedcallback
 
lang_string string $visiblename
 localised name
 

Protected Member Functions

 add_to_config_log ($name, $oldvalue, $value)
 Log config changes if necessary.
 
 set_flag_options ($enabled, $default, $shortname, $displayname)
 Generic function to add a flag to this admin setting.
 

Protected Attributes

bool $customcontrol = false
 Whether this setting uses a custom form control.
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

admin_setting::__construct ( $name,
$visiblename,
$description,
$defaultsetting )

Constructor.

Parameters
string$nameunique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins.
string$visiblenamelocalised name
string$descriptionlocalised long description
mixed$defaultsettingstring or array depending on implementation

Reimplemented in admin_setting_configfile, admin_setting_configpasswordunmask, admin_setting_configpasswordunmask_with_advanced, admin_setting_devicedetectregex, admin_setting_ldap_rolemapping, admin_setting_php_extension_enabled, admin_setting_pickfilters, admin_setting_pickroles, admin_setting_question_behaviour, admin_settings_coursecat_select, admin_settings_h5plib_handler_select, admin_settings_num_course_sections, admin_settings_sitepolicy_handler_select, and auth_shibboleth_admin_setting_convert_data.

Member Function Documentation

◆ add_dependent_on()

admin_setting::add_dependent_on ( $dependenton)

Add a setting to the list of those that could cause this one to be hidden.

Parameters
string$dependenton

◆ add_to_config_log()

admin_setting::add_to_config_log ( $name,
$oldvalue,
$value )
protected

Log config changes if necessary.

Parameters
string$name
string$oldvalue
string$value

Reimplemented in admin_setting_configpasswordunmask.

◆ config_read()

admin_setting::config_read ( $name)

Returns the config if possible.

Return values
mixedreturns config if successful else null

Reimplemented in enrol_flatfile_role_setting.

◆ config_write()

admin_setting::config_write ( $name,
$value )

Used to set a config pair and log change.

Parameters
string$name
mixed$valueGets converted to string if not null
Return values
boolWrite setting to config table

Reimplemented in enrol_flatfile_role_setting.

◆ get_defaultsetting()

◆ get_dependent_on()

admin_setting::get_dependent_on ( )

Get a list of the settings that could cause this one to be hidden.

Return values
array

◆ get_force_ltr()

admin_setting::get_force_ltr ( )

Get whether this should be displayed in LTR mode.

Return values
bool|null

Reimplemented in admin_setting_configtext, and admin_setting_filetypes.

◆ get_full_name()

admin_setting::get_full_name ( )

Returns the fullname prefixed by the plugin.

Return values
string

Reimplemented in admin_setting_managerepository.

◆ get_id()

admin_setting::get_id ( )

Returns the ID string based on plugin and name.

Return values
string

◆ get_setting()

admin_setting::get_setting ( )
abstract

Returns current value of this setting.

Return values
mixedarray or string depending on instance, NULL means not set yet

Reimplemented in admin_setting_configcheckbox, admin_setting_configcolourpicker, admin_setting_configduration, admin_setting_configmixedhostiplist, admin_setting_configmulticheckbox2, admin_setting_configmulticheckbox, admin_setting_configmultiselect, admin_setting_configselect, admin_setting_configstoredfile, admin_setting_configtext, admin_setting_configtime, admin_setting_courselist_frontpage, admin_setting_description, admin_setting_devicedetectregex, admin_setting_emoticons, admin_setting_enablemobileservice, admin_setting_encryptedpassword, admin_setting_gradecat_combo, admin_setting_heading, admin_setting_ldap_rolemapping, admin_setting_manage_plugins, admin_setting_manageantiviruses, admin_setting_manageauths, admin_setting_managecontentbankcontenttypes, admin_setting_managecustomfields, admin_setting_managedataformats, admin_setting_manageenrols, admin_setting_manageexternalservices, admin_setting_manageformats, admin_setting_managemediaplayers, admin_setting_managerepository, admin_setting_managewebserviceprotocols, admin_setting_php_extension_enabled, admin_setting_searchsetupinfo, admin_setting_sitesetcheckbox, admin_setting_sitesetselect, admin_setting_sitesettext, admin_setting_special_calendar_weekend, admin_setting_special_frontpagedesc, admin_setting_special_selectsetup, admin_setting_users_with_capability, admin_setting_webservicesoverview, core_admin\admin\admin_setting_plugin_manager, core_admin\local\settings\autocomplete, core_admin\local\settings\filesize, core_communication\admin\manage_communication_providers_page, core_question\admin\manage_qbank_plugins_page, editor_atto_subplugins_setting, enrol_lti\local\ltiadvantage\admin\admin_setting_registeredplatforms, mod_glossary_admin_setting_display_formats, mod_quiz\admin\review_setting, tiny_premium\local\admin_setting_tiny_premium_plugins, tool_log_setting_managestores, and tool_mfa\local\admin_setting_managemfa.

◆ get_setting_flag_defaults()

admin_setting::get_setting_flag_defaults ( & $defaults)

Get the list of defaults for the flags on this setting.

Parameters
arrayof strings describing the defaults for this setting. This is appended to by this function.

◆ get_setting_flag_value()

admin_setting::get_setting_flag_value ( admin_setting_flag $flag)

Get the currently saved value for a setting flag.

Parameters
admin_setting_flag$flag- One of the admin_setting_flag for this admin_setting.
Return values
bool

◆ has_custom_form_control()

admin_setting::has_custom_form_control ( )

Whether this setting uses a custom form control.

This function is especially useful to decide if we should render a label element for this setting or not.

Return values
bool

◆ is_forceable()

admin_setting::is_forceable ( )

Whether the setting can be overridden in config.php.

Returning true will allow the setting to be defined and overridden in config.php. Returning false will prevent the config setting from being overridden even when it gets defined in config.php.

Return values
bool

Reimplemented in admin_setting_sitesetcheckbox, admin_setting_sitesetselect, admin_setting_sitesettext, and admin_setting_special_frontpagedesc.

◆ is_readonly()

admin_setting::is_readonly ( )

Is this option forced in config.php?

Return values
bool

◆ is_related()

◆ output_html()

admin_setting::output_html ( $data,
$query = '' )

Return part of form with setting This function should always be overwritten.

Parameters
mixed$dataarray or string depending on setting
string$query
Return values
string

Reimplemented in admin_setting_configcheckbox, admin_setting_configcolourpicker, admin_setting_configdirectory, admin_setting_configduration, admin_setting_configempty, admin_setting_configexecutable, admin_setting_configfile, admin_setting_confightmleditor, admin_setting_configmulticheckbox, admin_setting_configmultiselect, admin_setting_configpasswordunmask, admin_setting_configselect, admin_setting_configselect_autocomplete, admin_setting_configstoredfile, admin_setting_configtext, admin_setting_configtextarea, admin_setting_configtime, admin_setting_courselist_frontpage, admin_setting_description, admin_setting_devicedetectregex, admin_setting_emoticons, admin_setting_enablemobileservice, admin_setting_encryptedpassword, admin_setting_filetypes, admin_setting_gradecat_combo, admin_setting_heading, admin_setting_ldap_rolemapping, admin_setting_manage_plugins, admin_setting_manageantiviruses, admin_setting_manageauths, admin_setting_managecontentbankcontenttypes, admin_setting_managecustomfields, admin_setting_managedataformats, admin_setting_manageenrols, admin_setting_manageexternalservices, admin_setting_manageformats, admin_setting_managemediaplayers, admin_setting_managerepository, admin_setting_managewebserviceprotocols, admin_setting_php_extension_enabled, admin_setting_searchsetupinfo, admin_setting_special_calendar_weekend, admin_setting_special_gradepointmax, admin_setting_webservicesoverview, core_admin\admin\admin_setting_plugin_manager, core_admin\local\settings\autocomplete, core_admin\local\settings\filesize, core_admin\local\settings\setting_scheduled_task_status, core_communication\admin\manage_communication_providers_page, core_question\admin\manage_qbank_plugins_page, editor_atto_subplugins_setting, enrol_lti\local\ltiadvantage\admin\admin_setting_registeredplatforms, mod_glossary_admin_setting_display_formats, mod_quiz\admin\review_setting, tiny_premium\local\admin_setting_tiny_premium_plugins, tool_log_setting_managestores, and tool_mfa\local\admin_setting_managemfa.

◆ output_setting_flags()

admin_setting::output_setting_flags ( )

Output the input fields for the advanced and locked flags on this setting.

Parameters
bool$adv- The current value of the advanced flag.
bool$locked- The current value of the locked flag.
Return values
string\$output- The html for the flags.

◆ post_write_settings()

admin_setting::post_write_settings ( $original)

Execute postupdatecallback if necessary.

Parameters
mixed$originaloriginal value before write_setting()
Return values
booltrue if changed, false if not.

Reimplemented in admin_setting_configstoredfile.

◆ set_advanced_flag_options()

admin_setting::set_advanced_flag_options ( $enabled,
$default )

Set the advanced options flag on this admin setting.

Parameters
bool$enabled- One of self\OPTION_ENABLED or self\OPTION_DISABLED
bool$default- The default for the flag

◆ set_affects_modinfo()

admin_setting::set_affects_modinfo ( $affectsmodinfo)
Parameters
bool$affectsmodinfoIf true, changes to this setting will cause the course cache to be rebuilt

◆ set_enabled_flag_options()

admin_setting::set_enabled_flag_options ( $enabled,
$default )

Set the enabled options flag on this admin setting.

Parameters
bool$enabled- One of self\OPTION_ENABLED or self\OPTION_DISABLED
bool$default- The default for the flag

◆ set_flag_options()

admin_setting::set_flag_options ( $enabled,
$default,
$shortname,
$displayname )
protected

Generic function to add a flag to this admin setting.

Parameters
bool$enabled- One of self\OPTION_ENABLED or self\OPTION_DISABLED
bool$default- The default for the flag
string$shortname- The shortname for this flag. Used as a suffix for the setting name.
string$displayname- The display name for this flag. Used as a label next to the checkbox.

◆ set_force_ltr()

admin_setting::set_force_ltr ( $value)

Set whether to force LTR or not.

Parameters
bool$valueTrue when forced, false when not force, null when unknown.

◆ set_locked_flag_options()

admin_setting::set_locked_flag_options ( $enabled,
$default )

Set the locked options flag on this admin setting.

Parameters
bool$enabled- One of self\OPTION_ENABLED or self\OPTION_DISABLED
bool$default- The default for the flag

◆ set_required_flag_options()

admin_setting::set_required_flag_options ( $enabled,
$default )

Set the required options flag on this admin setting.

Parameters
bool$enabled- One of self\OPTION_ENABLED or self\OPTION_DISABLED.
bool$default- The default for the flag.

◆ set_updatedcallback()

admin_setting::set_updatedcallback ( $functionname)

Function called if setting updated - cleanup, cache reset, etc.

Parameters
string$functionnameSets the function name
Return values
void

◆ write_setting()

admin_setting::write_setting ( $data)
abstract

Store new setting.

Parameters
mixed$datastring or array, must not be NULL
Return values
stringempty string if ok, string error message otherwise

Reimplemented in admin_setting_bloglevel, admin_setting_configcheckbox, admin_setting_configcolourpicker, admin_setting_configduration, admin_setting_configfile, admin_setting_confightmleditor, admin_setting_configmixedhostiplist, admin_setting_configmulticheckbox2, admin_setting_configmulticheckbox, admin_setting_configmultiselect, admin_setting_configselect, admin_setting_configstoredfile, admin_setting_configtext, admin_setting_configtext_trim_lower, admin_setting_configthemepreset, admin_setting_configtime, admin_setting_courselist_frontpage, admin_setting_description, admin_setting_devicedetectregex, admin_setting_emoticons, admin_setting_enablemobileservice, admin_setting_encryptedpassword, admin_setting_filetypes, admin_setting_gradecat_combo, admin_setting_heading, admin_setting_langlist, admin_setting_ldap_rolemapping, admin_setting_manage_plugins, admin_setting_manageantiviruses, admin_setting_manageauths, admin_setting_managecontentbankcontenttypes, admin_setting_managecustomfields, admin_setting_managedataformats, admin_setting_manageenrols, admin_setting_manageexternalservices, admin_setting_manageformats, admin_setting_managemediaplayers, admin_setting_managerepository, admin_setting_managewebserviceprotocols, admin_setting_php_extension_enabled, admin_setting_regradingcheckbox, admin_setting_searchsetupinfo, admin_setting_sitesetcheckbox, admin_setting_sitesetselect, admin_setting_sitesettext, admin_setting_special_adminseesall, admin_setting_special_backup_auto_destination, admin_setting_special_calendar_weekend, admin_setting_special_frontpagedesc, admin_setting_special_gradelimiting, admin_setting_special_grademinmaxtouse, admin_setting_special_gradepointmax, admin_setting_special_selectsetup, admin_setting_users_with_capability, admin_setting_webservicesoverview, antivirus_clamav_runningmethod_setting, auth_db_admin_setting_special_auth_configtext, auth_ldap_admin_setting_special_contexts_configtext, auth_ldap_admin_setting_special_lowercase_configtext, auth_shibboleth_admin_setting_special_idp_configtextarea, auth_shibboleth_admin_setting_special_wayf_select, core_admin\admin\admin_setting_plugin_manager, core_admin\local\settings\autocomplete, core_admin\local\settings\filesize, core_analytics\admin_setting_predictor, core_communication\admin\manage_communication_providers_page, core_question\admin\manage_qbank_plugins_page, editor_atto_subplugins_setting, enrol_lti\local\ltiadvantage\admin\admin_setting_registeredplatforms, mod_glossary_admin_setting_display_formats, mod_quiz\admin\review_setting, tiny_premium\local\admin_setting_tiny_premium_plugins, tool_log_setting_managestores, and tool_mfa\local\admin_setting_managemfa.

◆ write_setting_flags()

admin_setting::write_setting_flags ( $data)

Write the values of the flags for this admin setting.

Parameters
array$data- The data submitted from the form or null to set the default value for new installs.
Return values
bool- true if successful.

Member Data Documentation

◆ $plugin

mixed admin_setting::$plugin

can be String or Null.

Null means main config table


The documentation for this class was generated from the following file: