Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
base_setting Class Reference

This abstract class defines one basic setting. More...

Inheritance diagram for base_setting:
backup_setting activity_backup_setting course_backup_setting root_backup_setting section_backup_setting backup_activity_generic_setting backup_activity_included_setting backup_activity_userinfo_setting restore_activity_generic_setting restore_course_generic_setting backup_anonymize_setting backup_generic_setting restore_generic_setting restore_role_assignments_setting backup_section_generic_setting backup_section_included_setting backup_section_userinfo_setting restore_section_generic_setting

Public Member Functions

 __construct ($name, $vtype, $value=null, $visibility=self::VISIBLE, $status=self::NOT_LOCKED)
 Instantiates a setting object.
 
 add_dependency (base_setting $dependentsetting, $type=null, $options=array())
 Quick method to add a dependency to this setting.
 
 destroy ()
 Destroy all circular references.
 
 get_dependencies ()
 
 get_help ()
 Gets the help string params for this setting if it has been set.
 
 get_my_dependency_properties ($settingname=null)
 Gets an array of properties for all of the dependencies that will affect this setting.
 
 get_name ()
 
 get_param_validation ()
 Get the PARAM_XXXX validation to be applied to the setting.
 
 get_settings_depended_on ()
 Returns all of the dependencies that affect this setting.
 
 get_status ()
 
 get_ui ()
 Gets the user interface for this setting.
 
 get_ui_name ()
 
 get_ui_type ()
 
 get_value ()
 
 get_visibility ()
 
 has_dependencies_on_settings ()
 Checks if this setting is dependent on any other settings.
 
 has_dependent_settings ()
 Checks if there are other settings that are dependent on this setting.
 
 has_help ()
 Returns true if help has been set for this setting.
 
 register_dependency (setting_dependency $dependency)
 Adds a dependency where another setting depends on this setting.
 
 set_help ($identifier, $component='moodle')
 Sets a help string for this setting.
 
 set_status ($status)
 
 set_ui (backup_setting_ui $ui)
 Sets the user interface for this setting.
 
 set_value ($value)
 
 set_visibility ($visibility)
 

Public Attributes

const CHANGED_STATUS = 3
 
const CHANGED_VALUE = 1
 
const CHANGED_VISIBILITY = 2
 
const HIDDEN = 0
 
const IS_BOOLEAN = 'bool'
 
const IS_FILENAME = 'file'
 
const IS_INTEGER = 'int'
 
const IS_PATH = 'path'
 
const IS_TEXT = 'text'
 
const LOCKED_BY_CONFIG = 5
 
const LOCKED_BY_HIERARCHY = 7
 
const LOCKED_BY_PERMISSION = 9
 
const NOT_LOCKED = 3
 
const UI_HTML_CHECKBOX = 10
 
const UI_HTML_DROPDOWN = 30
 
const UI_HTML_RADIOBUTTON = 20
 
const UI_HTML_TEXTFIELD = 40
 
const UI_NONE = 0
 
const VISIBLE = 1
 

Protected Member Functions

 inform_dependencies ($ctype, $oldv)
 
 is_circular_reference ($obj)
 
 register_dependent_dependency (setting_dependency $dependency)
 Adds a dependency where this setting is dependent on another.
 
 validate_status ($status)
 
 validate_value ($vtype, $value)
 
 validate_visibility ($visibility)
 

Protected Attributes

setting_dependency[] $dependencies = array()
 
 $dependenton = array()
 
array $help = array()
 An array that contains the identifier and component of a help string if one has been set.
 
 $name
 
 $status
 
backup_setting_ui backup_setting_ui_checkbox backup_setting_ui_radio backup_setting_ui_select backup_setting_ui_text $uisetting
 The user interface for this setting.
 
 $unlockedvalue
 
 $value
 
 $visibility
 
 $vtype
 

Detailed Description

This abstract class defines one basic setting.

Each setting will be able to control its name, value (from a list), ui representation (check box, drop down, text field...), visibility, status (editable/locked...) and its hierarchy with other settings (using one like-observer pattern.

TODO: Finish phpdocs

Constructor & Destructor Documentation

◆ __construct()

base_setting::__construct ( $name,
$vtype,
$value = null,
$visibility = self::VISIBLE,
$status = self::NOT_LOCKED )

Instantiates a setting object.

Parameters
string$nameName of the setting
string$vtypeType of the setting, eg self::IS_TEXT
mixed$valueValue of the setting
bool$visibilityIs the setting visible in the UI, eg self::VISIBLE
int$statusStatus of the setting with regards to the locking, eg self::NOT_LOCKED

Reimplemented in activity_backup_setting, backup_filename_setting, backup_setting, course_backup_setting, restore_course_generic_text_setting, root_backup_setting, and section_backup_setting.

Member Function Documentation

◆ add_dependency()

base_setting::add_dependency ( base_setting $dependentsetting,
$type = null,
$options = array() )

Quick method to add a dependency to this setting.

The dependency created is done so by inspecting this setting and the setting that is passed in as the dependent setting.

Parameters
base_setting$dependentsetting
int$typeOne of setting_dependency::*
array$options

Reimplemented in backup_setting.

◆ destroy()

base_setting::destroy ( )

Destroy all circular references.

It helps PHP 5.2 a lot!

◆ get_help()

base_setting::get_help ( )

Gets the help string params for this setting if it has been set.

Return values
array|falseAn array (identifier, component) or false if not set

◆ get_my_dependency_properties()

base_setting::get_my_dependency_properties ( $settingname = null)

Gets an array of properties for all of the dependencies that will affect this setting.

This method returns an array rather than the dependencies in order to minimise the memory footprint of for the potentially huge recursive dependency structure that we may be dealing with.

This method also ensures that all dependencies are transmuted to affect the setting in question and that we don't provide any duplicates.

Parameters
string | null$settingname
Return values
array

◆ get_param_validation()

base_setting::get_param_validation ( )

Get the PARAM_XXXX validation to be applied to the setting.

Return values
stringThe PARAM_XXXX constant of null if the setting type is not defined

◆ get_settings_depended_on()

base_setting::get_settings_depended_on ( )

Returns all of the dependencies that affect this setting.

e.g. settings this setting depends on.

Return values
arrayArray of setting_dependency's

◆ get_ui()

base_setting::get_ui ( )

Gets the user interface for this setting.

Return values
base_setting_ui

◆ has_dependencies_on_settings()

base_setting::has_dependencies_on_settings ( )

Checks if this setting is dependent on any other settings.

Return values
boolTrue if this setting is dependent on any other settings

◆ has_dependent_settings()

base_setting::has_dependent_settings ( )

Checks if there are other settings that are dependent on this setting.

Return values
boolTrue if there are other settings that are dependent on this setting

◆ has_help()

base_setting::has_help ( )

Returns true if help has been set for this setting.

Return values
cool

◆ register_dependency()

base_setting::register_dependency ( setting_dependency $dependency)

Adds a dependency where another setting depends on this setting.

Parameters
setting_dependency$dependency

◆ register_dependent_dependency()

base_setting::register_dependent_dependency ( setting_dependency $dependency)
protected

Adds a dependency where this setting is dependent on another.

This should only be called internally once we are sure it is not cicrular.

Parameters
setting_dependency$dependency

◆ set_help()

base_setting::set_help ( $identifier,
$component = 'moodle' )

Sets a help string for this setting.

Parameters
string$identifier
string$component

◆ set_ui()

base_setting::set_ui ( backup_setting_ui $ui)

Sets the user interface for this setting.

Parameters
base_setting_ui$ui

◆ validate_value()

base_setting::validate_value ( $vtype,
$value )
protected

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