Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Static Public Member Functions | Static Protected Member Functions | List of all members
tool_mobile\external Class Reference

This is the external API for this tool. More...

Inheritance diagram for tool_mobile\external:
external_api

Static Public Member Functions

static call_external_function ($function, $args, $ajaxonly=false)
 Call an external function validating all params/returns correctly. More...
 
static call_external_functions ($requests)
 Call multiple external functions and return all responses. More...
 
static call_external_functions_parameters ()
 Returns description of method parameters. More...
 
static call_external_functions_returns ()
 Returns description of method result value. More...
 
static clean_returnvalue (external_description $description, $response)
 Clean response If a response attribute is unknown from the description, we just ignore the attribute. More...
 
static external_function_info ($function, $strictness=MUST_EXIST)
 Returns detailed function information. More...
 
static get_autologin_key ($privatetoken)
 Creates an auto-login key for the current user. More...
 
static get_autologin_key_parameters ()
 Returns description of get_autologin_key() parameters. More...
 
static get_autologin_key_returns ()
 Returns description of get_autologin_key() result value. More...
 
static get_config ($section='')
 Returns a list of site settings, filtering by section. More...
 
static get_config_parameters ()
 Returns description of get_config() parameters. More...
 
static get_config_returns ()
 Returns description of get_config() result value. More...
 
static get_content ($component, $method, $args=array())
 Returns a piece of content to be displayed in the Mobile app, it usually returns a template, javascript and other structured data that will be used to render a view in the Mobile app. More...
 
static get_content_parameters ()
 Returns description of get_content() parameters. More...
 
static get_content_returns ()
 Returns description of get_content() result value. More...
 
static get_plugins_supporting_mobile ()
 Returns a list of Moodle plugins supporting the mobile app. More...
 
static get_plugins_supporting_mobile_parameters ()
 Returns description of get_plugins_supporting_mobile() parameters. More...
 
static get_plugins_supporting_mobile_returns ()
 Returns description of get_plugins_supporting_mobile() result value. More...
 
static get_public_config ()
 Returns a list of the site public settings, those not requiring authentication. More...
 
static get_public_config_parameters ()
 Returns description of get_public_config() parameters. More...
 
static get_public_config_returns ()
 Returns description of get_public_config() result value. More...
 
static get_tokens_for_qr_login ($qrloginkey, $userid)
 Returns a WebService token (and private token) for QR login. More...
 
static get_tokens_for_qr_login_parameters ()
 Returns description of get_tokens_for_qr_login() parameters. More...
 
static get_tokens_for_qr_login_returns ()
 Returns description of get_tokens_for_qr_login() result value. More...
 
static set_context_restriction ($context)
 Set context restriction for all following subsequent function calls. More...
 
static set_timeout ($seconds=360)
 This method has to be called before every operation that takes a longer time to finish! More...
 
static validate_context ($context)
 Makes sure user may execute functions in this context. More...
 
static validate_parameters (external_description $description, $params)
 Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown. More...
 
static validate_subscription_key (string $key)
 Check if the given site subscription key is valid. More...
 
static validate_subscription_key_parameters ()
 Returns description of validate_subscription_key() parameters. More...
 
static validate_subscription_key_returns ()
 Returns description of validate_subscription_key() result value. More...
 

Static Protected Member Functions

static get_context_from_params ($param)
 Get context from passed parameters. More...
 
static get_context_parameters ()
 Returns a prepared structure to use a context parameters. More...
 

Detailed Description

This is the external API for this tool.

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

Member Function Documentation

◆ call_external_function()

static external_api::call_external_function (   $function,
  $args,
  $ajaxonly = false 
)
staticinherited

Call an external function validating all params/returns correctly.

Note that an external function may modify the state of the current page, so this wrapper saves and restores tha PAGE and COURSE global variables before/after calling the external function.

Parameters
string$functionA webservice function name.
array$argsParams array (named params)
boolean$ajaxonlyIf true, an extra check will be peformed to see if ajax is required.
Return values
arraycontaining keys for error (bool), exception and data.

◆ call_external_functions()

static tool_mobile\external::call_external_functions (   $requests)
static

Call multiple external functions and return all responses.

