Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Static Public Member Functions | |
static | delete_service_descriptions (string $component) |
Delete all pre-built services, related tokens, and external functions information defined for the specified component. | |
static | format_string ( $content, $context, $striplinks=true, $options=[]) |
Format the string to be returned properly as requested by the either the web service server, either by an internally call. | |
static | format_text ( $text, $textformat, $context, $component=null, $filearea=null, $itemid=null, $options=null) |
Format the text to be returned properly as requested by the either the web service server, either by an internally call. | |
static | generate_token (int $tokentype, stdClass $service, int $userid, context $context, int $validuntil=0, string $iprestriction='', string $name='') |
Create and return a session linked token. | |
static | generate_token_for_current_user (stdClass $service) |
Generate or return an existing token for the current authenticated user. | |
static | generate_token_name () |
Generate token name. | |
static | get_area_files ($contextid, $component, $filearea, $itemid=false, $useitemidinurl=true) |
Returns all area files (optionally limited by itemid). | |
static | get_service_by_id (int $serviceid) |
Get a service by its id. | |
static | get_service_by_name (string $name) |
Get a service by its name. | |
static | log_token_request (stdClass $token) |
Set the last time a token was sent and trigger the core\event\webservice_token_sent event. | |
static | validate_courses ( $courseids, $courses=[], $addcontext=false, $keepfails=false) |
Validate a list of courses, returning the complete course objects for valid courses. | |
static | validate_format ($format) |
Validate text field format against known FORMAT_XXX. | |
|
static |
Delete all pre-built services, related tokens, and external functions information defined for the specified component.
string | $component | The frankenstyle component name |
|
static |
Format the string to be returned properly as requested by the either the web service server, either by an internally call.
The caller can change the format (raw) with the settings singleton All web service servers must set this singleton when parsing the $_GET and $_POST.
Options are the same that in {
string | null | $content | The string to be filtered. Should be plain text, expect possibly for multilang tags. |
int | context | $context | The id of the context for the string or the context (affects filters). |
boolean | $striplinks | To strip any link in the result text. Moodle 1.8 default changed from false to true! MDL-8713 |
array | $options | options array/object or courseid |
string | text |
|
static |
Format the text to be returned properly as requested by the either the web service server, either by an internally call.
The caller can change the format (raw, filter, file, fileurl) with the core_external\settings singleton All web service servers must set this singleton when parsing the $_GET and $_POST.
Options are the same that in {
string | null | $text | The content that may contain ULRs in need of rewriting. |
string | int | null | $textformat | The text format. |
context | $context | This parameter and the next two identify the file area to use. |
string | null | $component | |
string | null | $filearea | helps identify the file area. |
int | string | null | $itemid | helps identify the file area. |
array | stdClass | null | $options | text formatting options |
array | text + textformat |
|
static |
Create and return a session linked token.
Token to be used for html embedded client apps that want to communicate with the Moodle server through web services. The token is linked to the current session for the current page request. It is expected this will be called in the script generating the html page that is embedding the client app and that the returned token will be somehow passed into the client app being embedded in the page.
int | $tokentype | EXTERNAL_TOKEN_EMBEDDED|EXTERNAL_TOKEN_PERMANENT |
stdClass | $service | service linked to the token |
int | $userid | user linked to the token |
context | $context | |
int | $validuntil | date when the token expired |
string | $iprestriction | allowed ip - if 0 or empty then all ips are allowed |
string | $name | token name as a note or token identity at the table view. |
string | generated token |
|
static |
Generate or return an existing token for the current authenticated user.
This function is used for creating a valid token for users authenticathing via places, including:
stdClass | $service | external service object |
stdClass | token object |
moodle_exception |
|
static |
Generate token name.
string |
|
static |
Returns all area files (optionally limited by itemid).
int | $contextid | context ID |
string | $component | component |
string | $filearea | file area |
int | $itemid | item ID or all files if not specified |
bool | $useitemidinurl | wether to use the item id in the file URL (modules intro don't use it) |
array | of files, compatible with the external_files structure. |
|
static |
Get a service by its id.
int | $serviceid |
stdClass |
|
static |
Get a service by its name.
string | $name | The service name. |
stdClass |
|
static |
Set the last time a token was sent and trigger the core\event\webservice_token_sent event.
This function is used when a token is generated by the user via login/token.php or admin/tool/mobile/launch.php. In order to protect the privatetoken, we remove it from the event params.
stdClass | $token | token object |
|
static |
Validate a list of courses, returning the complete course objects for valid courses.
Each course has an additional 'contextvalidated' field, this will be set to true unless you set $keepfails, in which case it will be false if validation fails for a course.
array | $courseids | A list of course ids |
array | $courses | An array of courses already pre-fetched, indexed by course id. |
bool | $addcontext | True if the returned course object should include the full context object. |
bool | $keepfails | True to keep all the course objects even if validation fails |
array | An array of courses and the validation warnings |
|
static |
Validate text field format against known FORMAT_XXX.
string | $format | the format to validate |
string | the validated format |
moodle_exception |