Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
enrol_user_button Class Reference

A button that is used to enrol users in a course. More...

Inheritance diagram for enrol_user_button:
single_button renderable

Public Member Functions

 __construct (moodle_url $url, $label, $method='post')
 Initialises the new enrol_user_button.
 
 __get ($name)
 Magic method getter.
 
 __set ($name, $value)
 Magic setter method.
 
 add_action (component_action $action)
 Add action to the button.
 
 add_confirm_action ($confirmmessage)
 Shortcut for adding a JS confirm dialog when the button is clicked.
 
 export_for_template (renderer_base $output)
 Export data.
 
 initialise_js (moodle_page $page)
 Initialises the JS that is required by this button.
 
 require_js_init_call ($function, array $extraarguments=null, $ondomready=false, array $module=null)
 Adds a JS initialisation call to the page when the button is used.
 
 require_yui_module ($modules, $function, array $arguments=null, $galleryversion=null, $ondomready=false)
 Adds a YUI module call that will be added to the page when the button is used.
 
 set_attribute ($name, $value)
 Sets an attribute for the HTML button tag.
 
 strings_for_js ($identifiers, $component='moodle', $a=null)
 Requires strings for JS that will be loaded when the button is used.
 

Public Attributes

string $actionid
 Action id.
 
array $actions = array()
 List of attached actions.
 
string $class = 'singlebutton'
 Wrapping div class.
 
bool $disabled = false
 True if button disabled, false if normal.
 
string $formid
 Form id.
 
string $label
 Button label.
 
string $method = 'post'
 Form submit method post or get.
 
array $params
 $params URL Params
 
string $tooltip = null
 Button tooltip.
 
moodle_url $url
 Target url.
 
const BUTTON_DANGER = 'danger'
 Possible button types - Danger.
 
const BUTTON_INFO = 'info'
 Possible button types - Info.
 
const BUTTON_PRIMARY = 'primary'
 Possible button types - Primary.
 
const BUTTON_SECONDARY = 'secondary'
 Possible button types - Secondary.
 
const BUTTON_SUCCESS = 'success'
 Possible button types - Success.
 
const BUTTON_TYPES
 Possible button types.
 
const BUTTON_WARNING = 'warning'
 Possible button types - Warning.
 

Protected Attributes

array $attributes = []
 
array $jsinitcalls = array()
 An array containing JS initialisation calls required by this button.
 
array $jsstrings = array()
 An array strings required by JS for this button.
 
array $jsyuimodules = array()
 An array containing JS YUI modules required by this button.
 
string $type
 Type of button (from defined types).
 

Detailed Description

A button that is used to enrol users in a course.

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

Constructor & Destructor Documentation

◆ __construct()

enrol_user_button::__construct ( moodle_url $url,
$label,
$method = 'post' )

Initialises the new enrol_user_button.

@staticvar int $count The number of enrol user buttons already created

Parameters
moodle_url$url
string$labelThe text to display in the button
string$methodEither post or get

Member Function Documentation

◆ __get()

single_button::__get ( $name)
inherited

Magic method getter.

This method manages access to some properties and will display deprecation message when accessing 'primary' property.

Parameters
string$name
Return values
mixed

◆ __set()

single_button::__set ( $name,
$value )
inherited

Magic setter method.

This method manages access to some properties and will display deprecation message when accessing 'primary' property.

Parameters
string$name
mixed$value

◆ add_action()

single_button::add_action ( component_action $action)
inherited

Add action to the button.

Parameters
component_action$action

◆ add_confirm_action()

single_button::add_confirm_action ( $confirmmessage)
inherited

Shortcut for adding a JS confirm dialog when the button is clicked.

The message must be a yes/no question.

Parameters
string$confirmmessageThe yes/no confirmation question. If "Yes" is clicked, the original action will occur.

◆ export_for_template()

single_button::export_for_template ( renderer_base $output)
inherited

Export data.

Parameters
renderer_base$outputRenderer.
Return values
stdClass

◆ initialise_js()

enrol_user_button::initialise_js ( moodle_page $page)

Initialises the JS that is required by this button.

Parameters
moodle_page$page

◆ require_js_init_call()

enrol_user_button::require_js_init_call ( $function,
array $extraarguments = null,
$ondomready = false,
array $module = null )

Adds a JS initialisation call to the page when the button is used.

Parameters
string$functionThe function to call
array$extraargumentsAn array of arguments to pass to the function
bool$ondomreadyIf true the call is postponed until the DOM is finished loading
array$moduleA module definition

◆ require_yui_module()

enrol_user_button::require_yui_module ( $modules,
$function,
array $arguments = null,
$galleryversion = null,
$ondomready = false )

Adds a YUI module call that will be added to the page when the button is used.

Parameters
string | array$modulesOne or more modules to require
string$functionThe JS function to call
array$argumentsAn array of arguments to pass to the function
string$galleryversionDeprecated: The gallery version to use
bool$ondomreadyIf true the call is postponed until the DOM is finished loading

◆ set_attribute()

single_button::set_attribute ( $name,
$value )
inherited

Sets an attribute for the HTML button tag.

Parameters
string$nameThe attribute name
mixed$valueThe value
Return values
null

◆ strings_for_js()

enrol_user_button::strings_for_js ( $identifiers,
$component = 'moodle',
$a = null )

Requires strings for JS that will be loaded when the button is used.

Parameters
type$identifiers
string$component
mixed$a

Member Data Documentation

◆ $type

string single_button::$type
protectedinherited

Type of button (from defined types).

Used for styling.

◆ BUTTON_TYPES

const single_button::BUTTON_TYPES
inherited
Initial value:
= [
self::BUTTON_PRIMARY,
self::BUTTON_SECONDARY,
self::BUTTON_SUCCESS,
self::BUTTON_DANGER,
self::BUTTON_WARNING,
self::BUTTON_INFO
]

Possible button types.

From boostrap.


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