Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
admin_setting_flag Class Reference

An additional option that can be applied to an admin setting. More...

Public Member Functions

 __construct ($enabled, $default, $shortname, $displayname)
 Constructor.
 
 get_default ()
 Should this option be checked by default?
 
 get_displayname ()
 Return the display name for this flag.
 
 get_shortname ()
 Return the short name for this flag.
 
 is_enabled ()
 Should this option appear in the interface and be toggleable?
 
 output_setting_flag (admin_setting $setting)
 Output the checkbox for this setting flag.
 
 set_options ($enabled, $default)
 Update the values of this setting options class.
 
 write_setting_flag (admin_setting $setting, $data)
 Save the submitted data for this flag - or set it to the default if $data is null.
 

Public Attributes

bool const DISABLED = false
 Checkbox for this flag is not displayed in admin page.
 
bool const ENABLED = true
 Checkbox for this flag is displayed in admin page.
 

Detailed Description

An additional option that can be applied to an admin setting.

The currently supported options are 'ADVANCED', 'LOCKED' and 'REQUIRED'.

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

Constructor & Destructor Documentation

◆ __construct()

admin_setting_flag::__construct ( $enabled,
$default,
$shortname,
$displayname )

Constructor.

Parameters
bool$enabledCan this option can be toggled. Should be one of admin_setting_flag\ENABLED or admin_setting_flag\DISABLED.
bool$defaultThe default checked state for this setting option.
string$shortnameThe shortname of this flag. Currently supported flags are 'locked' and 'adv'
string$displaynameThe displayname of this flag. Used as a label for the flag.

Member Function Documentation

◆ get_default()

admin_setting_flag::get_default ( )

Should this option be checked by default?

Return values
boolIs it on by default?

◆ get_displayname()

admin_setting_flag::get_displayname ( )

Return the display name for this flag.

e.g. 'Advanced' or 'Locked'

Return values
string

◆ get_shortname()

admin_setting_flag::get_shortname ( )

Return the short name for this flag.

e.g. 'adv' or 'locked'

Return values
string

◆ is_enabled()

admin_setting_flag::is_enabled ( )

Should this option appear in the interface and be toggleable?

Return values
boolIs it enabled?

◆ output_setting_flag()

admin_setting_flag::output_setting_flag ( admin_setting $setting)

Output the checkbox for this setting flag.

Should only be called if the flag is enabled.

Parameters
admin_setting$setting- The admin setting for this flag
Return values
string- The html for the checkbox.

◆ set_options()

admin_setting_flag::set_options ( $enabled,
$default )

Update the values of this setting options class.

Parameters
bool$enabledCan this option can be toggled. Should be one of admin_setting_flag\ENABLED or admin_setting_flag\DISABLED.
bool$defaultThe default checked state for this setting option.

◆ write_setting_flag()

admin_setting_flag::write_setting_flag ( admin_setting $setting,
$data )

Save the submitted data for this flag - or set it to the default if $data is null.

Parameters
admin_setting$setting- The admin setting for this flag
array$data- The data submitted from the form or null to set the default value for new installs.
Return values
bool

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