Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
core_admin\local\settings\filesize Class Reference

An admin setting to support entering and displaying of file sizes in Bytes, KB, MB or GB. More...

Inheritance diagram for core_admin\local\settings\filesize:
admin_setting

Public Member Functions

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

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 $plugin
 can be String or Null. More...
 
string $updatedcallback
 
string $visiblename
 localised name
 
int const UNIT_B = 1
 The byte unit. More...
 
int const UNIT_GB = 1073741824
 The gigabyte unit (number of bytes in a gigabyte)
 
int const UNIT_KB = 1024
 The kilobyte unit (number of bytes in a kilobyte)
 
int const UNIT_MB = 1048576
 The megabyte unit (number of bytes in a megabyte)
 

Protected Member Functions

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

Static Protected Member Functions

static get_size_text (int $bytes)
 Converts bytes to some more user friendly string. More...
 
static get_units ()
 Returns selectable units. More...
 
static parse_bytes (int $bytes)
 Finds suitable units for given file size. More...
 

Protected Attributes

bool $customcontrol = false
 Whether this setting uses a custom form control.
 
int $defaultunit
 default size unit
 

Detailed Description

An admin setting to support entering and displaying of file sizes in Bytes, KB, MB or GB.

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

Constructor & Destructor Documentation

◆ __construct()

core_admin\local\settings\filesize::__construct ( string  $name,
string  $visiblename,
string  $description,
int  $defaultvalue = null,
int  $defaultunit = null 
)

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
int | null$defaultvalueValue of the settings in bytes
int | null$defaultunitGB, MB, etc. (in bytes)

Member Function Documentation

◆ add_dependent_on()

admin_setting::add_dependent_on (   $dependenton)
inherited

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 
)
protectedinherited

Log config changes if necessary.

Parameters
string$name
string$oldvalue
string$value

Reimplemented in admin_setting_configpasswordunmask.

◆ config_read()

admin_setting::config_read (   $name)
inherited

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 
)
inherited

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()

admin_setting::get_defaultsetting ( )
inherited

◆ get_dependent_on()

admin_setting::get_dependent_on ( )
inherited

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 ( )
inherited

Get whether this should be displayed in LTR mode.

Return values
bool|null

Reimplemented in admin_setting_filetypes, and admin_setting_configtext.

◆ get_full_name()

admin_setting::get_full_name ( )
inherited

Returns the fullname prefixed by the plugin.

Return values
string

Reimplemented in admin_setting_managerepository.

◆ get_id()

admin_setting::get_id ( )
inherited

Returns the ID string based on plugin and name.

Return values
string

◆ get_setting()

core_admin\local\settings\filesize::get_setting ( )

Get the selected file size as array.

Return values
array|nullAn array containing 'v' => xx, 'u' => xx, or null if not set

Reimplemented from admin_setting.

◆ get_setting_flag_defaults()

admin_setting::get_setting_flag_defaults ( $defaults)
inherited

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)
inherited

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

◆ get_size_text()

static core_admin\local\settings\filesize::get_size_text ( int  $bytes)
staticprotected

Converts bytes to some more user friendly string.

Parameters
int$bytesThe number of bytes we want to convert from
Return values
string

◆ get_units()

static core_admin\local\settings\filesize::get_units ( )
staticprotected

Returns selectable units.

Return values
array

◆ has_custom_form_control()

admin_setting::has_custom_form_control ( )
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.

Return values
bool

◆ is_readonly()

admin_setting::is_readonly ( )
inherited

Is this option forced in config.php?

Return values
bool

◆ is_related()

admin_setting::is_related (   $query)
inherited

◆ output_html()

core_admin\local\settings\filesize::output_html (   $data,
  $query = '' 
)

Returns file size text+select fields.

Parameters
array$dataThe current setting value. Must be form 'v' => xx, 'u' => xx.
string$queryAdmin search query to be highlighted.
Return values
stringFile size text+select fields and wrapping div(s).

Reimplemented from admin_setting.

◆ output_setting_flags()

admin_setting::output_setting_flags ( )
inherited

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.

◆ parse_bytes()

static core_admin\local\settings\filesize::parse_bytes ( int  $bytes)
staticprotected

Finds suitable units for given file size.

Parameters
int$bytesThe number of bytes
Return values
arrayParsed file size in the format of ['v' => value, 'u' => unit]

◆ post_write_settings()

admin_setting::post_write_settings (   $original)
inherited

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 
)
inherited

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)
inherited
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 
)
inherited

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 
)
protectedinherited

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)
inherited

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 
)
inherited

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 
)
inherited

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)
inherited

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

Parameters
string$functionnameSets the function name
Return values
void

◆ write_setting()

core_admin\local\settings\filesize::write_setting (   $data)

Store the file size as bytes.

Parameters
array$dataMust be form 'h' => xx, 'm' => xx
Return values
stringThe error string if any

Reimplemented from admin_setting.

◆ write_setting_flags()

admin_setting::write_setting_flags (   $data)
inherited

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
inherited

can be String or Null.

Null means main config table

◆ UNIT_B

int const core_admin\local\settings\filesize::UNIT_B = 1

The byte unit.

Number of bytes in a byte


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