Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Seconds duration setting. More...
Public Member Functions | |
__construct ($name, $visiblename, $description, $defaultsetting, $defaultunit=86400) | |
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 () | |
Get the selected duration as array. | |
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='') | |
Returns duration text+select fields. | |
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_max_duration (?int $duration) | |
Set the maximum allowed value. | |
set_min_duration (int $duration) | |
Set the minimum allowed value. | |
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. | |
set_validate_function (?callable $validatefunction=null) | |
Sets a validate function. | |
write_setting ($data) | |
Store the duration as seconds. | |
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. | |
validate_setting (int $data) | |
Validate the setting. | |
Static Protected Member Functions | |
static | get_duration_text (int $seconds, ?string $emptyvalue=null) |
Converts seconds to some more user friendly string. | |
static | get_units () |
Returns selectable units. | |
static | parse_seconds ($seconds) |
Finds suitable units for given duration. | |
Seconds duration setting.
admin_setting_configduration::__construct | ( | $name, | |
$visiblename, | |||
$description, | |||
$defaultsetting, | |||
$defaultunit = 86400 ) |
Constructor.
string | $name | unique ascii name, either 'mysetting' for settings that in config, or 'myplugin/mysetting' for ones in config_plugins. |
string | $visiblename | localised name |
string | $description | localised long description |
mixed | $defaultsetting | string or array depending on implementation |
int | $defaultunit | - day, week, etc. (in seconds) |
Reimplemented in admin_setting_configduration_with_advanced.
|
inherited |
Add a setting to the list of those that could cause this one to be hidden.
string | $dependenton |
|
protectedinherited |
Log config changes if necessary.
string | $name | |
string | $oldvalue | |
string | $value |
Reimplemented in admin_setting_configpasswordunmask.
|
inherited |
Returns the config if possible.
mixed | returns config if successful else null |
Reimplemented in enrol_flatfile_role_setting.
|
inherited |
Used to set a config pair and log change.
string | $name | |
mixed | $value | Gets converted to string if not null |
bool | Write setting to config table |
Reimplemented in enrol_flatfile_role_setting.
|
inherited |
Returns default setting if exists.
mixed | array or string depending on instance; NULL means no default, user must supply |
Reimplemented in admin_setting_description, admin_setting_heading, 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_pickroles, admin_setting_searchsetupinfo, admin_setting_special_registerauth, admin_setting_users_with_capability, admin_setting_webservicesoverview, core_admin\admin\admin_setting_plugin_manager, 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, and tool_log_setting_managestores.
|
inherited |
Get a list of the settings that could cause this one to be hidden.
array |
|
staticprotected |
Converts seconds to some more user friendly string.
int | $seconds | |
null|string | The value to use when the duration is empty. If not specified, a "None" value is used. |
string |
|
inherited |
Get whether this should be displayed in LTR mode.
bool|null |
Reimplemented in admin_setting_configtext, and admin_setting_filetypes.
|
inherited |
Returns the fullname prefixed by the plugin.
string |
Reimplemented in admin_setting_managerepository.
|
inherited |
Returns the ID string based on plugin and name.
string |
admin_setting_configduration::get_setting | ( | ) |
Get the selected duration as array.
mixed | An array containing 'v'=>xx, 'u'=>xx, or null if not set |
Reimplemented from admin_setting.
|
inherited |
Get the list of defaults for the flags on this setting.
array | of strings describing the defaults for this setting. This is appended to by this function. |
|
inherited |
Get the currently saved value for a setting flag.
admin_setting_flag | $flag | - One of the admin_setting_flag for this admin_setting. |
bool |
|
staticprotected |
Returns selectable units.
array |
|
inherited |
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.
bool |
|
inherited |
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.
bool |
Reimplemented in admin_setting_sitesetcheckbox, admin_setting_sitesetselect, admin_setting_sitesettext, and admin_setting_special_frontpagedesc.
|
inherited |
Is this option forced in config.php?
bool |
|
inherited |
Is setting related to query text - used when searching.
string | $query |
bool |
Reimplemented in admin_setting_configmulticheckbox, admin_setting_configmultiselect, admin_setting_configselect, 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, core_admin\admin\admin_setting_plugin_manager, 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, and tool_log_setting_managestores.
admin_setting_configduration::output_html | ( | $data, | |
$query = '' ) |
Returns duration text+select fields.
array | $data | Must be form 'v'=>xx, 'u'=>xx |
string | $query |
string | duration text+select fields and wrapping div(s) |
Reimplemented from admin_setting.
|
inherited |
Output the input fields for the advanced and locked flags on this setting.
bool | $adv | - The current value of the advanced flag. |
bool | $locked | - The current value of the locked flag. |
string\$output | - The html for the flags. |
|
staticprotected |
Finds suitable units for given duration.
int | $seconds |
array |
|
inherited |
Execute postupdatecallback if necessary.
mixed | $original | original value before write_setting() |
bool | true if changed, false if not. |
Reimplemented in admin_setting_configstoredfile.
|
inherited |
Set the advanced options flag on this admin setting.
bool | $enabled | - One of self\OPTION_ENABLED or self\OPTION_DISABLED |
bool | $default | - The default for the flag |
|
inherited |
bool | $affectsmodinfo | If true, changes to this setting will cause the course cache to be rebuilt |
|
inherited |
Set the enabled options flag on this admin setting.
bool | $enabled | - One of self\OPTION_ENABLED or self\OPTION_DISABLED |
bool | $default | - The default for the flag |
|
protectedinherited |
Generic function to add a flag to this admin setting.
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. |
|
inherited |
Set whether to force LTR or not.
bool | $value | True when forced, false when not force, null when unknown. |
|
inherited |
Set the locked options flag on this admin setting.
bool | $enabled | - One of self\OPTION_ENABLED or self\OPTION_DISABLED |
bool | $default | - The default for the flag |
admin_setting_configduration::set_max_duration | ( | ?int | $duration | ) |
Set the maximum allowed value.
A value of null will disable the maximum duration value.
int | null | $duration |
admin_setting_configduration::set_min_duration | ( | int | $duration | ) |
Set the minimum allowed value.
This must be at least 0.
int | $duration |
|
inherited |
Set the required options flag on this admin setting.
bool | $enabled | - One of self\OPTION_ENABLED or self\OPTION_DISABLED. |
bool | $default | - The default for the flag. |
|
inherited |
Function called if setting updated - cleanup, cache reset, etc.
string | $functionname | Sets the function name |
void |
admin_setting_configduration::set_validate_function | ( | ?callable | $validatefunction = null | ) |
Sets a validate function.
The callback will be passed one parameter, the new setting value, and should return either an empty string '' if the value is OK, or an error message if not.
callable | null | $validatefunction | Validate function or null to clear |
|
protected |
Validate the setting.
This uses the callback function if provided; subclasses could override to carry out validation directly in the class.
int | $data | New value being set |
string | Empty string if valid, or error message text |
admin_setting_configduration::write_setting | ( | $data | ) |
Store the duration as seconds.
array | $data | Must be form 'h'=>xx, 'm'=>xx |
bool | true if success, false if not |
Reimplemented from admin_setting.
|
inherited |
Write the values of the flags for this admin setting.
array | $data | - The data submitted from the form or null to set the default value for new installs. |
bool | - true if successful. |
|
inherited |
can be String or Null.
Null means main config table