Parameters
array$requestsList of requests.
Return values
arrayResponses.
Since
Moodle 3.7

◆ call_external_functions_parameters()

static tool_mobile\external::call_external_functions_parameters ( )
static

Returns description of method parameters.

Return values
external_function_parameters
Since
Moodle 3.7

◆ call_external_functions_returns()

static tool_mobile\external::call_external_functions_returns ( )
static

Returns description of method result value.

Return values
external_single_structure
Since
Moodle 3.7

◆ clean_returnvalue()

static external_api::clean_returnvalue ( external_description  $description,
  $response 
)
staticinherited

Clean response If a response attribute is unknown from the description, we just ignore the attribute.

If a response attribute is incorrect, invalid_response_exception is thrown. Note: this function is similar to validate parameters, however it is distinct because parameters validation must be distinct from cleaning return values.

Parameters
external_description$descriptiondescription of the return values
mixed$responsethe actual response
Return values
mixedresponse with added defaults for optional items, invalid_response_exception thrown if any problem found
Author
2010 Jerome Mouneyrac
Since
Moodle 2.0

◆ external_function_info()

static external_api::external_function_info (   $function,
  $strictness = MUST_EXIST 
)
staticinherited

Returns detailed function information.

Parameters
string | object$functionname of external function or record from external_function
int$strictnessIGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; MUST_EXIST means throw exception if no record or multiple records found
Return values
stdClassdescription or false if not found or exception thrown
Since
Moodle 2.0

◆ get_autologin_key()

static tool_mobile\external::get_autologin_key (   $privatetoken)
static

Creates an auto-login key for the current user.

Is created only in https sites and is restricted by time and ip address.

Please note that it only works if the request comes from the Moodle mobile or desktop app.

Parameters
string$privatetokenthe user private token for validating the request
Return values
arraywith the settings and warnings
Since
Moodle 3.2

◆ get_autologin_key_parameters()

static tool_mobile\external::get_autologin_key_parameters ( )
static

Returns description of get_autologin_key() parameters.

Return values
external_function_parameters
Since
Moodle 3.2

◆ get_autologin_key_returns()

static tool_mobile\external::get_autologin_key_returns ( )
static

Returns description of get_autologin_key() result value.

Return values
external_description
Since
Moodle 3.2

◆ get_config()

static tool_mobile\external::get_config (   $section = '')
static

Returns a list of site settings, filtering by section.

Parameters
string$sectionsettings section name
Return values
arraywith the settings and warnings
Since
Moodle 3.2

◆ get_config_parameters()

static tool_mobile\external::get_config_parameters ( )
static

Returns description of get_config() parameters.

Return values
external_function_parameters
Since
Moodle 3.2

◆ get_config_returns()

static tool_mobile\external::get_config_returns ( )
static

Returns description of get_config() result value.

Return values
external_description
Since
Moodle 3.2

◆ get_content()

static tool_mobile\external::get_content (   $component,
  $method,
  $args = array() 
)
static

Returns a piece of content to be displayed in the Mobile app, it usually returns a template, javascript and other structured data that will be used to render a view in the Mobile app.

Callbacks (placed in $component::output::mobile) that are called by this web service are responsible for doing the appropriate security checks to access the information to be returned.

Parameters
string$componentname of the component.
string$methodfunction method name in class $component::output::mobile.
array$argsoptional arguments for the method.
Return values
arrayHTML, JavaScript and other required data and information to create a view in the app.
Since
Moodle 3.5
Exceptions
coding_exception

◆ get_content_parameters()

static tool_mobile\external::get_content_parameters ( )
static

Returns description of get_content() parameters.

Return values
external_function_parameters
Since
Moodle 3.5

◆ get_content_returns()

static tool_mobile\external::get_content_returns ( )
static

Returns description of get_content() result value.

Return values
array
Since
Moodle 3.5

◆ get_context_from_params()

static external_api::get_context_from_params (   $param)
staticprotectedinherited

Get context from passed parameters.

The passed array must either contain a contextid or a combination of context level and instance id to fetch the context. For example, the context level can be "course" and instanceid can be courseid.

See context_helper::get_all_levels() for a list of valid context levels.

Parameters
array$param
Since
Moodle 2.6
Exceptions
invalid_parameter_exception
Return values
context

◆ get_context_parameters()

static external_api::get_context_parameters ( )
staticprotectedinherited

Returns a prepared structure to use a context parameters.

Return values
external_single_structure

Reimplemented in tool_lp\external, and core_competency\external.

◆ get_plugins_supporting_mobile()

static tool_mobile\external::get_plugins_supporting_mobile ( )
static

Returns a list of Moodle plugins supporting the mobile app.

Return values
arrayan array of warnings and objects containing the plugin information
Since
Moodle 3.1

◆ get_plugins_supporting_mobile_parameters()

static tool_mobile\external::get_plugins_supporting_mobile_parameters ( )
static

Returns description of get_plugins_supporting_mobile() parameters.

Return values
external_function_parameters
Since
Moodle 3.1

◆ get_plugins_supporting_mobile_returns()

static tool_mobile\external::get_plugins_supporting_mobile_returns ( )
static

Returns description of get_plugins_supporting_mobile() result value.

Return values
external_description
Since
Moodle 3.1

◆ get_public_config()

static tool_mobile\external::get_public_config ( )
static

Returns a list of the site public settings, those not requiring authentication.

Return values
arraywith the settings and warnings
Since
Moodle 3.2

◆ get_public_config_parameters()

static tool_mobile\external::get_public_config_parameters ( )
static

Returns description of get_public_config() parameters.

Return values
external_function_parameters
Since
Moodle 3.2

◆ get_public_config_returns()

static tool_mobile\external::get_public_config_returns ( )
static

Returns description of get_public_config() result value.

Return values
external_description
Since
Moodle 3.2

◆ get_tokens_for_qr_login()

static tool_mobile\external::get_tokens_for_qr_login (   $qrloginkey,
  $userid 
)
static

Returns a WebService token (and private token) for QR login.

Parameters
string$qrloginkeythe user key generated and embedded into the QR code for validating the request
int$useridthe user the key belongs to
Return values
arraywith the tokens and warnings
Since
Moodle 3.9

◆ get_tokens_for_qr_login_parameters()

static tool_mobile\external::get_tokens_for_qr_login_parameters ( )
static

Returns description of get_tokens_for_qr_login() parameters.

Return values
external_function_parameters
Since
Moodle 3.9

◆ get_tokens_for_qr_login_returns()

static tool_mobile\external::get_tokens_for_qr_login_returns ( )
static

Returns description of get_tokens_for_qr_login() result value.

Return values
external_description
Since
Moodle 3.9

◆ set_context_restriction()

static external_api::set_context_restriction (   $context)
staticinherited

Set context restriction for all following subsequent function calls.

Parameters
stdClass$contextthe context restriction
Since
Moodle 2.0

◆ set_timeout()

static external_api::set_timeout (   $seconds = 360)
staticinherited

This method has to be called before every operation that takes a longer time to finish!

Parameters
int$secondsmax expected time the next operation needs
Since
Moodle 2.0

◆ validate_context()

static external_api::validate_context (   $context)
staticinherited

Makes sure user may execute functions in this context.

Parameters
stdClass$context
Since
Moodle 2.0

◆ validate_parameters()

static external_api::validate_parameters ( external_description  $description,
  $params 
)
staticinherited

Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown.

This is a simple recursive method which is intended to be called from each implementation method of external API.

Parameters
external_description$descriptiondescription of parameters
mixed$paramsthe actual parameters
Return values
mixedparams with added defaults for optional items, invalid_parameters_exception thrown if any problem found
Since
Moodle 2.0

◆ validate_subscription_key()

static tool_mobile\external::validate_subscription_key ( string  $key)
static

Check if the given site subscription key is valid.

Parameters
string$keysubscriptiion temporary key
Return values
arraywith the settings and warnings
Since
Moodle 3.9

◆ validate_subscription_key_parameters()

static tool_mobile\external::validate_subscription_key_parameters ( )
static

Returns description of validate_subscription_key() parameters.

Return values
external_function_parameters
Since
Moodle 3.9

◆ validate_subscription_key_returns()

static tool_mobile\external::validate_subscription_key_returns ( )
static

Returns description of validate_subscription_key() result value.

Return values
external_description
Since
Moodle 3.9

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